Documentation menu
Ads

Create campaign

A paused Meta campaign with any objective, targeting and a new or boosted creative, or a paused TikTok or LinkedIn campaign.

POSThttps://app.tryadeli.com/api/v1/ads/campaigns
AuthorizationBearer <API key>How keys work

On Meta, a body with objective builds a full campaign: any of seven objectives, a daily or lifetime budget, a schedule, a bid strategy, targeting, and a new image, video or carousel ad, or a boosted Page or Instagram post (see Meta full campaign body). A body without objective promotes a post the Meta Ads account's Page already published, creating a campaign, ad set, creative and ad. That is the Page chosen when Meta Ads was connected, which may differ from the profile's Facebook account's Page; pass a post from that Page. On TikTok, creates a campaign, ad group and video ad (see TikTok body below). On LinkedIn, sponsors a Page post as a draft campaign group, campaign and creative (see LinkedIn body). Everything is created paused. Nothing delivers and nothing spends until you activate it, which is a separate call.

An Idempotency-Key header is required. This is the only endpoint in the API where a retry has a cost, so the same key replays the original result rather than creating a second campaign: 200 with the same object ids when the campaign was built, 409 campaign_create_failed with the original reason when it failed, and 409 campaign_create_in_progress while it is still being created. To retry a failed create, send a new key.

On Meta, an ad account takes at most 30 new campaigns in five minutes and 100 in a day. Past that, the response is 429 ads_change_limited with Retry-After, and the Idempotency-Key has not been used, so retry with the same key. See the limits on changes.

Body

adAccountIdstringRequired
The ad account to create in.
pagePostIdstringRequired
The post id alone; the Page half of Meta's story id is server-derived.
dailyBudgetnumberRequired
Whole units of the ad account's currency: 25 means 25.00. Meta's API takes budgets in the currency's minor units (2500 cents for USD), and Adeli converts before sending.
startDatedateRequired
YYYY-MM-DD.
endDatedateRequired
YYYY-MM-DD, on or after startDate.
campaignNamestringRequired
Shown in Ads Manager.

Responds 201 with the created object ids, Adeli's campaign record (its id is the campaignRecordId used by Activate, pause or resume; metaAdsConnectionId names the Meta Ads account, and facebookConnectionId is set only on campaigns created before Meta Ads was a separate account), and a preview when Meta returns one: Meta's body markup, plus the url, width and height of the facebook.com preview page it wraps. Embed url in an iframe that allows scripts; the page renders blank without them. If a step fails, Adeli deletes what it already created and responds 502 campaign_create_failed with the failing step and any orphanedObjectIds it could not remove — those are paused, so they cost nothing, but they are named so you can find them in Ads Manager.

Meta full campaign body

For a meta_ads account, a body with objective creates a campaign, an ad set and an ad, all paused, published as the Meta Ads account's Page. Name an existing campaignId to add a new ad set and ad to it, or an adSetId to add only an ad; Adeli checks either belongs to adAccountId and has the same objective, and never deletes it if a later step fails.

Body (Meta full campaign)

adAccountIdstringRequired
The ad account to create in.
objectivestringRequired
traffic, engagement, awareness, video_views, lead_generation, conversions or app_promotion. Each maps to Meta's outcome objective and optimization goal; video_views is an engagement campaign optimized for ThruPlay.
campaignNamestringRequired
Shown in Ads Manager; the ad set and creative are named after it.
adNamestring
Defaults to the campaign name.
campaignIdstring
Add to this existing campaign instead of creating one.
adSetIdstring
Add only the ad, to this existing ad set. Leave out budget, targeting, bid and dates.
budgetobject
{ type: daily | lifetime, amount } in whole currency units, converted with the currency's own offset (so 3000 is 3,000 yen). Required unless the ad set's campaign holds the budget. A daily budget is at most 10,000; a lifetime budget needs endDate.
budgetLevelstring
ad_set (default), or campaign for Advantage campaign budget (CBO).
startDatedate
YYYY-MM-DD, tomorrow (UTC) or later. Required unless adSetId.
endDatedate
YYYY-MM-DD. The ad set runs through the end of that day (UTC). Optional for a daily budget.
bidobject
{ strategy: lowest_cost | bid_cap | cost_cap | min_roas, amount, roasFloor }. bid_cap and cost_cap need amount (whole currency units); min_roas needs roasFloor (2 means 200%) and works only with conversions and app_promotion. Lowest cost when omitted.
targetingobject
Required unless adSetId; see the table below.
creativeobjectRequired
One of the creative shapes below, by type.
instagramAccountIdstring
Show the ad as this Instagram account, from [Instagram accounts](/docs/api/ads/list-instagram-accounts). Required to boost an Instagram post.
pixelIdstring
conversions: the Meta pixel.
conversionEventstring
conversions: PURCHASE, LEAD, COMPLETE_REGISTRATION, ADD_TO_CART, INITIATED_CHECKOUT, ...
leadFormIdstring
lead_generation: a form from [Lead forms](/docs/api/ads/list-leads).
applicationIdstring
app_promotion: the app's Meta app id.
appStoreUrlstring
app_promotion: the App Store or Google Play URL.
specialAdCategoriesstring[]
HOUSING, EMPLOYMENT, CREDIT or FINANCIAL_PRODUCTS_SERVICES, with specialAdCategoryCountries. Political ads are not supported.
validateOnlyboolean
true asks Meta to check the campaign and create nothing; see Dry run.

targeting

locationsobjectRequired
{ countries, regions, cities, zips }. Countries are ISO codes; the others are { key } objects from [Targeting options](/docs/api/ads/list-targeting) (type locations), and a city may add radius and distanceUnit (mile or kilometer). At least one.
excludedLocationsobject
The same shape, excluded.
ageMin, ageMaxnumber
13 to 65.
genderstring
all (default), male or female.
interests, behaviorsobject[]
{ id, name } from Targeting options.
demographicsobject[]
{ id, type } from Targeting options (type demographics); type is the option's own, such as life_events.
languagesnumber[]
Locale ids from Targeting options (type languages).
customAudiences, excludedCustomAudiencesstring[]
Custom or lookalike audience ids in the ad account.
placementsstring | object
automatic (default), or { publisherPlatforms, facebookPositions, instagramPositions, audienceNetworkPositions, messengerPositions, devicePlatforms }.
advantageAudienceboolean
Let Meta reach beyond this audience. false unless you ask for it.

creative

{ type: page_post, pagePostId }object
Boost a post by the Meta Ads account's Page.
{ type: instagram_post, instagramMediaId }object
Boost an Instagram post; needs instagramAccountId.
{ type: image, image, ... }object
image is { uploadId } (media uploads, platform facebook) or { url } over HTTPS. With headline, body, description, callToAction and linkUrl. An image with no link runs as a photo post.
{ type: video, video, thumbnail, ... }object
video is { uploadId }, { url } or { videoId } of a video already in the ad account. Adeli uploads it and waits up to 90 seconds for Meta to process it; if Meta is still processing, the response is 409 video_processing with the videoId to retry with. The thumbnail defaults to Meta's own.
{ type: carousel, body, linkUrl, callToAction, cards }object
2 to 10 cards, each { image, headline, description, linkUrl, callToAction }.

callToAction is one of LEARN_MORE, SHOP_NOW, SIGN_UP, BOOK_NOW, CONTACT_US, DOWNLOAD, GET_OFFER, GET_QUOTE, SUBSCRIBE, WATCH_MORE, APPLY_NOW, ORDER_NOW, BUY_NOW, INSTALL_MOBILE_APP, USE_APP, DONATE_NOW, GET_DIRECTIONS, SEE_MENU, PLAY_GAME, LISTEN_NOW or NO_BUTTON, and needs a linkUrl except on lead and app ads, whose button opens the form or the store. traffic and conversions need a linkUrl on new creatives.

The 201 response adds platform, accountId, profileId, videoId (the uploaded video, or null) and reused (whether the campaign and ad set already existed) to the boost's response. The campaign record's source says what the ad was built from and objective which objective it has.

Dry run

With validateOnly: true Meta checks the request with its validate_only option and nothing is created or recorded, so the call can be repeated. The response is 200 with each step's result. Meta checks an ad set only inside a campaign that exists, and an ad only with a real ad set and creative, so those steps report skipped with the reason; a video given by URL is not uploaded in a dry run, so its creative is skipped too.

json
{
  "platform": "meta_ads",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "profileId": "00000000-0000-4000-8000-000000000002",
  "validateOnly": true,
  "steps": [
    { "step": "campaign", "result": "valid" },
    { "step": "ad set", "result": "skipped", "reason": "Meta validates an ad set only inside an existing campaign" },
    { "step": "creative", "result": "valid" },
    { "step": "ad", "result": "skipped", "reason": "Meta validates an ad only with a real ad set and creative" }
  ]
}

Instagram

instagramAccountId must be one of the ad account's connected Instagram accounts, read with the Meta Ads connection's own Ads permissions. If Meta refuses the Instagram account or post for want of a permission, the response is 403 permission_required naming instagram_basic, which the Meta Ads connection does not request today.

TikTok body

For a tiktok_ads account the body describes a video ad. Adeli uploads the video and cover, creates the identity when you pass one inline, then creates the campaign (no campaign budget), the ad group (the daily budget, schedule and targeting) and the ad, all disabled. startDate must be after today in the ad account's timezone, which is how TikTok reads the schedule.

Body (TikTok)

adAccountIdstringRequired
A TikTok advertiser id.
campaignNamestringRequired
Used for the campaign, ad group and ad.
goalstringRequired
traffic, reach or video_views.
dailyBudgetnumberRequired
Whole currency units per day on the ad group. At least 20 USD.
startDatedateRequired
YYYY-MM-DD, after today in the ad account's timezone.
endDatedateRequired
YYYY-MM-DD, on or after startDate.
targeting.locationIdsstring[]Required
Location ids from [Targeting options](/docs/api/ads/list-targeting).
targeting.ageGroupsstring[]
AGE_18_24, AGE_25_34, ... Omit for all ages.
targeting.genderstring
GENDER_MALE, GENDER_FEMALE or GENDER_UNLIMITED.
targeting.languagesstring[]
Language codes from Targeting options.
targeting.interestCategoryIdsstring[]
Interest ids from Targeting options.
creative.videoobjectRequired
{ uploadId } from media uploads (platform tiktok), or { url } over HTTPS. 9:16, 5 to 60 seconds.
creative.coverImageobject
{ uploadId } or { url }. Defaults to TikTok's own frame from the video.
creative.adTextstringRequired
The caption, up to 100 characters.
creative.callToActionstring
LEARN_MORE, SHOP_NOW, SIGN_UP, ...
creative.landingPageUrlstring
Required for traffic.
identityobjectRequired
{ identityId } from [ad identities](/docs/api/ads/list-identities), or { displayName, avatar } to create one.

The 201 response carries objects (campaignId, adGroupId, adId) and the campaign record; its id is the campaignRecordId that lets Update ad status activate the whole campaign from its ad.

LinkedIn body

For a linkedin_ads account the body sponsors an existing post by the ad account's own LinkedIn Page. Adeli checks the post's author and format, then creates a campaign group, a campaign (the daily budget, bid, schedule and targeting) and a creative that references the post, all as drafts. A draft does not deliver and LinkedIn does not review it until it is activated. The schedule is in UTC, and startDate must be tomorrow (UTC) or later.

Body (LinkedIn)

adAccountIdstringRequired
A LinkedIn ad account id (digits). Your role on it must be above Viewer.
campaignNamestringRequired
Used for the campaign group, campaign and ad.
goalstringRequired
website_visits, engagement, brand_awareness or video_views (video posts only).
postUrnstringRequired
urn:li:share:<id> or urn:li:ugcPost:<id>, by the ad account's Page. Text, image, article and video posts are supported.
dailyBudgetnumberRequired
Whole currency units per day on the campaign. At least 10 USD.
bidnumber
Per click, thousand impressions or view, by goal. Defaults to LinkedIn's suggested bid; 400 bid_required when LinkedIn suggests none.
startDatedateRequired
YYYY-MM-DD, tomorrow (UTC) or later.
endDatedateRequired
YYYY-MM-DD, on or after startDate.
targeting.locationsstring[]Required
Geo URNs from [Targeting options](/docs/api/ads/list-targeting) (type locations).
targeting.jobFunctionsstring[]
urn:li:function:<id> URNs.
targeting.senioritiesstring[]
urn:li:seniority:<id> URNs.
targeting.industriesstring[]
urn:li:industry:<id> URNs.
targeting.companySizesstring[]
urn:li:staffCountRange:(<from>,<to>) URNs.
targeting.interfaceLocalestring
The audience's LinkedIn language, such as en_US (the default).
politicalIntentstringRequired
NOT_POLITICAL. LinkedIn requires the declaration on every campaign; Adeli does not run political ads.

The 201 response carries objects, where campaignId is the campaign group, adGroupId the LinkedIn campaign and adId the creative, and the campaign record. Activating the campaign group through Update ad status activates its campaign and ad with it. A post from another Page answers 400 post_not_in_account_organization and an unsupported post 400 unsupported_post_format, before anything is created.