{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/zernio-com/json-schema/zernio-com-ctwa-ad-request-body-schema.json",
  "title": "CtwaAdRequestBody",
  "description": "Besides the `required` list, the request must use EXACTLY ONE of these shapes:\n\n- Single-creative: `headline`, `body`, and one of `imageUrl` / `video`, OR `platformPostId` / `objectStoryId` to reuse an organic post. On POST /v1/ads/messaging, `placementAssets` can replace `imageUrl` / `video`.\n- Carousel (messaging and CTWA): `body` and `carouselCards` (2-10 image or video cards) instead of `imageUrl` / `video`, top level or per `creatives[]` entry.\n- Multi-creative: a non-empty `creatives[]` array. Top-level creative fields must NOT be set on this shape.\n\n**Existing post references** work on messaging and CTWA only (not call ads). They cannot be combined with each other or with headline, body, imageUrl or video. `welcomeMessage` works on them (it lives on the ad, not the post).\n\nNo media is uploaded and the organic post is retained. Fresh creatives still require headline, body, and image or video.\n\nThe route enforces this at the Zod boundary; OpenAPI's `required` cannot express the OR cleanly.\n\n**Campaign, ad set and targeting fields** match POST /v1/ads/create on Meta and run through the same builders:\n\n- the full targeting set (including `rawTargeting`, `languages`, `gender`, exclusions and `savedTargetingId`);\n- `budgetLevel` (campaign budget);\n- `startDate` / `endDate` in the ad account timezone;\n- `existingCampaignId` to add a new ad set to a campaign you already have.\n",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/zernio-com-openapi.json#/components/schemas/CtwaAdRequestBody",
  "type": "object",
  "required": [
    "accountId",
    "adAccountId",
    "name"
  ],
  "properties": {
    "stage": {
      "type": "boolean",
      "description": "Send true to store this write as a staged change instead of applying it. The response is `202` with the change, and POST /v1/ads/changes/{changeId}/confirm applies it later. Cannot be combined with `validateOnly`."
    },
    "retryOnServerError": {
      "type": "boolean",
      "default": true,
      "description": "When Meta answers a create with a 5xx and reading the parent back by name finds no such object, Zernio sends the create again (at most 3 POSTs per object, never for an object created ACTIVE) and reports it in `recoveredWrites`.\n\n`false` never sends it again: the request fails with 502 and `details.unconfirmedWrite`, so you can check the parent yourself. One object found by name is still reused.\n"
    },
    "creativeFeatures": {
      "$ref": "#/$defs/MetaCreativeFeatures",
      "description": "Meta enhancement settings for single or attached ads, and defaults for creatives[]. An item replaces the entire map, including with an empty object."
    },
    "tracking": {
      "$ref": "#/$defs/AdTracking"
    },
    "accountId": {
      "type": "string",
      "minLength": 1,
      "description": "Facebook or Instagram SocialAccount ID."
    },
    "adAccountId": {
      "type": "string",
      "minLength": 1,
      "description": "Meta ad account ID, e.g. `act_123456789`."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Ad display name. Used to derive campaign / ad set names.\nOn the multi-creative shape, each ad's Meta name gets a\n\" #N\" suffix (1-indexed) so Ads Manager shows them as a\nnumbered batch.\n"
    },
    "campaignName": {
      "type": "string",
      "maxLength": 255,
      "description": "Exact name for the campaign this request provisions. Omitted keeps `<name> - Campaign`. Ignored with `adSetId` (the ad set already has a campaign)."
    },
    "adSetName": {
      "type": "string",
      "maxLength": 255,
      "description": "Exact name for the ad set this request provisions. Omitted keeps `<name> - Ad Set`. Ignored with `adSetId`."
    },
    "platformPostId": {
      "type": "string",
      "minLength": 1,
      "description": "Messaging and CTWA only. Platform post or reel ID, the same input boostPost takes as platformPostId. Mutually exclusive with objectStoryId and fresh creative fields.\n\n- Facebook IDs become object_story_id.\n- Instagram IDs become source_instagram_media_id, run as the media owner (resolved from the media on a Meta ads business-login connection, so no Instagram connection is needed).\n"
    },
    "existingPostId": {
      "type": "string",
      "minLength": 1,
      "deprecated": true,
      "description": "Alias of platformPostId, kept for existing callers. Sending both with different values is a 400."
    },
    "objectStoryId": {
      "type": "string",
      "pattern": "^\\d+_\\d+$",
      "description": "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."
    },
    "pageId": {
      "type": "string",
      "description": "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. Same semantics as `pageId` on POST /v1/ads/create."
    },
    "whatsappPhoneNumber": {
      "type": "string",
      "pattern": "^\\+[1-9]\\d{6,14}$",
      "description": "WhatsApp only. Optional E.164 number already paired with the Facebook Page. Omit to let Meta select the paired number.\n\n- Sent to the creative CTA and, when creating a new ad set, its promoted_object.\n- Meta can accept the number yet create the ad set without it; the response then carries a `warnings` entry.\n- Attach requests do not change the existing ad set.\n- Stored as creative.whatsappPhoneNumber on every created ad.\n"
    },
    "headline": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "Single-creative shape only. Mutually exclusive with\n`creatives[]`. Required on a single image or video ad (including\none built with `placementAssets`); not used by a `carouselCards`\nad and not accepted with an existing post reference.\n"
    },
    "body": {
      "type": "string",
      "minLength": 1,
      "description": "Primary text shown above the image / video. Single-creative\nshape only. Mutually exclusive with `creatives[]`.\n"
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "description": "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.\n\nMeta shows it mainly on Facebook Feed placements, under the headline, when there is room. Instagram, Stories, Reels and Messenger placements do not display it.\n\nAlso accepted per entry in `creatives[]`. Not allowed with an existing post creative.\n"
    },
    "imageUrl": {
      "type": "string",
      "format": "uri",
      "description": "Image asset for single-creative shape. Mutually exclusive\nwith `video` and with `creatives[]`. Required on the\nsingle-creative shape if neither `video` nor an existing post reference is supplied.\n"
    },
    "video": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Public URL of the video to upload. Provide either `url` or `id`."
        },
        "id": {
          "type": "string",
          "description": "Reuse a video already uploaded to this ad account (list them with GET /v1/ads/videos) instead of re-uploading. Wins over `url`. Provide either `url` or `id`. Meta: a video still processing is waited on for up to 30 s, then answered 409 `invalid_resource_state` (poll GET /v1/ads/videos/{videoId})."
        },
        "thumbnailUrl": {
          "type": "string",
          "format": "uri",
          "description": "OPTIONAL: when omitted, the poster is auto-generated from\nMeta's own preferred video thumbnail. When Meta produces no\ncandidate the request fails with a 502 platform_error\n(reason: video_thumbnail_unavailable). Retry, or supply\nthis field to control the poster frame exactly.\n"
        }
      },
      "description": "Video creative for single-creative shape. Mutually\nexclusive with `imageUrl` and with `creatives[]`. Required\non the single-creative shape if neither `imageUrl` nor an existing post reference is supplied.\n"
    },
    "welcomeMessage": {
      "type": "object",
      "required": [
        "text"
      ],
      "properties": {
        "text": {
          "type": "string",
          "minLength": 1,
          "description": "Greeting shown when the chat opens. Replaces Meta's default (\"Hi! Can we help you?\")."
        },
        "prefillText": {
          "type": "string",
          "minLength": 1,
          "description": "Message put into the user's text input, ready to send. Replaces Meta's default (\"Hi! I want more info.\"). Lets one ad steer the opening message toward what it promotes (e.g. a specific product). Exactly one of prefillText or quickReplies."
        },
        "quickReplies": {
          "type": "array",
          "minItems": 1,
          "maxItems": 13,
          "items": {
            "type": "object",
            "required": [
              "title",
              "payload"
            ],
            "properties": {
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 20,
                "description": "Chip label the person taps."
              },
              "payload": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1000,
                "description": "Opaque string you choose; delivered on the message.received webhook as interactiveMetadata.quickReplyPayload when the chip is tapped."
              }
            }
          },
          "description": "Tappable chips under the greeting instead of a prefilled message. Exactly one of prefillText or quickReplies.\n\nPut your own campaign or ad key in each payload. The tap arrives on the messages webhook with that payload even where Meta delivers no ad referral (Pages owned by an EU business under the Europe/Japan Messenger restrictions).\n"
        }
      },
      "description": "Custom chat welcome message (Meta's `page_welcome_message`,\n\"Mensaje de bienvenida\" / \"Mensaje predefinido\" in Ads Manager).\nSingle-creative shape only; for `creatives[]` set it per entry.\n"
    },
    "carouselCards": {
      "type": "array",
      "minItems": 2,
      "maxItems": 10,
      "items": {
        "$ref": "#/$defs/MessagingCarouselCard"
      },
      "description": "Messaging and CTWA only (a 400 on POST /v1/ads/call). A hand-built carousel of 2-10 image or video cards, sent to Meta in the given order as `link_data.child_attachments`.\n\n- Meta may reorder cards for performance, since `multi_share_optimized` defaults to true; `optimizeCardOrder: false` keeps your order.\n- Every card (and the carousel) carries the destination's messaging call to action (WHATSAPP_MESSAGE, MESSAGE_PAGE or INSTAGRAM_MESSAGE), so a tap on any card opens the conversation.\n- Replaces `imageUrl` / `video` (sending either is a 400).\n- `body` is required as the primary text. `headline` is optional and only names the creative (each card has its own `headline`). A top-level `description` is a 400 (set it per card).\n- `welcomeMessage`, `whatsappPhoneNumber` and `destinations` apply as on a single-image ad.\n- Also a 400 with `placementAssets`, `platformPostId`, `existingPostId` or `objectStoryId`.\n- Single-creative shape; for `creatives[]` set it per entry.\n"
    },
    "optimizeCardOrder": {
      "type": "boolean",
      "description": "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`.\n\n- `false`: keeps the cards in the order given. Meta then takes at most 5 cards, so `false` with more than 5 `carouselCards` is a 400.\n- `true`: lets Meta pick and reorder the cards for performance (up to 10).\n- Omitted: nothing is sent and Meta's default (`true`) applies.\n"
    },
    "creatives": {
      "type": "array",
      "minItems": 1,
      "description": "Multi-creative shape: N CTWA ads under one campaign + one ad set, sharing budget and targeting. Fresh and existing creatives can be mixed.\n\nEach entry supplies headline, body, and image/video, or a platformPostId or objectStoryId reference.\n\nMutually exclusive with the top-level single-creative fields (`headline` / `body` / `imageUrl` / `video`): setting both is a 400. This differs from `POST /v1/ads/create`, where the top-level fields are silently ignored in multi-creative mode.\n",
      "items": {
        "type": "object",
        "description": "Supply headline, body, and image/video; or body and carouselCards (no headline); or exactly one existing post reference. References cannot be combined with headline, body, imageUrl, video or carouselCards; welcomeMessage works on all three.",
        "properties": {
          "platformPostId": {
            "type": "string",
            "minLength": 1,
            "description": "Messaging and CTWA only. Platform post or reel ID, the same input boostPost takes as platformPostId. Mutually exclusive with objectStoryId and fresh creative fields.\n\n- Facebook IDs become object_story_id.\n- Instagram IDs become source_instagram_media_id, run as the media owner (resolved from the media on a Meta ads business-login connection, so no Instagram connection is needed).\n"
          },
          "existingPostId": {
            "type": "string",
            "minLength": 1,
            "deprecated": true,
            "description": "Alias of platformPostId, kept for existing callers. Sending both with different values is a 400."
          },
          "objectStoryId": {
            "type": "string",
            "pattern": "^\\d+_\\d+$",
            "description": "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."
          },
          "creativeFeatures": {
            "$ref": "#/$defs/MetaCreativeFeatures",
            "description": "Replaces the top-level creativeFeatures map for this item. Omit to inherit; an empty object clears inherited enrollment choices."
          },
          "headline": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "body": {
            "type": "string",
            "minLength": 1,
            "description": "Primary text shown above the image / video."
          },
          "imageUrl": {
            "type": "string",
            "format": "uri",
            "description": "Image asset. Mutually exclusive with this entry's\n`video`. Required if neither `video` nor an existing post reference is supplied.\n"
          },
          "video": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "description": "Public URL of the video to upload. Provide either `url` or `id`."
              },
              "id": {
                "type": "string",
                "description": "Reuse a video already uploaded to this ad account (list them with GET /v1/ads/videos) instead of re-uploading. Wins over `url`. Provide either `url` or `id`. Meta: a video still processing is waited on for up to 30 s, then answered 409 `invalid_resource_state` (poll GET /v1/ads/videos/{videoId})."
              },
              "thumbnailUrl": {
                "type": "string",
                "format": "uri",
                "description": "OPTIONAL: when omitted, the poster is auto-generated\nfrom Meta's own preferred video thumbnail. When Meta\nproduces no candidate the request fails with a 502\nplatform_error (reason: video_thumbnail_unavailable).\n"
              }
            },
            "description": "Video creative. Mutually exclusive with this entry's\n`imageUrl`. Required if neither `imageUrl` nor an existing post reference is supplied.\n"
          },
          "welcomeMessage": {
            "type": "object",
            "required": [
              "text"
            ],
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1,
                "description": "Greeting shown when the chat opens. Replaces Meta's default."
              },
              "prefillText": {
                "type": "string",
                "minLength": 1,
                "description": "Message put into the user's text input, ready to send. Replaces Meta's default. Exactly one of prefillText or quickReplies."
              },
              "quickReplies": {
                "type": "array",
                "minItems": 1,
                "maxItems": 13,
                "items": {
                  "type": "object",
                  "required": [
                    "title",
                    "payload"
                  ],
                  "properties": {
                    "title": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 20,
                      "description": "Chip label the person taps."
                    },
                    "payload": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1000,
                      "description": "Opaque string you choose; delivered on the message.received webhook as interactiveMetadata.quickReplyPayload when the chip is tapped."
                    }
                  }
                },
                "description": "Tappable chips under the greeting instead of a prefilled message. Exactly one of prefillText or quickReplies."
              }
            },
            "description": "Custom chat welcome message for this entry: `text` plus exactly one of `prefillText` or `quickReplies` (400 otherwise). Same shape as the top-level `welcomeMessage` of the single-creative shape."
          },
          "carouselCards": {
            "type": "array",
            "minItems": 2,
            "maxItems": 10,
            "items": {
              "$ref": "#/$defs/MessagingCarouselCard"
            },
            "description": "A 2-10 card carousel for this entry instead of `imageUrl` / `video`; `body` is required. Same rules as the top-level `carouselCards`. Carousel and single-media entries can be mixed on one ad set."
          }
        }
      }
    },
    "adSetId": {
      "type": "string",
      "description": "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.\n\nThe ad set then owns budget, targeting and schedule, so these are rejected with a 400 alongside it: `budgetAmount`, `budgetType`, `budgetLevel`, `startDate`, `endDate`, `objective`, `campaignStatus`, `adSetStatus`, `existingCampaignId`, the special ad category fields, and every targeting field except `ageMin`, `ageMax`, `placements` and `advantageAudience`.\n"
    },
    "existingCampaignId": {
      "type": "string",
      "pattern": "^\\d+$",
      "description": "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`.\n\n- The campaign's objective must be OUTCOME_ENGAGEMENT, OUTCOME_SALES or OUTCOME_LEADS (400 otherwise).\n- If the campaign has a campaign budget, omit `budgetAmount` and `budgetType` (400 if sent). Otherwise they are required and land on the new ad set.\n- `objective`, `campaignName`, `campaignStatus`, `budgetLevel`, `specialAdCategories`, `specialAdCategoryCountry` and `adSetId` are rejected alongside it.\n"
    },
    "budgetLevel": {
      "type": "string",
      "enum": [
        "adset",
        "campaign"
      ],
      "description": "Where the budget lives. `adset` (default) puts it on the new ad\nset. `campaign` creates an Advantage campaign budget (CBO): the\nbudget and bid strategy sit on the campaign and the ad set\ninherits them, same as POST /v1/ads/create. Not allowed with\n`adSetId` or `existingCampaignId`.\n"
    },
    "budgetAmount": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Budget amount in the ad account's currency major units\n(e.g. dollars for USD, not cents). Must be > 0.\nRequired unless `adSetId` is set (the ad set owns it) or\n`existingCampaignId` names a campaign with a campaign budget.\n"
    },
    "budgetType": {
      "type": "string",
      "enum": [
        "daily",
        "lifetime"
      ],
      "description": "Required unless `adSetId` is set or `existingCampaignId` names a campaign with a campaign budget. `lifetime` requires `endDate`."
    },
    "currency": {
      "type": "string",
      "minLength": 3,
      "maxLength": 3,
      "description": "ISO 4217 currency code matching the ad account's currency\n(e.g. `USD`). Optional: Zernio resolves it from the ad account\nwhen omitted. The value selects the minor-unit exponent Zernio\nconverts budget/bid amounts by before calling Meta (most\ncurrencies are cents; zero-decimal currencies like JPY/KRW are\nsent as-is).\n"
    },
    "startDate": {
      "type": "string",
      "description": "When the ad set starts delivering. ISO 8601 date or date-time. A\nvalue with an offset (`2027-01-15T10:00:00+01:00`, `...Z`) is used\nas is; one without an offset (`2027-01-15T10:00:00`) is read in the\nad account's timezone, and a date-only value starts at 00:00 local.\nDefaults to now.\n"
    },
    "endDate": {
      "type": "string",
      "description": "ISO 8601 date or date-time, read like `startDate`; a date-only\nvalue ends at 23:59:59 local. Required when `budgetType` is\n`lifetime`.\n"
    },
    "countries": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 2,
        "maxLength": 2
      },
      "description": "ISO 3166-1 alpha-2 country codes. Defaults to `[\"US\"]` only\nwhen no other geo (`cities`, `regions`, `zips`, `metros`,\n`customLocations`) is supplied.\n"
    },
    "cities": {
      "type": "array",
      "description": "City-level geo targeting for local CTWA campaigns. Each entry maps to Meta's TargetingGeoLocationCity; `key` is Meta's city ID.\n\n`radius` and `distance_unit` are coupled: set both or neither. Meta enforces a minimum city radius (~17 km / 10 mi); smaller values resolve to a 0-size audience and the ad fails at launch. For a tighter catchment use customLocations (lat/lng).\n",
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          },
          "radius": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "distance_unit": {
            "type": "string",
            "enum": [
              "mile",
              "kilometer"
            ]
          }
        }
      }
    },
    "regions": {
      "type": "array",
      "description": "Region / state-level geo targeting. `key` is Meta's region\nID (lookupable via GET /v1/ads/targeting/search?type=region).\n",
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "zips": {
      "type": "array",
      "description": "ZIP / postal-code geo targeting. `key` is the platform's\npostal id resolved via /v1/ads/targeting/search.\n",
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "metros": {
      "type": "array",
      "description": "DMA / metro-area geo targeting. `key` is Meta's metro id\n(e.g. `DMA:807`).\n",
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "countryGroups": {
      "type": "array",
      "description": "Meta only. Continents and trade blocs (`geo_locations.country_groups`),\nfor targeting a whole region without listing its countries. Combines\nwith `countries` rather than replacing it, and is also accepted under\n`excludedLocations`. Discoverable via\n`GET /v1/ads/targeting/search?dimension=geo&geoType=country_group`.\n",
      "items": {
        "type": "string",
        "enum": [
          "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"
        ]
      }
    },
    "customLocations": {
      "type": "array",
      "description": "Point-radius geo (Meta `geo_locations.custom_locations`).\nUse for targeting a radius around a specific lat/long when\nno Meta city/region key fits. `distanceUnit` is required.\n",
      "items": {
        "type": "object",
        "required": [
          "latitude",
          "longitude",
          "radius",
          "distanceUnit"
        ],
        "properties": {
          "latitude": {
            "type": "number",
            "minimum": -90,
            "maximum": 90
          },
          "longitude": {
            "type": "number",
            "minimum": -180,
            "maximum": 180
          },
          "radius": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "distanceUnit": {
            "type": "string",
            "enum": [
              "mile",
              "kilometer"
            ]
          },
          "name": {
            "type": "string"
          },
          "address": {
            "type": "string"
          }
        }
      }
    },
    "ageMin": {
      "type": "integer",
      "minimum": 13,
      "maximum": 65
    },
    "ageMax": {
      "type": "integer",
      "minimum": 13,
      "maximum": 65
    },
    "interests": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "audienceId": {
      "type": "string",
      "description": "Custom audience ID to target."
    },
    "placements": {
      "type": "object",
      "description": "Manual ad placements on the shared ad set. Omit for automatic placements.\n\nWhen set, restricts delivery to the chosen surfaces, mapped onto the ad set's `targeting.{publisher_platforms, facebook_positions, instagram_positions, messenger_positions, audience_network_positions, threads_positions, whatsapp_positions, device_platforms}`.\n\nEnum membership is validated here. Meta additionally enforces co-selection rules and restricts which placements are eligible for click-to-WhatsApp ads, returning an actionable error which we surface.\n",
      "properties": {
        "publisherPlatforms": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "facebook",
              "instagram",
              "threads",
              "messenger",
              "audience_network",
              "whatsapp"
            ]
          },
          "description": "Top-level platforms to deliver on. A position field below is only honoured when its parent platform is included here."
        },
        "facebookPositions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "feed",
              "right_hand_column",
              "marketplace",
              "story",
              "search",
              "instream_video",
              "facebook_reels",
              "facebook_reels_overlay",
              "profile_feed",
              "notification"
            ]
          }
        },
        "instagramPositions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "stream",
              "story",
              "explore",
              "explore_home",
              "reels",
              "profile_feed",
              "ig_search",
              "profile_reels"
            ]
          }
        },
        "messengerPositions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "messenger_home",
              "sponsored_messages",
              "story"
            ]
          }
        },
        "audienceNetworkPositions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "classic",
              "rewarded_video"
            ]
          }
        },
        "threadsPositions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "threads_stream"
            ]
          }
        },
        "whatsappPositions": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "status"
            ]
          }
        },
        "devicePlatforms": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "mobile",
              "desktop"
            ]
          },
          "description": "Restrict by device. Omit to deliver on both mobile and desktop."
        }
      }
    },
    "gender": {
      "type": "string",
      "enum": [
        "all",
        "male",
        "female"
      ],
      "description": "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`."
    },
    "languages": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "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\"). Meta numeric locale ids (e.g. \"24\" for English UK) are also accepted. Unknown values are rejected. Same format as `targeting.languages` on POST /v1/ads/boost."
    },
    "places": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string"
          }
        }
      },
      "description": "Meta place keys (from GET /v1/ads/targeting/search)."
    },
    "neighborhoods": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "key"
        ],
        "properties": {
          "key": {
            "type": "string"
          }
        }
      },
      "description": "Meta neighborhood keys (from GET /v1/ads/targeting/search)."
    },
    "excludedLocations": {
      "type": "object",
      "description": "Geo to exclude, same shape as POST /v1/ads/create (countries, countryGroups, regions, cities, zips, places, neighborhoods, customLocations).",
      "additionalProperties": true
    },
    "behaviors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "description": "Behavior ids from /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."
    },
    "workPositions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "workEmployers": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "workIndustries": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      }
    },
    "incomeTier": {
      "type": "string",
      "enum": [
        "top_5",
        "top_10",
        "top_10_25",
        "top_25_50"
      ],
      "description": "Normalized household-income tier, same as POST /v1/ads/create. Incompatible with housing, employment and credit specialAdCategories."
    },
    "userOs": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "description": "Meta `user_os`, e.g. [\"iOS_ver_14.0_and_above\"]."
    },
    "userDevice": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "description": "Meta `user_device`."
    },
    "audienceInclude": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "description": "Custom or lookalike audience ids to include."
    },
    "audienceExclude": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "description": "Custom or lookalike audience ids to exclude."
    },
    "savedTargetingId": {
      "type": "string",
      "description": "ID of a saved_targeting audience (POST /v1/ads/audiences), expanded as the base targeting. Precedence: savedTargetingId, then `targeting`, then the flat fields."
    },
    "targeting": {
      "$ref": "#/$defs/TargetingSpec",
      "description": "Nested targeting object, same contract as POST /v1/ads/create and boost. Flat fields win per key."
    },
    "rawTargeting": {
      "type": "object",
      "additionalProperties": true,
      "description": "Meta targeting spec sent as the BASE layer of the ad set's `targeting`, exactly as POST /v1/ads/create does. Use it for anything the flat fields cannot express, such as a layered `flexible_spec` (entries AND together, ids inside one entry OR).\n\nFlat fields you also send are layered on top and win per key.\n\nWith rawTargeting present the US geo and `advantage_audience: 0` defaults are not injected, so include `targeting_automation` in it (or send `advantageAudience`), as Meta requires it on create.\n"
    },
    "metaSavedAudienceId": {
      "type": "string",
      "pattern": "^\\d+$",
      "description": "The id of a Meta saved audience on `adAccountId` (made in Ads Manager, listed by `GET /v1/ads/saved-audiences`). Its targeting is read live from Meta and used as `rawTargeting` for the new ad set, so flat targeting fields merge on top of it exactly as they do on `rawTargeting`.\n\nReturns 404 when the id is not on the ad account, 400 `mutually_exclusive_fields` with `rawTargeting` or `savedTargetingId`, and 400 with `adSetId` (an existing ad set keeps its targeting). Meta requires `targeting_automation` on create: send `advantageAudience` when the saved audience does not carry it.\n"
    },
    "specialAdCategories": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "HOUSING",
          "EMPLOYMENT",
          "CREDIT",
          "ISSUES_ELECTIONS_POLITICS",
          "FINANCIAL_PRODUCTS_SERVICES",
          "ONLINE_GAMBLING_AND_GAMING"
        ]
      },
      "description": "Meta special ad categories on the new campaign."
    },
    "specialAdCategoryCountry": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Countries the special ad category applies to. Requires specialAdCategories."
    },
    "advantageAudience": {
      "oneOf": [
        {
          "type": "integer",
          "enum": [
            0,
            1
          ]
        },
        {
          "type": "boolean"
        }
      ],
      "description": "Meta's Advantage+ audience expansion. `0` or `false` (default) keeps\ntargeting strict; `1` or `true` lets Meta expand beyond the supplied\ntargeting when its delivery system finds better matches.\nBooleans are sent to Meta as 1/0. Always sent on CREATE (Meta requires it).\n"
    },
    "objective": {
      "type": "string",
      "enum": [
        "OUTCOME_ENGAGEMENT",
        "OUTCOME_SALES",
        "OUTCOME_LEADS"
      ],
      "description": "Defaults to `OUTCOME_ENGAGEMENT` on POST /v1/ads/ctwa and POST /v1/ads/messaging,\nand to `OUTCOME_LEADS` on POST /v1/ads/call and on POST /v1/ads/messaging with\n`optimizationGoal: LEAD_GENERATION` (which accepts only `OUTCOME_LEADS`).\n`OUTCOME_SALES` and `OUTCOME_LEADS` require\nadditional account configuration (Dataset linked to the WABA\nfor sales) and may be rejected by Meta if missing.\n"
    },
    "status": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "PAUSED"
      ],
      "description": "Defaults to `ACTIVE`. `PAUSED` pauses only the top-most object this\ncall creates: the new campaign (ad set and ads switched on), or, with\n`adSetId`, the new ads themselves.\n"
    },
    "campaignStatus": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "PAUSED"
      ],
      "description": "Campaign-level status, same semantics as `POST /v1/ads/create`. Defaults to `status`.\n\n- `PAUSED`: holds the new campaign off while the ad set and ads switch on (one resume call brings the whole hierarchy live).\n- `ACTIVE` with `status: PAUSED`: switches the campaign on and pauses the new ad set instead.\n\nOnly meaningful when a new campaign is created. Rejected with a 400 alongside `adSetId` (the attach shape reuses an existing campaign).\n"
    },
    "adSetStatus": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "PAUSED"
      ],
      "description": "Ad-set-level status, same semantics as `POST /v1/ads/create`. Sets the new ad set's switch alone and overrides `status` for it.\n\nA level status (`campaignStatus`, `adSetStatus`, `adStatus`) always wins for its level, and `status: PAUSED` adds a hold of its own only when none of them is PAUSED.\n\nRejected with a 400 alongside `adSetId` (that ad set already exists).\n"
    },
    "adStatus": {
      "$ref": "#/$defs/AdActivationStatus",
      "description": "Ad-level status, same semantics as `POST /v1/ads/create`. Sets the\nnew ads' switch and overrides `status` for them, also with\n`adSetId`. Send `campaignStatus`, `adSetStatus` and `adStatus` all\nPAUSED to create every object paused.\n"
    },
    "bidStrategy": {
      "type": "string",
      "enum": [
        "LOWEST_COST_WITHOUT_CAP",
        "LOWEST_COST_WITH_BID_CAP",
        "COST_CAP",
        "LOWEST_COST_WITH_MIN_ROAS"
      ],
      "description": "Meta bid strategy applied to the shared ad set. Defaults to\n`LOWEST_COST_WITHOUT_CAP` (auto-bid) when omitted.\n`LOWEST_COST_WITH_BID_CAP` and `COST_CAP` require\n`bidAmount`. `LOWEST_COST_WITH_MIN_ROAS` requires\n`roasAverageFloor`. The ad set `optimization_goal` comes from the endpoint\n(`CONVERSATIONS` on POST /v1/ads/ctwa, `QUALITY_CALL` on POST /v1/ads/call, the\n`optimizationGoal` field on POST /v1/ads/messaging); the bid strategy is independent.\n"
    },
    "bidAmount": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Whole currency units (e.g. `5` = $5.00 on a USD account).\nRequired when `bidStrategy` is `LOWEST_COST_WITH_BID_CAP`\nor `COST_CAP`; rejected otherwise.\n"
    },
    "roasAverageFloor": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Decimal ROAS multiplier (e.g. `2.0` = 2.0× ROAS floor).\nRequired when `bidStrategy` is `LOWEST_COST_WITH_MIN_ROAS`;\nrejected otherwise. Meta enforces its own upper bound\nserver-side.\n"
    },
    "dsaBeneficiary": {
      "type": "string",
      "maxLength": 100,
      "description": "Legal entity that benefits from the ad. Required when targeting EU users\n(EU DSA, Article 26). Optional if the ad account has a default beneficiary:\nset it once via `PATCH /v1/ads/accounts` or in Meta Ads Manager, and Meta\nfills it in whenever the field is omitted.\n"
    },
    "dsaPayor": {
      "type": "string",
      "maxLength": 100,
      "description": "Legal entity that pays for the ad. Can differ from `dsaBeneficiary`\n(for example, an agency paying for a client's ads). Same rules as\n`dsaBeneficiary`: required for EU targeting unless the ad account has\na default payor.\n"
    },
    "regionalRegulatedCategories": {
      "type": "array",
      "description": "Meta only. Regional regulation categories required when the ad set targets certain countries (e.g. AUSTRALIA_FINSERV, AUSTRALIA_UNIVERSAL, BRAZIL_REGULATION, INDIA_FINSERV, MALAYSIA_UNIVERSAL, SINGAPORE_UNIVERSAL, TAIWAN_FINSERV, TAIWAN_UNIVERSAL, THAILAND_UNIVERSAL, US_SECURITIES_LICENSING). Forwarded to the ad set.",
      "items": {
        "type": "string"
      }
    },
    "regionalRegulationIdentities": {
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "integer"
        ]
      },
      "description": "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.\n\nMeta may require them on API-created ad sets even when a default beneficiary and payer are set in Ads Manager (seen on AUSTRALIA_FINSERV), so sending them explicitly is the reliable path.\n\n**Value:** the Verified identity ID (Meta Business Settings > Verified identities), not a Page or Business ID. Beneficiary and payer may be the same ID. The IDs reach Meta unchanged.\n\nSend each ID as a string of digits: IDs can have 17 digits, more than a JSON number holds exactly, and a rounded number is rejected. Numbers up to 9007199254740991 are still accepted.\n\n**Keys by category:**\n\n- AUSTRALIA_FINSERV: australia_finserv_beneficiary / australia_finserv_payer\n- TAIWAN_FINSERV: taiwan_finserv_beneficiary / taiwan_finserv_payer\n- INDIA_FINSERV: india_finserv_beneficiary / india_finserv_payer\n- TAIWAN_UNIVERSAL: taiwan_universal_beneficiary / taiwan_universal_payer\n- SINGAPORE_UNIVERSAL: singapore_universal_beneficiary / singapore_universal_payer\n- AUSTRALIA_UNIVERSAL, BRAZIL_REGULATION, MALAYSIA_UNIVERSAL, THAILAND_UNIVERSAL and US_SECURITIES_LICENSING: universal_beneficiary / universal_payer\n\nWhen Meta rejects the ad set for a missing verified advertiser, the error carries param regionalRegulationIdentities, details.expectedIdentityKeys (keys the declared categories expect), details.suggestedCategories (markets Meta ties to that subcode) and Meta's metaCode, metaSubcode and fbtraceId.\n"
    }
  },
  "$defs": {
    "AdActivationStatus": {
      "type": "string",
      "enum": [
        "ACTIVE",
        "PAUSED"
      ],
      "description": "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` enum). Distinct from `AdStatus` (the platform-reported delivery status returned on reads)."
    },
    "AdTracking": {
      "type": "object",
      "description": "Ad tracking. Meta, plus `urlTags` on ChatGPT (OpenAI) and `pixelId` on Reddit.\n\n**Meta**: attaches pixel measurement to the ad regardless of the optimization goal (the \"Website events\" tracking row in Ads Manager).\n\n- `pixelId` becomes the ad's `tracking_specs` (offsite_conversion + fb_pixel).\n- `urlTags` is stored on the new creative as `url_tags` and retained on the ad for compatibility.\n- Applied on the legacy single-creative shape, every ad of the multi-creative shape, and the attach shape.\n- Tracking lives on the AD object and is not inherited from the ad set, so pass it on EVERY attach call that should carry the pixel.\n\n**ChatGPT (OpenAI)**: `urlTags` becomes the ad's `landing_page_configuration.query_string_template`, which OpenAI appends to `linkUrl` on click.\n\n**Reddit**: `pixelId` picks the pixel of the new ad group, like `promotedObject.pixelId` (which wins when both are sent).\n",
      "properties": {
        "pixelId": {
          "type": "string",
          "description": "Meta Pixel ID to attach for offsite-conversion measurement, or the Reddit pixel of the new ad group."
        },
        "urlTags": {
          "type": "array",
          "description": "Click-URL params.\n\n- Meta: stored on the creative as `url_tags` and returned by GET /v1/ads/{adId}/tracking-tags. Dynamic macros ({{ad.id}}, {{campaign.id}}, {{placement}}, ...) are sent through unescaped so Meta expands them; every other character is percent-encoded. App-promotion linkUrl stays byte-identical to promotedObject.objectStoreUrl.\n- ChatGPT (OpenAI): the same encoding, with OpenAI's macros `{campaign_id}`, `{ad_group_id}`, `{ad_id}` and `{oppref}` (click id) passed through raw. OpenAI expands macros here, not inside `linkUrl`.\n",
          "items": {
            "type": "object",
            "required": [
              "key",
              "value"
            ],
            "properties": {
              "key": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            }
          }
        },
        "zernioTag": {
          "type": "boolean",
          "description": "POST /v1/ads/create on Meta and Google only. Set `true` and the ad carries `zrn=<platform ad id>` on its landing URL, so orders and events tied to the landing URL map back to the ad. Omitted: follows your team's Tag new ads setting (`PUT /v1/ads/campaign-results/tag-new-ads`, off by default).\n\n- **Meta:** `{ key: zrn, value: '{{ad.id}}' }` is appended after your `urlTags`, which are sent unchanged; a `zrn` key you send yourself is kept. Skipped for lead forms, call ads, `existingCreativeId` and app promotion.\n- **Google (Display and Search):** the ad's `final_url_suffix` is set to `zrn={creative}` only when the ad inherits no suffix from its ad group, campaign or account. Otherwise the ad is left untouched (your suffix keeps applying) and attribution uses the click's `gclid`.\n- If the inherited suffix cannot be read or Google rejects the tag, the ad is created untagged.\n\nExisting ads are never changed. `false` creates the ad with no Zernio tag, whatever the setting.\n"
        }
      }
    },
    "MessagingCarouselCard": {
      "type": "object",
      "description": "One card of a messaging ad carousel (Meta link_data.child_attachments). Every card opens the same conversation, so a card has no link of its own. Exactly one of `imageUrl` or `video` (a 400 otherwise).",
      "properties": {
        "imageUrl": {
          "type": "string",
          "format": "uri",
          "description": "Image card. Uploaded to the ad account and sent as the card image_hash (by URL on validateOnly)."
        },
        "video": {
          "type": "object",
          "description": "Video card, sent as the card's `video_id`. Needs `url` or `id`. On validateOnly only `id` works, since `url` needs an upload first.",
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "description": "Video file uploaded to the ad account."
            },
            "id": {
              "type": "string",
              "description": "A video already on the ad account."
            },
            "thumbnailUrl": {
              "type": "string",
              "format": "uri",
              "description": "The card's poster. Defaults to Meta's auto-generated thumbnail."
            }
          }
        },
        "headline": {
          "type": "string",
          "maxLength": 255,
          "description": "Card title (Meta name)."
        },
        "description": {
          "type": "string",
          "maxLength": 255,
          "description": "Card description, under the title."
        },
        "callToAction": {
          "type": "string",
          "description": "Optional. Must equal the destination's messaging call to action (WHATSAPP_MESSAGE for whatsapp, MESSAGE_PAGE for messenger, INSTAGRAM_MESSAGE for instagram_direct; with `destinations` the first one listed). Any other value is a 400 naming the card, because Meta refuses a carousel whose cards do not all open the destination."
        },
        "linkUrl": {
          "type": "string",
          "description": "Not accepted: a 400. The card tap opens the conversation, not a website."
        }
      }
    },
    "MetaCreativeFeatures": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "enum": [
          "OPT_IN",
          "OPT_OUT"
        ]
      },
      "propertyNames": {
        "pattern": "^[a-z0-9_]+$"
      },
      "description": "Meta Advantage+ creative enhancements. Map snake_case feature names to OPT_IN or OPT_OUT; Meta validates supported keys. On creation Zernio sends only the keys you name, so Meta's default applies to the rest; on PUT /v1/ads/{adId} omitted keys keep the creative's current value. Send OPT_OUT to switch an enhancement off.\n\nauto_promotion_tag is an Advantage+ enhancement, not the Ads Manager Promotion setting. The deprecated standard_enhancements bundle (subcode 3858504) is a 400 before any Meta call.\n"
    },
    "TargetingSpec": {
      "type": "object",
      "description": "Normalized, platform-agnostic ad-targeting spec. Every field is optional; an empty object targets the platform's default broadest audience.\n\nField names are camelCase and identical across `POST /v1/ads/create` (the `targeting` object), `POST /v1/ads/targeting/reach-estimate`, and `saved_targeting` audiences, so a spec resolved once can be reused verbatim.\n\n**Entity ids** (`regions[].key`, `cities[].key`, `zips[].key`, `metros[].key`, `interests[].id`, `behaviors[].id`) are the platform's opaque identifiers resolved via `GET /v1/ads/targeting/search`. A spec is therefore meaningful only for the platform it was built against.\n\n**Portable fields** carry across platforms: `countries`, `ageMin`/`ageMax`, `gender`, `incomeTier`, `languages`.\n\nFields a platform cannot honour are rejected on create, boost and targeting update with `INVALID_FIELD_VALUE` naming the offending field (never silently dropped).\n",
      "properties": {
        "userOs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Meta only. Operating systems and version ranges, such as iOS_ver_14.0_and_above or Android. Emitted as user_os. May also be supplied inside targeting."
        },
        "userDevice": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Meta only. Device models such as iPhone. Emitted as user_device. May also be supplied inside targeting."
        },
        "countries": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "ISO 3166-1 alpha-2 country codes (e.g. ['US'])."
        },
        "regions": {
          "type": "array",
          "description": "Region/state targeting. `key` is the platform location ID from /v1/ads/targeting/search?dimension=geo&geoType=region. An entry may also be that id as a plain string (`\"20321\"` is `{ key: \"20321\" }`).",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            ]
          }
        },
        "cities": {
          "type": "array",
          "description": "City targeting. Optional `radius` + `distanceUnit` extend beyond the city limits; both must be set together or both omitted. `radius` is only honoured on platforms whose capability map allows city radius (Meta). An entry may also be the city id as a plain string (`\"1006410\"` is `{ key: \"1006410\" }`).",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "radius": {
                    "type": "number",
                    "description": "Radius around the city. Requires distanceUnit. Meta enforces a minimum city radius (~17 km / 10 mi); smaller values resolve to a 0-size audience and the ad fails at launch. For a tighter catchment use customLocations (lat/lng), which allows a smaller radius."
                  },
                  "distanceUnit": {
                    "type": "string",
                    "enum": [
                      "mile",
                      "kilometer"
                    ],
                    "description": "Required if radius is set."
                  }
                }
              }
            ]
          }
        },
        "zips": {
          "type": "array",
          "description": "Postal/ZIP targeting. `key` is the platform's postal location ID (e.g. Meta `US:94304`). Supported on Meta, Google, TikTok, Pinterest, X.",
          "items": {
            "type": "object",
            "required": [
              "key"
            ],
            "properties": {
              "key": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "metros": {
          "type": "array",
          "description": "DMA / metro-area targeting. `key` is the platform's metro ID (e.g. Meta `DMA:807`).",
          "items": {
            "type": "object",
            "required": [
              "key"
            ],
            "properties": {
              "key": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "countryGroups": {
          "type": "array",
          "description": "Meta only. Continents and trade blocs (`geo_locations.country_groups`),\nfor targeting a whole region without listing its countries. Combines\nwith `countries` rather than replacing it, and is also accepted under\n`excludedLocations`. Discoverable via\n`GET /v1/ads/targeting/search?dimension=geo&geoType=country_group`.\n",
          "items": {
            "type": "string",
            "enum": [
              "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"
            ]
          }
        },
        "places": {
          "type": "array",
          "description": "Meta only. Named points of interest to target. `key` from /v1/ads/targeting/search.",
          "items": {
            "type": "object",
            "required": [
              "key"
            ],
            "properties": {
              "key": {
                "type": "string"
              }
            }
          }
        },
        "neighborhoods": {
          "type": "array",
          "description": "Meta only. Named neighbourhood areas to target. `key` from /v1/ads/targeting/search.",
          "items": {
            "type": "object",
            "required": [
              "key"
            ],
            "properties": {
              "key": {
                "type": "string"
              }
            }
          }
        },
        "customLocations": {
          "type": "array",
          "description": "Point-radius (lat/lng) targeting (Meta custom_locations / Google proximity). Honoured on Meta and Google; ignored on platforms without radius support.",
          "items": {
            "type": "object",
            "required": [
              "latitude",
              "longitude",
              "radius",
              "distanceUnit"
            ],
            "properties": {
              "latitude": {
                "type": "number",
                "minimum": -90,
                "maximum": 90
              },
              "longitude": {
                "type": "number",
                "minimum": -180,
                "maximum": 180
              },
              "radius": {
                "type": "number",
                "description": "Positive radius around the point."
              },
              "distanceUnit": {
                "type": "string",
                "enum": [
                  "mile",
                  "kilometer"
                ]
              },
              "name": {
                "type": "string"
              },
              "address": {
                "type": "string",
                "description": "Optional label, sent to Meta as `address_string`. latitude/longitude take precedence for the pin location."
              }
            }
          }
        },
        "excludedLocations": {
          "type": "object",
          "description": "Geo to exclude from the audience. Mirrors the inclusion geo shape.\n\n- Meta (excluded_geo_locations): excluded cities can carry a radius catchment, and excluded custom (lat/lng) pins are supported.\n- Google (Search, Display, Performance Max): excludes countries, regions, cities and zips as negative location criteria. countryGroups, places, neighborhoods, customLocations and a city radius return 400.\n- Google Demand Gen: returns 400 for any exclusion.\n",
          "properties": {
            "countries": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "countryGroups": {
              "type": "array",
              "description": "Meta only. Continents and trade blocs to exclude (`excluded_geo_locations.country_groups`).",
              "items": {
                "type": "string",
                "enum": [
                  "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"
                ]
              }
            },
            "regions": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            },
            "cities": {
              "type": "array",
              "description": "Cities to exclude. Optional `radius` + `distanceUnit` exclude a catchment around the city (both must be set together or both omitted); Meta honours the radius on excluded cities.",
              "items": {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "radius": {
                    "type": "number",
                    "description": "Radius around the excluded city. Requires distanceUnit."
                  },
                  "distanceUnit": {
                    "type": "string",
                    "enum": [
                      "mile",
                      "kilometer"
                    ],
                    "description": "Required if radius is set."
                  }
                }
              }
            },
            "zips": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            },
            "places": {
              "type": "array",
              "description": "Named points of interest to exclude. `key` from /v1/ads/targeting/search.",
              "items": {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  }
                }
              }
            },
            "neighborhoods": {
              "type": "array",
              "description": "Named neighbourhood areas to exclude. `key` from /v1/ads/targeting/search.",
              "items": {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string"
                  }
                }
              }
            },
            "customLocations": {
              "type": "array",
              "description": "Point-radius (lat/lng) pins to exclude (Meta excluded_geo_locations.custom_locations). Mirrors the inclusion customLocations shape.",
              "items": {
                "type": "object",
                "required": [
                  "latitude",
                  "longitude",
                  "radius",
                  "distanceUnit"
                ],
                "properties": {
                  "latitude": {
                    "type": "number",
                    "minimum": -90,
                    "maximum": 90
                  },
                  "longitude": {
                    "type": "number",
                    "minimum": -180,
                    "maximum": 180
                  },
                  "radius": {
                    "type": "number",
                    "description": "Positive radius around the point."
                  },
                  "distanceUnit": {
                    "type": "string",
                    "enum": [
                      "mile",
                      "kilometer"
                    ]
                  },
                  "name": {
                    "type": "string"
                  },
                  "address": {
                    "type": "string",
                    "description": "Optional label, sent to Meta as `address_string`. latitude/longitude take precedence for the pin location."
                  }
                }
              }
            }
          }
        },
        "ageMin": {
          "type": "integer",
          "minimum": 13,
          "maximum": 100,
          "description": "Minimum age.\n\n- Applied on Meta, TikTok, Pinterest, LinkedIn, X and Google Search/Display (Google excludes the age ranges outside the request).\n- Rejected with 400 on OpenAI, Reddit and Google Performance Max / Demand Gen.\n\nEach platform clamps to its own range:\n\n- Meta and Pinterest: effectively cap at 65 (65 = 65+).\n- Pinterest: no under-18 bucket, so an ageMin below 18 starts at 18.\n- TikTok: maps up to 100.\n- LinkedIn: rounds out to its buckets (18-24, 25-34, 35-54, 55+) and has no under-18 audience.\n- X: rounds out to the narrowest of its fixed ranges (e.g. 25-34 becomes 25-49, 18-65 becomes 18+)."
        },
        "ageMax": {
          "type": "integer",
          "minimum": 13,
          "maximum": 100,
          "description": "Maximum age. Same per-platform application and clamping as ageMin."
        },
        "gender": {
          "type": "string",
          "enum": [
            "all",
            "male",
            "female"
          ],
          "description": "Restrict by gender. 'all' (default) targets everyone. Applied on Meta, TikTok, Pinterest, LinkedIn, X, Reddit and Google Search/Display (Google excludes the other gender); rejected with 400 on OpenAI and on Google Performance Max / Demand Gen."
        },
        "incomeTier": {
          "type": "string",
          "enum": [
            "top_5",
            "top_10",
            "top_10_25",
            "top_25_50"
          ],
          "description": "Normalized household-income tier (ZIP/percentile based). Meta and TikTok\nexpress all four. Google maps only `top_10` (its INCOME_RANGE_90_UP); other\ntiers on Google, and any income tier on LinkedIn / X / Pinterest, are rejected.\nOn Meta, income/zip targeting requires the relevant `specialAdCategories` to be\nunset (housing/employment/credit ads cannot use it).\n"
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Language codes restricting the audience by language. Applied on Meta, Google, TikTok, LinkedIn, X, Pinterest and Reddit; rejected with 400 on OpenAI. A code the platform cannot target returns 400 listing the ones it can.\n\nOn Meta: ISO 639-1 codes (e.g. ['en']). A bare code targets all regional variants (\"en\" = all English); use a region-qualified code (\"en_GB\", \"pt_BR\") for a specific one. Meta numeric locale ids (e.g. \"24\" for English UK) are also accepted. Unknown values are rejected.\n\nPOST /v1/ads/create and POST /v1/ads/boost take the same format."
        },
        "interests": {
          "type": "array",
          "description": "Interest entities from /v1/ads/targeting/search?dimension=interest. Each carries the platform's opaque id.\n\n- Google: applied as ad-group interest criteria (affinity and in-market categories) on Display and Search ad groups the request creates. Interests are create-only.\n- Google rejections (400): on Performance Max, on Demand Gen (use the Demand Gen audience `userInterests` there), and when attaching to an existing ad group (`adSetId`).\n- OpenAI: rejected with 400.\n- TikTok: bare numeric ids are interest categories (`interest_category_ids`); ids like `keyword:123456` from `dimension=interestKeyword` are additional interests (`interest_keyword_ids`). Any other id returns 422 naming `targeting.interests`.\n- TikTok matching: people who fit ANY selected interest, additional interest or behavior (one OR'd group). That group is ANDed with location, age, gender and the other dimensions.\n",
          "items": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "behaviors": {
          "type": "array",
          "description": "Behaviour entities from /v1/ads/targeting/search?dimension=behavior (Meta, TikTok and LinkedIn).\n\n**On TikTok** they target people who, in the picked categories:\n\n- interacted with videos (watched to the end, liked, commented or shared, last 15 days);\n- interacted with creators (followed or viewed the profile);\n- or viewed videos with a picked hashtag (`hashtag:<id>` ids from `dimension=hashtag`, sent as a `HASHTAG_RELATED` action with `VIEW_HASHTAG`).\n\nThe ad group then uses the TikTok placement only. Behaviors are OR'd with interests and additional interests.\n",
          "items": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "workPositions": {
          "type": "array",
          "description": "Meta only. Job title entities from /v1/ads/targeting/search?dimension=workPosition. Not interchangeable with the LinkedIn `jobTitles` URN fragments.",
          "items": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "workEmployers": {
          "type": "array",
          "description": "Meta only. Employer entities from /v1/ads/targeting/search?dimension=workEmployer.",
          "items": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "workIndustries": {
          "type": "array",
          "description": "Meta only. Work-industry entities from /v1/ads/targeting/search?dimension=workIndustry. Not interchangeable with the LinkedIn `industries` URN fragments.",
          "items": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          }
        },
        "industries": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "LinkedIn B2B only. Industry URN id fragments, or the full urn:li:industry:* URN from /v1/ads/targeting/search?dimension=industry."
        },
        "companySizes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "LinkedIn B2B only. Single-letter size codes (A to I), or the full urn:li:staffCountRange:* URN from /v1/ads/targeting/search?dimension=companySize."
        },
        "seniorities": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "LinkedIn B2B only. Seniority URN id fragments, or the full urn:li:seniority:* URN from /v1/ads/targeting/search?dimension=seniority."
        },
        "jobFunctions": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "LinkedIn B2B only. Function URN id fragments, or the full urn:li:function:* URN from /v1/ads/targeting/search?dimension=jobFunction."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "LinkedIn B2B only. Member skills (e.g. Python, Recruiting): skill URN id fragments, or the full urn:li:skill:* URN from /v1/ads/targeting/search?dimension=skill. Values are ORed; the facet is ANDed with the other facets. On an ad set update an empty list removes the skills."
        },
        "audienceInclude": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Platform audience IDs to include, as returned by GET /v1/ads/audiences:\n\n- Meta: custom audience ids.\n- TikTok: audience ids.\n- Pinterest: customer list ids.\n- LinkedIn: segment ids (the platformAudienceId from GET /v1/ads/audiences). Zernio resolves it to the targetable LinkedIn ad segment; an unknown id returns 400.\n- Google: user list ids.\n- X: custom audience ids.\n- Reddit: ids of custom audiences built in Reddit Ads Manager (GET /v1/ads/audiences does not list Reddit audiences).\n- OpenAI: not supported (400)."
        },
        "audienceExclude": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Platform audience IDs to exclude; same ID formats as audienceInclude. Not supported on OpenAI (400)."
        },
        "communities": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Reddit only (400 elsewhere). Subreddits to target, by name, with or without the `r/` prefix (e.g. `['marketing', 'r/startups']`), as returned by /v1/ads/targeting/search?dimension=community."
        },
        "excludedCommunities": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Reddit only (400 elsewhere). Subreddits to exclude, named like `communities`."
        },
        "conversationKeywords": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Reddit only (400 elsewhere). Keywords that place the ad in Reddit conversations about them, as returned by /v1/ads/targeting/search?dimension=conversationKeyword."
        },
        "excludedConversationKeywords": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "description": "Reddit only (400 elsewhere). Conversation keywords to keep the ad away from."
        }
      }
    }
  }
}