跳转到主要内容
POST
Create messaging ad

请求规范

  • 方法与路径: POST /apis/v1/ads/messaging
  • 可用状态: enabled
  • 请求 URL 模板: https://api.aisa.one/apis/v1/ads/messaging
  • connectionId: query; 必填
  • X-Aisa-Confirm: header; 可选
  • Idempotency-Key: header; 可选
  • Runtime 事实版本: fe60122939c67dc98a3a6ac6b97bd5c326b526105150c8959304dd2160d4dd09
完整 OpenAPI 定义 有效请求与价格声明(包括认证和引用的 schema):

费用与请求规则

当前未提供请求参考价格;请使用接口支持的报价功能确认费用。 最终费用以账户适用价格及实际结算为准。 公开参考值不是你的账户报价或最终扣费。对于支持 X-AISA-Cost-Mode: quote 的接口,执行前请针对完整请求获取免费报价;执行后通过响应费用元数据和 Usage Logs 核对结算费用。1 USD 等于 1,000,000 个整数 micro-USD。

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求头

X-Aisa-Confirm
enum<string>

Required with the value "spend" when the request can spend money or change spend. Without it the request is refused with 409 confirmation_required, which describes what would happen; nothing is sent to the ad platform.

可用选项:
spend
Idempotency-Key
string

Passed to the ad platform integration: a retry with the same key returns the first result instead of acting twice. AIsa never retries a write for you.

Required string length: 1 - 191

查询参数

connectionId
string
必填

The ads connection (adc_...) the request runs on: one of yours, from GET /apis/v1/ads/connections. On a request with a JSON body it may be sent as a top-level body member instead.

Pattern: ^adc_[0-9A-Za-z]+$

请求体

application/json

Besides the required list, the request must use EXACTLY ONE of these shapes: Single-creative: headline, body, and one of imageUrl / video, OR platformPostId / objectStoryId to reuse an organic post.

adAccountId
string
必填

Meta ad account ID, e.g. act_123456789.

Minimum string length: 1
name
string
必填

Ad display name. Used to derive campaign / ad set names. On the multi-creative shape, each ad's Meta name gets a " #N" suffix (1-indexed) so Ads Manager shows them as a numbered batch.

Minimum string length: 1
adSetId
string

Attaches the creatives to this EXISTING messaging ad set instead of building a campaign, so the ad set keeps its learning phase. Its destination_type must match the ad's destination. Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.

adSetName
string

Exact name for the ad set this request provisions. Omitted keeps - Ad Set. Ignored with adSetId.

Maximum string length: 255
adSetStatus
enum<string>

Ad-set-level status, same semantics as POST /apis/v1/ads/create. Sets the new ad set's switch alone and overrides status for it.

可用选项:
ACTIVE,
PAUSED
adStatus
enum<string>

Request-side publish switch for adStatus on ad creation endpoints only (status, campaignStatus and adSetStatus carry their own inline ACTIVE/PAUSED enum there; the status-update endpoints are a separate lowercase active/paused…

可用选项:
ACTIVE,
PAUSED
advantageAudience
enum<integer>

Meta's Advantage+ audience expansion. 0 (default) keeps targeting strict; 1 lets Meta expand beyond the supplied targeting when its delivery system finds better matches. Always sent on CREATE (Meta requires it).

可用选项:
0,
1
ageMax
integer
必填范围: 13 <= x <= 65
ageMin
integer
必填范围: 13 <= x <= 65
audienceExclude
string[]

Custom or lookalike audience ids to exclude. Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.

Minimum array length: 1
audienceId
string

Custom audience ID to target. Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.

audienceInclude
string[]

Custom or lookalike audience ids to include. Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.

Minimum array length: 1
behaviors
object[]

Behavior ids from /apis/v1/ads/targeting/search?dimension=behavior. Meta: each dimension is its own flexible_spec entry (OR within, AND across). TikTok: video/creator interaction categories, sent as the ad group's actions.

bidAmount
number

Whole currency units (e.g. 5 = $5.00 on a USD account). Required when bidStrategy is LOWEST_COST_WITH_BID_CAP or COST_CAP; rejected otherwise.

bidStrategy
enum<string>

Meta bid strategy applied to the shared ad set. Defaults to LOWEST_COST_WITHOUT_CAP (auto-bid) when omitted. LOWEST_COST_WITH_BID_CAP and COST_CAP require bidAmount. LOWEST_COST_WITH_MIN_ROAS requires roasAverageFloor.

可用选项:
LOWEST_COST_WITHOUT_CAP,
LOWEST_COST_WITH_BID_CAP,
COST_CAP,
LOWEST_COST_WITH_MIN_ROAS
body
string

Primary text shown above the image / video. Single-creative shape only. Mutually exclusive with creatives[].

Minimum string length: 1
budgetAmount
number

Budget amount in the ad account's currency major units (e.g. dollars for USD, not cents). Must be > 0. Required unless adSetId is set (the ad set owns it) or existingCampaignId names a campaign with a campaign budget.

budgetLevel
enum<string>

Where the budget lives. adset (default) puts it on the new ad set. campaign creates an Advantage campaign budget (CBO): the budget and bid strategy sit on the campaign and the ad set inherits them, same as POST /apis/v1/ads/create.

可用选项:
adset,
campaign
budgetType
enum<string>

Required unless adSetId is set or existingCampaignId names a campaign with a campaign budget. lifetime requires endDate.

可用选项:
daily,
lifetime
campaignName
string

Exact name for the campaign this request provisions. Omitted keeps - Campaign. Ignored with adSetId (the ad set already has a campaign).

Maximum string length: 255
campaignStatus
enum<string>

Campaign-level status, same semantics as POST /apis/v1/ads/create. Defaults to status. PAUSED: holds the new campaign off while the ad set and ads switch on (one resume call brings the whole hierarchy live).

可用选项:
ACTIVE,
PAUSED

Messaging and CTWA only (a 400 on POST /apis/v1/ads/call). A hand-built carousel of 2-10 image cards, sent to Meta in the given order as link_data.child_attachments.

Required array length: 2 - 10 elements
cities
object[]

City-level geo targeting for local CTWA campaigns. Each entry maps to Meta's TargetingGeoLocationCity; key is Meta's city ID. radius and distance_unit are coupled: set both or neither.

connectionId
string

The ads connection (adc_...), when not sent as the connectionId query parameter.

Pattern: ^adc_[0-9A-Za-z]+$
countries
string[]

ISO 3166-1 alpha-2 country codes. Defaults to ["US"] only when no other geo (cities, regions, zips, metros, customLocations) is supplied.

Required string length: 2
countryGroups
enum<string>[]

Meta only. Continents and trade blocs (geo_locations.country_groups), for targeting a whole region without listing its countries. Combines with countries rather than replacing it, and is also accepted under excludedLocations.

可用选项:
africa,
asia,
europe,
north_america,
south_america,
oceania,
central_america,
caribbean,
eea,
euro_area,
nafta,
mercosur,
afta,
apec,
gcc,
cisfta,
emerging_markets,
itunes_app_store,
android_free_store,
android_paid_store
creativeFeatures
object

Meta Advantage+ creative enhancements. Map snake_case feature names to OPT_IN or OPT_OUT; Meta validates supported keys and unspecified features default to OPT_OUT.

creatives
object[]

Multi-creative shape: N CTWA ads under one campaign + one ad set, sharing budget and targeting. Fresh and existing creatives can be mixed. Each entry supplies headline, body, and image/video, or a platformPostId or objectStoryId reference.

Minimum array length: 1
currency
string

ISO 4217 currency code matching the ad account's currency (e.g. USD).

Required string length: 3
customLocations
object[]

Point-radius geo (Meta geo_locations.custom_locations). Use for targeting a radius around a specific lat/long when no Meta city/region key fits. distanceUnit is required.

description
string

Link description, independent of headline and body: Meta's link_data.description, video_data.link_description on video, and the shared description of a placementAssets feed.

Required string length: 1 - 255
destination
enum<string>

Where the conversation opens when the ad is tapped. Set this OR destinations, not both.

可用选项:
whatsapp,
messenger,
instagram_direct
destinations
enum<string>[]

Two or three messaging apps on ONE ad set, like Ads Manager's "all messaging apps". Set this OR destination, not both. The ad set gets Meta's combined destination_type (e.g.

Required array length: 2 - 3 elements
可用选项:
whatsapp,
messenger,
instagram_direct
dsaBeneficiary
string

Legal entity that benefits from the ad. Required when targeting EU users (EU DSA, Article 26).

Maximum string length: 100
dsaPayor
string

Legal entity that pays for the ad. Can differ from dsaBeneficiary (for example, an agency paying for a client's ads). Same rules as dsaBeneficiary: required for EU targeting unless the ad account has a default payor.

Maximum string length: 100
endDate
string

ISO 8601 date or date-time, read like startDate; a date-only value ends at 23:59:59 local. Required when budgetType is lifetime.

excludedLocations
object

Geo to exclude, same shape as POST /apis/v1/ads/create (countries, countryGroups, regions, cities, zips, places, neighborhoods, customLocations).

existingCampaignId
string

Creates the new messaging ad set (and its ads) under this EXISTING Meta campaign instead of a new one, e.g. several audience ad sets under one campaign. To add ads to an existing ad set instead, use adSetId. Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.

Pattern: ^\d+$
existingPostId
string

Alias of platformPostId, kept for existing callers. Sending both with different values is a 400.

Minimum string length: 1
gender
enum<string>

Restrict the audience by gender (Meta genders). Omit or send all for everyone; all is ignored in adSetId attach mode. Stored on the ad and read back in targeting.gender.

可用选项:
all,
male,
female
headline
string

Single-creative shape only. Mutually exclusive with creatives[]. Required on a single image or video ad (including one built with placementAssets); not used by a carouselCards ad and not accepted with an existing post reference.

Required string length: 1 - 255
imageUrl
string<uri>

Image asset for single-creative shape. Mutually exclusive with video and with creatives[]. Required on the single-creative shape if neither video nor an existing post reference is supplied.

incomeTier
enum<string>

Normalized household-income tier, same as POST /apis/v1/ads/create. Incompatible with housing, employment and credit specialAdCategories.

可用选项:
top_5,
top_10,
top_10_25,
top_25_50
interests
object[]
languages
string[]

Audience languages (Meta locales). A bare ISO 639-1 code targets all regional variants ("en" = all English), a region-qualified code a specific one ("en_GB", "pt_BR"); unknown codes are rejected.

metros
object[]

DMA / metro-area geo targeting. key is Meta's metro id (e.g. DMA:807).

neighborhoods
object[]

Meta neighborhood keys (from GET /apis/v1/ads/targeting/search).

objectStoryId
string

Messaging and CTWA only. Raw Facebook pageId_postId reference, used as object_story_id even with an Instagram account. Mutually exclusive with platformPostId and fresh creative fields.

Pattern: ^\d+_\d+$
objective
enum<string>

Defaults to OUTCOME_ENGAGEMENT. OUTCOME_SALES and OUTCOME_LEADS require additional account configuration (Dataset linked to the WABA for sales) and may be rejected by Meta if missing.

可用选项:
OUTCOME_ENGAGEMENT,
OUTCOME_SALES,
OUTCOME_LEADS
optimizeCardOrder
boolean

Only with carouselCards (a 400 without them). Single-creative shape; for creatives[] set it per entry. Sets the creative's link_data.multi_share_optimized. false: keeps the cards in the order given.

pageId
string

Facebook Page the ad runs as, when the connection was granted several Pages. Defaults to the Page bound to the connection. Any Page granted to the connection is accepted; other ids answer 400 listing the granted Pages.

placementAssets
object

A different image or video per placement on one messaging ad, e.g. a 4:5 image on Feed and a 9:16 image on Stories/Reels. Works on the single-creative shape and on attach (adSetId).

placements
object

Manual ad placements on the shared ad set. Omit for automatic placements.

places
object[]

Meta place keys (from GET /apis/v1/ads/targeting/search).

platformPostId
string

Messaging and CTWA only. Platform post or reel ID, the same input boostPost takes as platformPostId. Mutually exclusive with objectStoryId and fresh creative fields. Facebook IDs become object_story_id.

Minimum string length: 1
rawTargeting
object

Meta targeting spec sent as the BASE layer of the ad set's targeting, exactly as POST /apis/v1/ads/create does.

regionalRegulatedCategories
string[]

Meta only. Regional regulation categories required when the ad set targets certain countries (e.g.

regionalRegulationIdentities
object

Meta only. Verified identity IDs of the beneficiary and payer for each declared regionalRegulatedCategories value. Ignored when adSetId adds the ad to an existing ad set.

regions
object[]

Region / state-level geo targeting. key is Meta's region ID (lookupable via GET /apis/v1/ads/targeting/search?type=region).

roasAverageFloor
number

Decimal ROAS multiplier (e.g. 2.0 = 2.0× ROAS floor). Required when bidStrategy is LOWEST_COST_WITH_MIN_ROAS; rejected otherwise. Meta enforces its own upper bound server-side.

savedTargetingId
string

ID of a saved_targeting audience (POST /apis/v1/ads/audiences), expanded as the base targeting. Precedence: savedTargetingId, then targeting, then the flat fields. Must be yours: it is checked through the connection before the request is sent, and an id that is not yours answers not_found.

specialAdCategories
enum<string>[]

Meta special ad categories on the new campaign.

可用选项:
HOUSING,
EMPLOYMENT,
CREDIT,
ISSUES_ELECTIONS_POLITICS,
FINANCIAL_PRODUCTS_SERVICES,
ONLINE_GAMBLING_AND_GAMING
specialAdCategoryCountry
string[]

Countries the special ad category applies to. Requires specialAdCategories.

startDate
string

When the ad set starts delivering. ISO 8601 date or date-time.

status
enum<string>

Defaults to ACTIVE. PAUSED pauses only the top-most object this call creates: the new campaign (ad set and ads switched on), or, with adSetId, the new ads themselves.

可用选项:
ACTIVE,
PAUSED
targeting
object

Normalized, platform-agnostic ad-targeting spec. Every field is optional; an empty object targets the platform's default broadest audience.

tracking
object

Ad tracking. Meta, plus urlTags on ChatGPT (OpenAI) and pixelId on Reddit. Meta: attaches pixel measurement to the ad regardless of the optimization goal (the "Website events" tracking row in Ads Manager).

userDevice
string[]

Meta user_device.

Minimum array length: 1
userOs
string[]

Meta user_os, e.g. ["iOS_ver_14.0_and_above"].

Minimum array length: 1
validateOnly
boolean

Dry-runs the ad on Meta with execution_options validate_only, as ONE inline campaign + ad set + creative + ad (or creative + ad on the existing ad set with adSetId). Nothing is uploaded, created or stored; media is checked by URL.

video
object

Video creative for single-creative shape. Mutually exclusive with imageUrl and with creatives[]. Required on the single-creative shape if neither imageUrl nor an existing post reference is supplied.

welcomeMessage
object

Custom chat welcome message (Meta's page_welcome_message, "Mensaje de bienvenida" / "Mensaje predefinido" in Ads Manager). Single-creative shape only; for creatives[] set it per entry.

whatsappPhoneNumber
string

WhatsApp only. Optional E.164 number already paired with the Facebook Page. Omit to let Meta select the paired number. Sent to the creative CTA and, when creating a new ad set, its promoted_object.

Pattern: ^\+[1-9]\d{6,14}$
workEmployers
object[]
workIndustries
object[]
workPositions
object[]
workflowId
string

A workflow in the ad account's profile, stored on the ad. 404 when no such workflow exists in the profile.

Pattern: ^[a-fA-F0-9]{24}$
zips
object[]

ZIP / postal-code geo targeting. key is the platform's postal id resolved via /apis/v1/ads/targeting/search.

响应

validateOnly: true only. Meta accepted every node; nothing was created.

message
string
必填
results
object[]
必填
validateOnly
boolean
必填

Always true.