Meta ads: boosts, standalone ads, audiences, targeting, and lead forms.
Every function needs the ads scope. boost/2, create/2, set_status/3, and
delete/3 spend money and also need the publish scope. A boost or an ad starts
paused unless :paused is false.
{:ok, ad} =
FoPost.Ads.boost(client,
workspace_id: workspace.id,
connection_id: connection.id,
ad_account_id: "act_123",
post_id: post.id,
account_id: account.id,
name: "Launch week",
goal: "engagement",
budget: %{minor: 5_000, type: "daily"},
targeting: %{countries: ["US"], ageMin: 18, ageMax: 65, gender: "all"}
):budget and :targeting are sent as given, so spell their keys the way the API
does (minor, type, endAt; countries, ageMin, ageMax, gender,
audienceIds, locations, interests, behaviors, income).
Summary
Functions
The saved audiences and pixels on an ad account. Required: :connection_id,
:ad_account_id. Optional: :workspace_id.
Same as audiences/2, but raises FoPost.Error.
The Meta login URL; finish it in a browser. Required: :workspace_id. Optional:
:method (business, user), :return_to.
Same as authorize_meta/2, but raises FoPost.Error.
Promotes a post FoPost already published. Needs the publish scope as well as ads.
Starts paused unless paused: false.
Same as boost/2, but raises FoPost.Error.
Published posts a boost can start from.
Same as boostable/2, but raises FoPost.Error.
The ads logins connected to the workspace.
Same as connections/2, but raises FoPost.Error.
Creates a standalone ad from a creative. Needs the publish scope as well as ads.
Starts paused unless paused: false.
Same as create/2, but raises FoPost.Error.
Creates an audience. Required: :workspace_id, :connection_id, :ad_account_id,
:name, :spec. Optional: :description.
Same as create_audience/2, but raises FoPost.Error.
Creates an Instant Form on a Page; answers its id.
Same as create_lead_form/2, but raises FoPost.Error.
Ends delivery and deletes the ad on Meta as well as here. Needs the publish scope as
well as ads. Required: :workspace_id.
Same as delete/3, but raises FoPost.Error.
Disconnects an ads login. Every ad record created through it is deleted too.
Required: :workspace_id.
Same as delete_connection/3, but raises FoPost.Error.
Ads on the connected ad accounts that were made elsewhere. Read live, never stored.
Same as external/2, but raises FoPost.Error.
Each connection and Page with the lead forms on it.
Same as lead_forms/2, but raises FoPost.Error.
One page of a form's leads. Required: :connection_id, :page_id. Optional: :after
(the previous page's next_cursor), :workspace_id.
Same as leads/3, but raises FoPost.Error.
Boosts and ads created through FoPost, with insights from their last refresh.
Optionally narrowed with :workspace_id.
Same as list/2, but raises FoPost.Error.
Reads the delivery status and lifetime insights from Meta. Required: :workspace_id.
Same as refresh/3, but raises FoPost.Error.
Locations, interests, behaviours, and income brackets as Meta names them.
Required: :connection_id, :type (country, region, city, zip, metro,
interest, behavior, income). Optional: :q, :workspace_id.
Same as search_targeting/2, but raises FoPost.Error.
Pauses or resumes an ad. Needs the publish scope as well as ads.
Required: :workspace_id, :status (active, paused).
Same as set_status/3, but raises FoPost.Error.
Each connection with the ad accounts and Pages its grant reaches.
Same as sources/2, but raises FoPost.Error.
Functions
@spec audiences( FoPost.Client.t(), keyword() ) :: {:ok, FoPost.AudiencesResult.t()} | {:error, FoPost.Error.t()}
The saved audiences and pixels on an ad account. Required: :connection_id,
:ad_account_id. Optional: :workspace_id.
Same as audiences/2, but raises FoPost.Error.
@spec authorize_meta( FoPost.Client.t(), keyword() ) :: {:ok, String.t()} | {:error, FoPost.Error.t()}
The Meta login URL; finish it in a browser. Required: :workspace_id. Optional:
:method (business, user), :return_to.
Same as authorize_meta/2, but raises FoPost.Error.
@spec boost( FoPost.Client.t(), keyword() ) :: {:ok, FoPost.Ad.t()} | {:error, FoPost.Error.t()}
Promotes a post FoPost already published. Needs the publish scope as well as ads.
Starts paused unless paused: false.
Required: :workspace_id, :connection_id, :ad_account_id, :post_id,
:account_id, :name, :goal (engagement, traffic, awareness, video_views),
:budget, :targeting. Optional: :paused.
Same as boost/2, but raises FoPost.Error.
@spec boostable( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.BoostablePost.t()]} | {:error, FoPost.Error.t()}
Published posts a boost can start from.
Same as boostable/2, but raises FoPost.Error.
@spec connections( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.AdConnection.t()]} | {:error, FoPost.Error.t()}
The ads logins connected to the workspace.
Same as connections/2, but raises FoPost.Error.
@spec create( FoPost.Client.t(), keyword() ) :: {:ok, FoPost.Ad.t()} | {:error, FoPost.Error.t()}
Creates a standalone ad from a creative. Needs the publish scope as well as ads.
Starts paused unless paused: false.
Required: :workspace_id, :connection_id, :ad_account_id, :page_id, :name,
:goal, :budget, :targeting, :text. Optional: :headline, :destination_url,
:media_url, :paused.
Same as create/2, but raises FoPost.Error.
@spec create_audience( FoPost.Client.t(), keyword() ) :: {:ok, FoPost.CreatedAudience.t()} | {:error, FoPost.Error.t()}
Creates an audience. Required: :workspace_id, :connection_id, :ad_account_id,
:name, :spec. Optional: :description.
:spec is sent as given and carries a subtype of CUSTOM (with emails),
LOOKALIKE (with originAudienceId, country, ratio), or WEBSITE (with
pixelId, retentionDays, urlContains).
Same as create_audience/2, but raises FoPost.Error.
@spec create_lead_form( FoPost.Client.t(), keyword() ) :: {:ok, String.t()} | {:error, FoPost.Error.t()}
Creates an Instant Form on a Page; answers its id.
Required: :workspace_id, :connection_id, :page_id, :name, :questions,
:privacy_policy_url, :thank_you_message. Optional: :follow_up_url.
Same as create_lead_form/2, but raises FoPost.Error.
@spec delete(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.Message.t()} | {:error, FoPost.Error.t()}
Ends delivery and deletes the ad on Meta as well as here. Needs the publish scope as
well as ads. Required: :workspace_id.
Same as delete/3, but raises FoPost.Error.
@spec delete_connection(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.Message.t()} | {:error, FoPost.Error.t()}
Disconnects an ads login. Every ad record created through it is deleted too.
Required: :workspace_id.
Same as delete_connection/3, but raises FoPost.Error.
@spec external( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.ExternalAd.t()]} | {:error, FoPost.Error.t()}
Ads on the connected ad accounts that were made elsewhere. Read live, never stored.
Same as external/2, but raises FoPost.Error.
@spec lead_forms( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.LeadFormSource.t()]} | {:error, FoPost.Error.t()}
Each connection and Page with the lead forms on it.
Same as lead_forms/2, but raises FoPost.Error.
@spec leads(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.LeadsPage.t()} | {:error, FoPost.Error.t()}
One page of a form's leads. Required: :connection_id, :page_id. Optional: :after
(the previous page's next_cursor), :workspace_id.
Same as leads/3, but raises FoPost.Error.
@spec list( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.Ad.t()]} | {:error, FoPost.Error.t()}
Boosts and ads created through FoPost, with insights from their last refresh.
Optionally narrowed with :workspace_id.
Same as list/2, but raises FoPost.Error.
@spec refresh(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.Ad.t()} | {:error, FoPost.Error.t()}
Reads the delivery status and lifetime insights from Meta. Required: :workspace_id.
Same as refresh/3, but raises FoPost.Error.
@spec search_targeting( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.TargetingOption.t()]} | {:error, FoPost.Error.t()}
Locations, interests, behaviours, and income brackets as Meta names them.
Required: :connection_id, :type (country, region, city, zip, metro,
interest, behavior, income). Optional: :q, :workspace_id.
Same as search_targeting/2, but raises FoPost.Error.
@spec set_status(FoPost.Client.t(), String.t(), keyword()) :: {:ok, FoPost.Ad.t()} | {:error, FoPost.Error.t()}
Pauses or resumes an ad. Needs the publish scope as well as ads.
Required: :workspace_id, :status (active, paused).
Same as set_status/3, but raises FoPost.Error.
@spec sources( FoPost.Client.t(), keyword() ) :: {:ok, [FoPost.AdSource.t()]} | {:error, FoPost.Error.t()}
Each connection with the ad accounts and Pages its grant reaches.
Same as sources/2, but raises FoPost.Error.