Guides
Campaigns

Create a campaign

The campaign → ad set → creative → ad sequence, with budget, optimization goal, destination and the validation errors of each step.

A campaign in the Marketing API is four objects created in order in the ad account:

  1. The campaign sets the objective (OUTCOME_*) and, optionally, the budget.
  2. The ad set sets the budget, schedule, optimization goal, billing event, destination and audience.
  3. The creative is the Page post the ad shows.
  4. The ad links an ad set to a creative and goes through review.

Writes accept form data (-F), urlencoded or JSON; objects and lists can go as JSON strings. The response to a create is {"id":"…"}. Every write requires ads_management and a role on the account.

1. Campaign

bash
curl -s "https://meta-ads.mimicr.dev/v27.0/act_100539998049706/campaigns" \
  -H 'Authorization: Bearer <token>' \
  -F name='Gás em casa' -F objective=OUTCOME_ENGAGEMENT -F status=PAUSED \
  -F special_ad_categories='[]' -F is_adset_budget_sharing_enabled=false
json
{ "id": "120200539998049712" }
  • objective is one of OUTCOME_APP_PROMOTION, OUTCOME_AWARENESS, OUTCOME_ENGAGEMENT, OUTCOME_LEADS, OUTCOME_SALES and OUTCOME_TRAFFIC. Legacy objectives (MESSAGES, LINK_CLICKS, CONVERSIONS) answer 100.
  • special_ad_categories is required; [] when there's no special category.
  • Without a campaign budget, is_adset_budget_sharing_enabled has been required since v24.0. Without it: 100/4834011 "Must specify True or False in is_adset_budget_sharing_enabled field if you are not using campaign budget".
  • With a campaign budget (daily_budget or lifetime_budget), ad sets can't have their own budget (1885621).

2. Ad set

bash
curl -s "https://meta-ads.mimicr.dev/v27.0/act_100539998049706/adsets" \
  -H 'Authorization: Bearer <token>' \
  -F name='Gás em casa' -F campaign_id=120200539998049712 -F status=PAUSED \
  -F billing_event=IMPRESSIONS -F optimization_goal=CONVERSATIONS \
  -F bid_strategy=LOWEST_COST_WITHOUT_CAP -F daily_budget=2000 \
  -F destination_type=WHATSAPP \
  -F promoted_object='{"page_id":"100539998049709","whatsapp_phone_number":"551336985333"}' \
  -F start_time=2026-11-07T08:00:00-0300 -F end_time=2026-11-17T08:00:00-0300 \
  -F targeting='{"geo_locations":{"custom_locations":[{"latitude":-23.55,"longitude":-46.63,"radius":5,"distance_unit":"kilometer"}]},"age_min":18,"targeting_automation":{"advantage_audience":0}}'
ParameterRule
daily_budget / lifetime_budgetCents; exactly one, unless the campaign has a budget. Lifetime requires end_time (1487171). Daily only for ad sets longer than 24 h (1487172)
optimization_goalMust match the objective (table below), otherwise 2490408
billing_eventIMPRESSIONS for click-to-WhatsApp
bid_amountRequired with LOWEST_COST_WITH_BID_CAP and COST_CAP
destination_typeWHATSAPP requires promoted_object.page_id of a Page with WhatsApp (2446880)
promoted_object{page_id, whatsapp_phone_number} for WhatsApp, {page_id} for leads, {pixel_id, custom_event_type} for conversions
targetingSee Targeting; geo_locations is required
pacing_type + adset_scheduleHour schedule, only with a lifetime budget (1487201)
start_timeDefault: now

Goals accepted per objective in Mimicr (without optimization_goal, Mimicr uses the objective's default goal: REACH, LINK_CLICKS, POST_ENGAGEMENT, LEAD_GENERATION, OFFSITE_CONVERSIONS or APP_INSTALLS):

Objectiveoptimization_goal
OUTCOME_ENGAGEMENTCONVERSATIONS, LINK_CLICKS, POST_ENGAGEMENT, THRUPLAY, IMPRESSIONS, REACH, PAGE_LIKES
OUTCOME_TRAFFICCONVERSATIONS, LANDING_PAGE_VIEWS, LINK_CLICKS, IMPRESSIONS, REACH, POST_ENGAGEMENT
OUTCOME_SALESCONVERSATIONS, OFFSITE_CONVERSIONS, LINK_CLICKS, IMPRESSIONS, REACH, VALUE, LANDING_PAGE_VIEWS
OUTCOME_LEADSLEAD_GENERATION, QUALITY_LEAD, CONVERSATIONS, LINK_CLICKS, OFFSITE_CONVERSIONS
OUTCOME_AWARENESSREACH, IMPRESSIONS, AD_RECALL_LIFT, THRUPLAY
OUTCOME_APP_PROMOTIONAPP_INSTALLS, APP_INSTALLS_AND_OFFSITE_CONVERSIONS, LINK_CLICKS, VALUE

The minimum daily budget depends on the goal. In Mimicr: R$1.00 for impressions and reach, R$2.50 for clicks and R$5.00 for conversations and leads. Below that, 100/1885272 with the message in Portuguese for pt_BR users:

json
{
  "error": {
    "message": "(#100) Invalid parameter",
    "type": "OAuthException",
    "code": 100,
    "error_subcode": 1885272,
    "is_transient": false,
    "error_user_title": "Your Budget Is Too Low",
    "error_user_msg": "O orçamento diário mínimo deste conjunto é R$ 5,00.",
    "error_data": { "blame_field_specs": [["daily_budget"]] },
    "fbtrace_id": "uu_3OO2gIWY"
  }
}

3. Creative

For video, upload the file first and wait for it to be ready:

bash
curl -s "https://meta-ads.mimicr.dev/v27.0/act_100539998049706/advideos" \
  -H 'Authorization: Bearer <token>' -F file_url=https://cdn.example.com/gas.mp4 -F name='Vídeo gás'
# {"id":"100539998049715"}
curl -s "https://meta-ads.mimicr.dev/v27.0/100539998049715?fields=status,picture" -H 'Authorization: Bearer <token>'

status.video_status goes from processing to ready in 6 sandbox seconds. Creating a creative with a video that isn't ready yet answers 100/1885252.

Image creative with click-to-WhatsApp:

bash
curl -s "https://meta-ads.mimicr.dev/v27.0/act_100539998049706/adcreatives" \
  -H 'Authorization: Bearer <token>' \
  -F name=Botijão \
  -F object_story_spec='{"page_id":"100539998049709","link_data":{"message":"Botijão em 30 min","name":"Peça pelo WhatsApp","picture":"https://cdn.example.com/botijao.jpg","link":"https://api.whatsapp.com/send","call_to_action":{"type":"WHATSAPP_MESSAGE","value":{"app_destination":"WHATSAPP"}}}}'

For a website, use link with the URL and call_to_action {"type":"ORDER_NOW","value":{"link":"https://loja.example.com"}}. For leads, see Lead ads and webhook. An unknown call_to_action.type answers 100/1373054. Creatives don't change after they're created, except name and status.

4. Ad

bash
curl -s "https://meta-ads.mimicr.dev/v27.0/act_100539998049706/ads" \
  -H 'Authorization: Bearer <token>' \
  -F name=Botijão -F adset_id=120200539998049713 \
  -F creative='{"creative_id":"120200539998049717"}' -F status=PAUSED

The ad goes into review even when paused. See Ads and review. To go live, activate the ad, the ad set and the campaign (POST /{id} with status=ACTIVE).

Validate without creating

execution_options=["validate_only"] on campaigns, ad sets, creatives and ads runs every validation and answers {"success":true} without saving anything.

If something fails midway

Creates aren't idempotent in the Graph API: repeating a POST creates another object. If the ad set fails after the campaign was created, remove the campaign (POST /{campaign_id} with status=DELETED) and start over. A 500 with is_transient: true on a POST may or may not have created the object; list before retrying.

Reference: Create campaign, Create ad set, Create creative, Upload video and Create ad.