# 准备广告操作

标准 URL： https://sosoapi.ai/zh-hans/docs/api/advertising-api-actions-prepare

契约：sha256:9aedef8d43dd4514

冻结确切 campaign/adset/ad/creative/saved-audience 指令及已审核影响。新建投放从 PAUSED 开始；启用或预算影响需要额外的正式操作权限。

POST /advertising-api/actions/prepare

## 验证与权限

- **接受的凭证类别：** user_session、delegated_oauth、personal_access_token

- **委派能力：** agent:advertising_manage

- **最低工作区角色：** editor

- **访问范围：** 此用户获准访问的资源

- **需要所有工作区同意：** 否

- **更改状态：** 是

- **操作完成时：** synchronous_http_response

令牌只能使用其所有者持有的权利。每次请求会检查工作区成员资格、资源拥有权、所选工作区及已授予能力。core 与 full 配置只变更显示的工具，不会授予访问权限。

## 请求字段

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "advertising_account_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "mutation_id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "command": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "create_campaign"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "budget": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "daily",
                    "lifetime"
                  ]
                },
                "amount_minor": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{0,11}$"
                }
              },
              "required": [
                "kind",
                "amount_minor"
              ],
              "additionalProperties": false
            },
            "objective": {
              "type": "string",
              "enum": [
                "OUTCOME_AWARENESS",
                "OUTCOME_ENGAGEMENT",
                "OUTCOME_LEADS",
                "OUTCOME_SALES",
                "OUTCOME_TRAFFIC",
                "OUTCOME_APP_PROMOTION"
              ]
            },
            "special_ad_categories": {
              "default": [],
              "maxItems": 4,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "CREDIT",
                  "EMPLOYMENT",
                  "HOUSING",
                  "ISSUES_ELECTIONS_POLITICS"
                ]
              }
            },
            "status": {
              "default": "PAUSED",
              "type": "string",
              "const": "PAUSED"
            }
          },
          "required": [
            "operation",
            "name",
            "objective"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "update_campaign"
            },
            "object_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "budget": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "daily",
                    "lifetime"
                  ]
                },
                "amount_minor": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{0,11}$"
                }
              },
              "required": [
                "kind",
                "amount_minor"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string",
              "enum": [
                "ACTIVE",
                "PAUSED",
                "ARCHIVED"
              ]
            }
          },
          "required": [
            "operation",
            "object_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "create_adset"
            },
            "campaign_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "budget": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "daily",
                    "lifetime"
                  ]
                },
                "amount_minor": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{0,11}$"
                }
              },
              "required": [
                "kind",
                "amount_minor"
              ],
              "additionalProperties": false
            },
            "targeting": {
              "type": "object",
              "properties": {
                "geo_locations": {
                  "type": "object",
                  "properties": {
                    "countries": {
                      "minItems": 1,
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[A-Z]{2}$"
                      }
                    }
                  },
                  "required": [
                    "countries"
                  ],
                  "additionalProperties": false
                },
                "age_min": {
                  "default": 18,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "age_max": {
                  "default": 65,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "genders": {
                  "minItems": 1,
                  "maxItems": 2,
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {
                        "type": "number",
                        "const": 1
                      },
                      {
                        "type": "number",
                        "const": 2
                      }
                    ]
                  }
                },
                "locales": {
                  "maxItems": 25,
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "publisher_platforms": {
                  "minItems": 1,
                  "maxItems": 3,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "facebook",
                      "instagram",
                      "threads"
                    ]
                  }
                },
                "facebook_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "feed",
                      "story",
                      "facebook_reels",
                      "video_feeds"
                    ]
                  }
                },
                "instagram_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "stream",
                      "story",
                      "reels",
                      "explore"
                    ]
                  }
                },
                "threads_positions": {
                  "maxItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "const": "threads_stream"
                  }
                },
                "custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                },
                "excluded_custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                }
              },
              "required": [
                "geo_locations",
                "publisher_platforms"
              ],
              "additionalProperties": false
            },
            "billing_event": {
              "type": "string",
              "enum": [
                "IMPRESSIONS",
                "LINK_CLICKS"
              ]
            },
            "optimization_goal": {
              "type": "string",
              "enum": [
                "REACH",
                "IMPRESSIONS",
                "LINK_CLICKS",
                "LANDING_PAGE_VIEWS",
                "OFFSITE_CONVERSIONS",
                "LEAD_GENERATION"
              ]
            },
            "bid_strategy": {
              "default": "LOWEST_COST_WITHOUT_CAP",
              "type": "string",
              "const": "LOWEST_COST_WITHOUT_CAP"
            },
            "start_time": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            "end_time": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            "promoted_object": {
              "type": "object",
              "properties": {
                "page_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "pixel_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "custom_event_type": {
                  "type": "string",
                  "enum": [
                    "PURCHASE",
                    "LEAD",
                    "COMPLETE_REGISTRATION",
                    "ADD_TO_CART"
                  ]
                }
              },
              "additionalProperties": false
            },
            "status": {
              "default": "PAUSED",
              "type": "string",
              "const": "PAUSED"
            }
          },
          "required": [
            "operation",
            "campaign_id",
            "name",
            "targeting",
            "billing_event",
            "optimization_goal"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "update_adset"
            },
            "object_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "budget": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "daily",
                    "lifetime"
                  ]
                },
                "amount_minor": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{0,11}$"
                }
              },
              "required": [
                "kind",
                "amount_minor"
              ],
              "additionalProperties": false
            },
            "status": {
              "type": "string",
              "enum": [
                "ACTIVE",
                "PAUSED",
                "ARCHIVED"
              ]
            },
            "targeting": {
              "type": "object",
              "properties": {
                "geo_locations": {
                  "type": "object",
                  "properties": {
                    "countries": {
                      "minItems": 1,
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[A-Z]{2}$"
                      }
                    }
                  },
                  "required": [
                    "countries"
                  ],
                  "additionalProperties": false
                },
                "age_min": {
                  "default": 18,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "age_max": {
                  "default": 65,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "genders": {
                  "minItems": 1,
                  "maxItems": 2,
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {
                        "type": "number",
                        "const": 1
                      },
                      {
                        "type": "number",
                        "const": 2
                      }
                    ]
                  }
                },
                "locales": {
                  "maxItems": 25,
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "publisher_platforms": {
                  "minItems": 1,
                  "maxItems": 3,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "facebook",
                      "instagram",
                      "threads"
                    ]
                  }
                },
                "facebook_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "feed",
                      "story",
                      "facebook_reels",
                      "video_feeds"
                    ]
                  }
                },
                "instagram_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "stream",
                      "story",
                      "reels",
                      "explore"
                    ]
                  }
                },
                "threads_positions": {
                  "maxItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "const": "threads_stream"
                  }
                },
                "custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                },
                "excluded_custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                }
              },
              "required": [
                "geo_locations",
                "publisher_platforms"
              ],
              "additionalProperties": false
            },
            "start_time": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            "end_time": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            }
          },
          "required": [
            "operation",
            "object_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "create_ad"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "adset_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "creative_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "status": {
              "default": "PAUSED",
              "type": "string",
              "const": "PAUSED"
            }
          },
          "required": [
            "operation",
            "name",
            "adset_id",
            "creative_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "update_ad"
            },
            "object_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "creative_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "status": {
              "type": "string",
              "enum": [
                "ACTIVE",
                "PAUSED",
                "ARCHIVED"
              ]
            }
          },
          "required": [
            "operation",
            "object_id"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "create_creative"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "object_story_spec": {
              "type": "object",
              "properties": {
                "page_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "instagram_user_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "link_data": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "type": "string",
                      "maxLength": 2048,
                      "format": "uri"
                    },
                    "message": {
                      "type": "string",
                      "maxLength": 5000
                    },
                    "name": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "image_hash": {
                      "type": "string",
                      "pattern": "^[a-fA-F0-9]{16,128}$"
                    },
                    "call_to_action": {
                      "type": "string",
                      "enum": [
                        "LEARN_MORE",
                        "SHOP_NOW",
                        "SIGN_UP",
                        "CONTACT_US"
                      ]
                    }
                  },
                  "required": [
                    "link",
                    "message",
                    "image_hash"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "page_id",
                "link_data"
              ],
              "additionalProperties": false
            },
            "object_story_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}_[1-9]\\d{1,24}$"
            }
          },
          "required": [
            "operation",
            "name"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "create_saved_audience"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "targeting": {
              "type": "object",
              "properties": {
                "geo_locations": {
                  "type": "object",
                  "properties": {
                    "countries": {
                      "minItems": 1,
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[A-Z]{2}$"
                      }
                    }
                  },
                  "required": [
                    "countries"
                  ],
                  "additionalProperties": false
                },
                "age_min": {
                  "default": 18,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "age_max": {
                  "default": 65,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "genders": {
                  "minItems": 1,
                  "maxItems": 2,
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {
                        "type": "number",
                        "const": 1
                      },
                      {
                        "type": "number",
                        "const": 2
                      }
                    ]
                  }
                },
                "locales": {
                  "maxItems": 25,
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "publisher_platforms": {
                  "minItems": 1,
                  "maxItems": 3,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "facebook",
                      "instagram",
                      "threads"
                    ]
                  }
                },
                "facebook_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "feed",
                      "story",
                      "facebook_reels",
                      "video_feeds"
                    ]
                  }
                },
                "instagram_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "stream",
                      "story",
                      "reels",
                      "explore"
                    ]
                  }
                },
                "threads_positions": {
                  "maxItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "const": "threads_stream"
                  }
                },
                "custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                },
                "excluded_custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                }
              },
              "required": [
                "geo_locations",
                "publisher_platforms"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "operation",
            "name",
            "targeting"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "operation": {
              "type": "string",
              "const": "update_saved_audience"
            },
            "object_id": {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "targeting": {
              "type": "object",
              "properties": {
                "geo_locations": {
                  "type": "object",
                  "properties": {
                    "countries": {
                      "minItems": 1,
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[A-Z]{2}$"
                      }
                    }
                  },
                  "required": [
                    "countries"
                  ],
                  "additionalProperties": false
                },
                "age_min": {
                  "default": 18,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "age_max": {
                  "default": 65,
                  "type": "integer",
                  "minimum": 18,
                  "maximum": 65
                },
                "genders": {
                  "minItems": 1,
                  "maxItems": 2,
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {
                        "type": "number",
                        "const": 1
                      },
                      {
                        "type": "number",
                        "const": 2
                      }
                    ]
                  }
                },
                "locales": {
                  "maxItems": 25,
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "publisher_platforms": {
                  "minItems": 1,
                  "maxItems": 3,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "facebook",
                      "instagram",
                      "threads"
                    ]
                  }
                },
                "facebook_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "feed",
                      "story",
                      "facebook_reels",
                      "video_feeds"
                    ]
                  }
                },
                "instagram_positions": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "stream",
                      "story",
                      "reels",
                      "explore"
                    ]
                  }
                },
                "threads_positions": {
                  "maxItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "const": "threads_stream"
                  }
                },
                "custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                },
                "excluded_custom_audience_ids": {
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[1-9]\\d{1,24}$"
                  }
                }
              },
              "required": [
                "geo_locations",
                "publisher_platforms"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "operation",
            "object_id"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "required": [
    "workspace_id",
    "advertising_account_id",
    "mutation_id",
    "command"
  ],
  "additionalProperties": false
}
```

## 响应与完成

成功 HTTP 状态：200

成功 HTTP 响应可能表示请求已接受，并非已完成。背景工作请存储返回 ID，持续检查同一操作直到完成。已排程或已接受的帖子，只有平台确认后才算已发布；客户端逾时无法证明结果。

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract_version": {
      "type": "string",
      "const": "advertising/v1"
    },
    "prepare_token": {
      "type": "string",
      "minLength": 32,
      "maxLength": 128
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "action": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "workspace_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "advertising_account_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "mutation_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "status": {
          "type": "string",
          "enum": [
            "prepared",
            "queued",
            "processing",
            "succeeded",
            "failed",
            "unknown",
            "cancelled"
          ]
        },
        "command": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "create_campaign"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "budget": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "daily",
                        "lifetime"
                      ]
                    },
                    "amount_minor": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{0,11}$"
                    }
                  },
                  "required": [
                    "kind",
                    "amount_minor"
                  ]
                },
                "objective": {
                  "type": "string",
                  "enum": [
                    "OUTCOME_AWARENESS",
                    "OUTCOME_ENGAGEMENT",
                    "OUTCOME_LEADS",
                    "OUTCOME_SALES",
                    "OUTCOME_TRAFFIC",
                    "OUTCOME_APP_PROMOTION"
                  ]
                },
                "special_ad_categories": {
                  "default": [],
                  "maxItems": 4,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "enum": [
                      "CREDIT",
                      "EMPLOYMENT",
                      "HOUSING",
                      "ISSUES_ELECTIONS_POLITICS"
                    ]
                  }
                },
                "status": {
                  "default": "PAUSED",
                  "type": "string",
                  "const": "PAUSED"
                }
              },
              "required": [
                "operation",
                "name",
                "objective",
                "special_ad_categories",
                "status"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "update_campaign"
                },
                "object_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "budget": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "daily",
                        "lifetime"
                      ]
                    },
                    "amount_minor": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{0,11}$"
                    }
                  },
                  "required": [
                    "kind",
                    "amount_minor"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ACTIVE",
                    "PAUSED",
                    "ARCHIVED"
                  ]
                }
              },
              "required": [
                "operation",
                "object_id"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "create_adset"
                },
                "campaign_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "budget": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "daily",
                        "lifetime"
                      ]
                    },
                    "amount_minor": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{0,11}$"
                    }
                  },
                  "required": [
                    "kind",
                    "amount_minor"
                  ]
                },
                "targeting": {
                  "type": "object",
                  "properties": {
                    "geo_locations": {
                      "type": "object",
                      "properties": {
                        "countries": {
                          "minItems": 1,
                          "maxItems": 25,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[A-Z]{2}$"
                          }
                        }
                      },
                      "required": [
                        "countries"
                      ]
                    },
                    "age_min": {
                      "default": 18,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "age_max": {
                      "default": 65,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "genders": {
                      "minItems": 1,
                      "maxItems": 2,
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "number",
                            "const": 1
                          },
                          {
                            "type": "number",
                            "const": 2
                          }
                        ]
                      }
                    },
                    "locales": {
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "publisher_platforms": {
                      "minItems": 1,
                      "maxItems": 3,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "facebook",
                          "instagram",
                          "threads"
                        ]
                      }
                    },
                    "facebook_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "feed",
                          "story",
                          "facebook_reels",
                          "video_feeds"
                        ]
                      }
                    },
                    "instagram_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "stream",
                          "story",
                          "reels",
                          "explore"
                        ]
                      }
                    },
                    "threads_positions": {
                      "maxItems": 1,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "const": "threads_stream"
                      }
                    },
                    "custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    },
                    "excluded_custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    }
                  },
                  "required": [
                    "geo_locations",
                    "age_min",
                    "age_max",
                    "publisher_platforms"
                  ]
                },
                "billing_event": {
                  "type": "string",
                  "enum": [
                    "IMPRESSIONS",
                    "LINK_CLICKS"
                  ]
                },
                "optimization_goal": {
                  "type": "string",
                  "enum": [
                    "REACH",
                    "IMPRESSIONS",
                    "LINK_CLICKS",
                    "LANDING_PAGE_VIEWS",
                    "OFFSITE_CONVERSIONS",
                    "LEAD_GENERATION"
                  ]
                },
                "bid_strategy": {
                  "default": "LOWEST_COST_WITHOUT_CAP",
                  "type": "string",
                  "const": "LOWEST_COST_WITHOUT_CAP"
                },
                "start_time": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                },
                "end_time": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                },
                "promoted_object": {
                  "type": "object",
                  "properties": {
                    "page_id": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{1,24}$"
                    },
                    "pixel_id": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{1,24}$"
                    },
                    "custom_event_type": {
                      "type": "string",
                      "enum": [
                        "PURCHASE",
                        "LEAD",
                        "COMPLETE_REGISTRATION",
                        "ADD_TO_CART"
                      ]
                    }
                  }
                },
                "status": {
                  "default": "PAUSED",
                  "type": "string",
                  "const": "PAUSED"
                }
              },
              "required": [
                "operation",
                "campaign_id",
                "name",
                "targeting",
                "billing_event",
                "optimization_goal",
                "bid_strategy",
                "status"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "update_adset"
                },
                "object_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "budget": {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "daily",
                        "lifetime"
                      ]
                    },
                    "amount_minor": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{0,11}$"
                    }
                  },
                  "required": [
                    "kind",
                    "amount_minor"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ACTIVE",
                    "PAUSED",
                    "ARCHIVED"
                  ]
                },
                "targeting": {
                  "type": "object",
                  "properties": {
                    "geo_locations": {
                      "type": "object",
                      "properties": {
                        "countries": {
                          "minItems": 1,
                          "maxItems": 25,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[A-Z]{2}$"
                          }
                        }
                      },
                      "required": [
                        "countries"
                      ]
                    },
                    "age_min": {
                      "default": 18,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "age_max": {
                      "default": 65,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "genders": {
                      "minItems": 1,
                      "maxItems": 2,
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "number",
                            "const": 1
                          },
                          {
                            "type": "number",
                            "const": 2
                          }
                        ]
                      }
                    },
                    "locales": {
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "publisher_platforms": {
                      "minItems": 1,
                      "maxItems": 3,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "facebook",
                          "instagram",
                          "threads"
                        ]
                      }
                    },
                    "facebook_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "feed",
                          "story",
                          "facebook_reels",
                          "video_feeds"
                        ]
                      }
                    },
                    "instagram_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "stream",
                          "story",
                          "reels",
                          "explore"
                        ]
                      }
                    },
                    "threads_positions": {
                      "maxItems": 1,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "const": "threads_stream"
                      }
                    },
                    "custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    },
                    "excluded_custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    }
                  },
                  "required": [
                    "geo_locations",
                    "age_min",
                    "age_max",
                    "publisher_platforms"
                  ]
                },
                "start_time": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                },
                "end_time": {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                }
              },
              "required": [
                "operation",
                "object_id"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "create_ad"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "adset_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "creative_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "status": {
                  "default": "PAUSED",
                  "type": "string",
                  "const": "PAUSED"
                }
              },
              "required": [
                "operation",
                "name",
                "adset_id",
                "creative_id",
                "status"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "update_ad"
                },
                "object_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "creative_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ACTIVE",
                    "PAUSED",
                    "ARCHIVED"
                  ]
                }
              },
              "required": [
                "operation",
                "object_id"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "create_creative"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "object_story_spec": {
                  "type": "object",
                  "properties": {
                    "page_id": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{1,24}$"
                    },
                    "instagram_user_id": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{1,24}$"
                    },
                    "link_data": {
                      "type": "object",
                      "properties": {
                        "link": {
                          "type": "string",
                          "maxLength": 2048,
                          "format": "uri"
                        },
                        "message": {
                          "type": "string",
                          "maxLength": 5000
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "image_hash": {
                          "type": "string",
                          "pattern": "^[a-fA-F0-9]{16,128}$"
                        },
                        "call_to_action": {
                          "type": "string",
                          "enum": [
                            "LEARN_MORE",
                            "SHOP_NOW",
                            "SIGN_UP",
                            "CONTACT_US"
                          ]
                        }
                      },
                      "required": [
                        "link",
                        "message",
                        "image_hash"
                      ]
                    }
                  },
                  "required": [
                    "page_id",
                    "link_data"
                  ]
                },
                "object_story_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}_[1-9]\\d{1,24}$"
                }
              },
              "required": [
                "operation",
                "name"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "create_saved_audience"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "targeting": {
                  "type": "object",
                  "properties": {
                    "geo_locations": {
                      "type": "object",
                      "properties": {
                        "countries": {
                          "minItems": 1,
                          "maxItems": 25,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[A-Z]{2}$"
                          }
                        }
                      },
                      "required": [
                        "countries"
                      ]
                    },
                    "age_min": {
                      "default": 18,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "age_max": {
                      "default": 65,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "genders": {
                      "minItems": 1,
                      "maxItems": 2,
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "number",
                            "const": 1
                          },
                          {
                            "type": "number",
                            "const": 2
                          }
                        ]
                      }
                    },
                    "locales": {
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "publisher_platforms": {
                      "minItems": 1,
                      "maxItems": 3,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "facebook",
                          "instagram",
                          "threads"
                        ]
                      }
                    },
                    "facebook_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "feed",
                          "story",
                          "facebook_reels",
                          "video_feeds"
                        ]
                      }
                    },
                    "instagram_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "stream",
                          "story",
                          "reels",
                          "explore"
                        ]
                      }
                    },
                    "threads_positions": {
                      "maxItems": 1,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "const": "threads_stream"
                      }
                    },
                    "custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    },
                    "excluded_custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    }
                  },
                  "required": [
                    "geo_locations",
                    "age_min",
                    "age_max",
                    "publisher_platforms"
                  ]
                }
              },
              "required": [
                "operation",
                "name",
                "targeting"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "const": "update_saved_audience"
                },
                "object_id": {
                  "type": "string",
                  "pattern": "^[1-9]\\d{1,24}$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200
                },
                "targeting": {
                  "type": "object",
                  "properties": {
                    "geo_locations": {
                      "type": "object",
                      "properties": {
                        "countries": {
                          "minItems": 1,
                          "maxItems": 25,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^[A-Z]{2}$"
                          }
                        }
                      },
                      "required": [
                        "countries"
                      ]
                    },
                    "age_min": {
                      "default": 18,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "age_max": {
                      "default": 65,
                      "type": "integer",
                      "minimum": 18,
                      "maximum": 65
                    },
                    "genders": {
                      "minItems": 1,
                      "maxItems": 2,
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "number",
                            "const": 1
                          },
                          {
                            "type": "number",
                            "const": 2
                          }
                        ]
                      }
                    },
                    "locales": {
                      "maxItems": 25,
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "publisher_platforms": {
                      "minItems": 1,
                      "maxItems": 3,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "facebook",
                          "instagram",
                          "threads"
                        ]
                      }
                    },
                    "facebook_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "feed",
                          "story",
                          "facebook_reels",
                          "video_feeds"
                        ]
                      }
                    },
                    "instagram_positions": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "stream",
                          "story",
                          "reels",
                          "explore"
                        ]
                      }
                    },
                    "threads_positions": {
                      "maxItems": 1,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "const": "threads_stream"
                      }
                    },
                    "custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    },
                    "excluded_custom_audience_ids": {
                      "maxItems": 4,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "pattern": "^[1-9]\\d{1,24}$"
                      }
                    }
                  },
                  "required": [
                    "geo_locations",
                    "age_min",
                    "age_max",
                    "publisher_platforms"
                  ]
                }
              },
              "required": [
                "operation",
                "object_id"
              ]
            }
          ]
        },
        "reviewed_digest": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "effects": {
          "type": "object",
          "properties": {
            "creates_object": {
              "type": "boolean"
            },
            "initial_status": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "PAUSED"
                },
                {
                  "type": "null"
                }
              ]
            },
            "activates_delivery": {
              "type": "boolean"
            },
            "changes_budget": {
              "type": "boolean"
            },
            "changes_audience": {
              "type": "boolean"
            },
            "changes_creative": {
              "type": "boolean"
            },
            "currency": {
              "type": "string",
              "pattern": "^[A-Z]{3}$"
            },
            "timezone": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "budget": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "daily",
                        "lifetime"
                      ]
                    },
                    "amount_minor": {
                      "type": "string",
                      "pattern": "^[1-9]\\d{0,11}$"
                    }
                  },
                  "required": [
                    "kind",
                    "amount_minor"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "creates_object",
            "initial_status",
            "activates_delivery",
            "changes_budget",
            "changes_audience",
            "changes_creative",
            "currency",
            "timezone",
            "budget"
          ]
        },
        "live_approval": {
          "type": "object",
          "properties": {
            "required": {
              "type": "boolean"
            },
            "state": {
              "type": "string",
              "enum": [
                "not_required",
                "missing",
                "approved",
                "expired",
                "revoked",
                "invalid"
              ]
            },
            "reason": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ]
            },
            "expires_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "approved_by": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "required",
            "state",
            "reason",
            "expires_at",
            "approved_by"
          ]
        },
        "provider_object_id": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^[1-9]\\d{1,24}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "failure_code": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 100
            },
            {
              "type": "null"
            }
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "completed_at": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "workspace_id",
        "advertising_account_id",
        "mutation_id",
        "status",
        "command",
        "reviewed_digest",
        "effects",
        "live_approval",
        "provider_object_id",
        "failure_code",
        "created_at",
        "completed_at"
      ]
    }
  },
  "required": [
    "contract_version",
    "prepare_token",
    "expires_at",
    "action"
  ]
}
```

## 错误与安全重试

检查 HTTP 状态和响应正文。400 验证错误可能包含 ZodError；处理程序错误使用 error、message 和 code 字段。保留 request_id 或 x-request-id 以便诊断，但不要保留凭证。先解决 401/403 访问错误再重试，并在收到 429 时遵循 Retry-After。如写入结果不确定或返回 5xx，先读取现有结果。仅在支持时复用幂等键；重试行为因操作而异，并不保证恰好交付一次。

## 示例

这些示例使用已依schema检查的虚构值。请将 ID 替换为你有权使用的 ID、将媒体替换为已就绪素材，并将日期替换为已确认的发布时间。提交写入前，请检查账号资格。本页不会发送 API 请求。

在服务器上将 SOSOAPI_ACCESS_TOKEN 设为此操作接受的凭证，且不要放入浏览器代码。AI 智能代理 请使用 sosoapi auth login 通过浏览器登录，并由 CLI 更新凭证。

request.json

```json
{
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "advertising_account_id": "11111111-1111-4111-8111-111111111111",
  "mutation_id": "11111111-1111-4111-8111-111111111111",
  "command": {
    "operation": "create_campaign",
    "name": "example",
    "objective": "OUTCOME_AWARENESS"
  }
}
```

cURL

```bash
curl --request POST \
  "https://gqeshlawtcexsapabaui.supabase.co/functions/v1/advertising-api/actions/prepare" \
  -H "Authorization: Bearer $SOSOAPI_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @request.json
```

JavaScript

```js
// Server-side JavaScript. Do not print tokens or credential-bearing responses.
const token = process.env.SOSOAPI_ACCESS_TOKEN;
if (!token) throw new Error("Set an accepted credential for this operation");
const response = await fetch("https://gqeshlawtcexsapabaui.supabase.co/functions/v1/advertising-api/actions/prepare", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer " + token },
  body: JSON.stringify({
  "workspace_id": "11111111-1111-4111-8111-111111111111",
  "advertising_account_id": "11111111-1111-4111-8111-111111111111",
  "mutation_id": "11111111-1111-4111-8111-111111111111",
  "command": {
    "operation": "create_campaign",
    "name": "example",
    "objective": "OUTCOME_AWARENESS"
  }
})
});
const result = await response.json();
// Check response.ok, the operation-specific body and completion state before continuing.
```

CLI

```bash
npx sosoapi api post /advertising-api/actions/prepare < request.json
```

合成响应示例

```json
{
  "contract_version": "advertising/v1",
  "prepare_token": "exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
  "expires_at": "2099-01-15T09:00:00Z",
  "action": {
    "id": "11111111-1111-4111-8111-111111111111",
    "workspace_id": "11111111-1111-4111-8111-111111111111",
    "advertising_account_id": "11111111-1111-4111-8111-111111111111",
    "mutation_id": "11111111-1111-4111-8111-111111111111",
    "status": "prepared",
    "command": {
      "operation": "create_campaign",
      "name": "example",
      "objective": "OUTCOME_AWARENESS",
      "special_ad_categories": [],
      "status": "PAUSED"
    },
    "reviewed_digest": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "effects": {
      "creates_object": false,
      "initial_status": null,
      "activates_delivery": false,
      "changes_budget": false,
      "changes_audience": false,
      "changes_creative": false,
      "currency": "USD",
      "timezone": "UTC",
      "budget": null
    },
    "live_approval": {
      "required": false,
      "state": "not_required",
      "reason": null,
      "expires_at": null,
      "approved_by": null
    },
    "provider_object_id": null,
    "failure_code": null,
    "created_at": "2099-01-15T09:00:00Z",
    "completed_at": null
  }
}
```

## 相关工具与指南

MCP: sosoapi_ads_actions_prepare

[API 参考](https://sosoapi.ai/zh-hans/docs/api)
