> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 推广帖子

> 将 Snapchat Public Profile 的 Snap 推广为广告。Ayrshare 创建广告系列、ad squad 和广告，设置目标、预算与受众。

推广您的 Snapchat 公开个人资料（Public Profile）发布的 Snap。Ayrshare 会将该 Snap 添加到您的广告账户，等待 Snapchat 将其准备就绪，然后在您的 Snapchat 广告账户中创建广告创意、广告活动、广告组（ad squad）和广告。

<ul>
  <li>Snapchat 广告需按账户单独开通。请联系我们以启用该功能。</li>
  <li>关联 Snapchat。该关联已包含广告权限（`snapchat-marketing-api`），因此您无需重新关联。</li>
  <li>如果 Snapchat 不再接受您的关联（例如因为在 Snapchat 中移除了访问权限），所有 Snapchat 广告请求都将返回 `code: 420` 和 HTTP 401。请重新关联 Snapchat 后重试。</li>
  <li>预算设置在广告组（ad squad）上，使用您广告账户的币种。请勿发送 `budget.currency` 或 `budget.level: "campaign"`。</li>
  <li>最低预算为您广告账户币种的 5。</li>
  <li>Snapchat 通常会在几秒内准备好 Snap。如果 45 秒内仍未准备好，将返回 `code: 369`，且不会创建广告，因此不会产生任何花费。请在几分钟后使用新的 `idempotencyKey` 重试。</li>
  <li>如果 Snapchat 完全无法准备好 Snap，也将返回 `code: 369`，并且 `details` 会说明 Snapchat 无法准备该 Snap。重试该 Snap 不会有帮助：请检查它是否仍在您的公开个人资料中，或推广其他 Snap。</li>
  <li>仅支持按国家/地区定位。`targeting.locations.regions`、`targeting.locations.cities`、`targeting.excludedLocations`、`targeting.keywords` 和 `attachTo` 会返回 `code: 101`。</li>
  <li>Snapchat 会审核每个新广告。在获得批准之前，该广告在[已推广广告](https://www.ayrshare.com/docs/apis/ads/snapchat/get-boosted-ads.md)中的 `review.status` 为 `PENDING`。</li>
  <li>如果 Snapchat 未能开启新广告，推广仍会被创建，且响应中会包含 `warning`。通常广告会处于暂停状态（`adStatus` 为 `PAUSED`）：请通过状态更新恢复它。如果 Snapchat 报告该广告正在投放，`adStatus` 为 `ACTIVE`：如果您不希望它上线，请通过状态更新暂停它。在少数情况下，Snapchat 无法确认广告的状态，此时 `adStatus` 为 `UNKNOWN`：请不要恢复它，并携带广告 ID 联系我们。</li>
  <li>如果您发送请求的速度超过 Snapchat 的允许范围，将返回 `code: 364` 和 HTTP 429，并在 `details` 中附带 Snapchat 的消息。请等待一分钟后重试。如果您发送了 `idempotencyKey`，请使用新的键重试：相同的键会重放 `code: 364` 的响应。</li>
</ul>

### 广告目标

<ul>
  <li>`brand_awareness`：向尽可能多的人展示该 Snap。</li>
  <li>`video_views`：获取视频 Snap 的观看次数。</li>
  <li>`traffic`：将用户引导至您的网站。需要带有 `https://` 链接的 `callToAction`。</li>
</ul>

## 定位受众细分

要触达或排除你的 Snapchat 受众细分中的人，请发送 `targeting.audiences` 和 `targeting.excludedAudiences`。两者都是来自[受众](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)的细分 ID 列表：你的客户名单、网站访客和类似受众。可通过[创建受众](https://www.ayrshare.com/docs/apis/ads/snapchat/create-audience.md)或在 Snapchat Ads Manager 中创建它们。

```json theme={"system"}
{
  "accountId": "5a0d1b2c-0000-4000-8000-000000000003",
  "postId": "Ut1fWU6XkqkMayHGnJZ",
  "goal": "brand_awareness",
  "budget": { "amount": 20, "type": "daily" },
  "targeting": {
    "locations": { "countries": ["US"] },
    "audiences": ["8c1e2f3a-0000-4000-8000-000000000101"],
    "excludedAudiences": ["8c1e2f3a-0000-4000-8000-000000000103"]
  }
}
```

<ul>
  <li>广告会触达你定位的国家和年龄范围内同时属于这些细分的人，并且永远不会触达被排除细分中的人。</li>
  <li>每个列表至少包含一个 ID。空列表会返回 `code: 101`：请改为省略该字段。</li>
  <li>Snapchat 只会在细分就绪后定位它，也就是 Snapchat 已匹配到足够多的人时。推广前请在[受众](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)中检查 `status.ready`。</li>
</ul>

## 请求头参数

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## 请求体参数

**accountId** `string` *required*

您的 Snapchat 广告账户 ID，例如 `5a0d0000-0000-4000-8000-000000000003`。

**postId** `string`

要推广的 Ayrshare 帖子 ID。请发送 `postId` 或 `socialPostId`。对于通过 Ayrshare 发布的 Snapchat 快拍（Story），请单独发送 `postId`：即使该快拍包含多个 Snap，Ayrshare 也会推广该帖子添加的 Snap，并且广告会保持与该帖子的关联。单独发送的 `postId` 必须是 Ayrshare 发布到 Snapchat 的帖子，否则推广会失败并返回 `code: 369`。如果同时发送两者，由 `socialPostId` 决定推广哪个 Snap，且 `postId` 必须是您自己的帖子之一，否则推广会失败并返回 `code: 369`。

**socialPostId** `string`

要推广的 Snap 的 ID，即该帖子 Snapchat 结果中的 `mediaId`。您也可以发送该结果中的快拍 `id`：Ayrshare 会推广该快拍中的 Snap。包含多个 Snap 的快拍会返回错误 `101`，因此请改为单独发送该帖子的 `postId`，或发送该 Snap 的 `mediaId`。

**goal** `string` *required*

[广告目标](#ad-goals)之一。

**budget** `object` *required*

**子属性**

**amount** `number` *required*

要花费的金额，至少为 5，最多两位小数。

**type** `string` (default: daily)

`daily` 或 `lifetime`。总预算需要 `schedule.end`。

**schedule** `object`

**子属性**

**start** `string`

广告开始投放的 ISO 日期时间。默认为当前时间。

**end** `string`

广告停止投放的 ISO 日期时间。省略则一直投放，直到您暂停为止。

**targeting** `object` *required*

**子属性**

**locations** `object` *required*

展示广告的位置：在 `countries` 下填写两个字母的国家/地区代码。

```json theme={"system"}
{ "countries": ["US", "GB"] }
```

**ageMin** `number`

从 18 到 35。Snapchat 不支持高于 35 的最小年龄定位，因此 36 及以上会返回 `code: 101`。

**ageMax** `number`

从 18 到 55，或 65 表示无上限。Snapchat 不支持高于 55 的最大年龄定位，因此 56 到 64 会返回 `code: 101`。

**genders** `string`

`all`、`male` 或 `female`。

**interests** `array`

来自 `GET /ads/snapchat/interests?search=<term>` 的兴趣 ID，例如 `SLC_1`。

**audiences** `array`

要触达的受众细分 ID，来自[受众](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)。请参阅[定位受众细分](#audiences)。

**excludedAudiences** `array`

要排除的受众细分 ID，来自[受众](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)。

**callToAction** `object`

`traffic` 目标必填，且仅在该目标下接受。

**子属性**

**type** `string` *required*

Snapchat 的网页视图按钮：`MORE`、`VIEW`、`SHOP_NOW`、`SIGN_UP`、`BOOK_NOW`、`APPLY_NOW`、`ORDER_NOW`、`BUY_TICKETS`、`GET_NOW`、`DOWNLOAD`、`WATCH`、`LISTEN`、`READ`、`PLAY`、`PLAY_GAME`、`TRY`、`DONATE`、`VOTE`、`RESPOND`、`SHOW`、`SHOWTIMES`、`VIEW_MENU` 或 `PRE_REGISTER`。`LEARN_MORE` 会作为 `MORE` 发送，`VIEW_MORE` 会作为 `VIEW` 发送。

**link** `string` *required*

要打开的 `https://` 页面。

**status** `string` (default: active)

`active` 或 `paused`。

**idempotencyKey** `string`

此推广请求的唯一非空键。使用相同的键重试相同的请求体可避免创建重复的广告：会重放首次的响应，包括错误。以不同的请求体或平台重复使用该键会返回 HTTP 409。仍在处理中的请求也会返回 409；预留不可用时会返回 503，且不会创建广告。在出现 `code: 369`（“仍在准备中”）或 `code: 364`（速率限制）之后，请使用新的键重试。

**platformOptions.snapchat** `object`

**子属性**

**placements** `array`

在 Snapchat 上展示广告的位置：`INTERSTITIAL_USER`、`INTERSTITIAL_CONTENT`、`INTERSTITIAL_SPOTLIGHT`、`INSTREAM`、`INSTREAM_SPOTLIGHT`、`PUBLIC_STORIES_INSTREAM` 或 `CHAT_FEED`。省略则由 Snapchat 选择。

* `CHAT_FEED` 需要目标为 `traffic`，并需同时包含 `INTERSTITIAL_USER` 或 `INTERSTITIAL_CONTENT`。
* `INTERSTITIAL_SPOTLIGHT` 需要同时包含另一个位置，并且需要视频 Snap。

**headline** `string`

广告的标题，最多 34 个字符。默认为您的公司名称。

**brandName** `string`

代替您公开个人资料名称显示的名称，最多 32 个字符。

**adName** `string`

广告活动、广告组和广告的名称，最多 375 个字符。默认为您的公司名称、该 Snap 和时间。如果您发送 `idempotencyKey`，默认名称末尾还会附加一个简短的请求标识，同一密钥的标识保持不变。

```bash cURL theme={"system"}
curl -X POST https://api.ayrshare.com/api/ads/snapchat/boost \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "5a0d0000-0000-4000-8000-000000000003",
    "socialPostId": "6f1c2d3e-0000-4000-8000-00000000000a",
    "goal": "brand_awareness",
    "budget": { "amount": 20, "type": "daily" },
    "targeting": { "locations": { "countries": ["US"] } },
    "platformOptions": { "snapchat": { "placements": ["INTERSTITIAL_USER", "INSTREAM"] } }
  }'
```

```json 200: Snap Boosted theme={"system"}
{
  "status": "success",
  "id": "c3a1e2d4-0000-4000-8000-0000000000ad",
  "platform": "snapchat",
  "adStatus": "ACTIVE",
  "budget": { "amount": 20, "type": "daily", "level": "adSet", "currency": "USD" },
  "schedule": { "start": 1791892800000 },
  "platformIds": {
    "mediaId": "b7f0e2d4-0000-4000-8000-0000000000me",
    "creativeId": "a1b2c3d4-0000-4000-8000-0000000000cr",
    "campaignId": "d4c3b2a1-0000-4000-8000-0000000000ca",
    "adSquadId": "e5f6a7b8-0000-4000-8000-0000000000sq",
    "adId": "c3a1e2d4-0000-4000-8000-0000000000ad"
  }
}
```

```json 400: CHAT_FEED alone theme={"system"}
{
  "action": "request",
  "status": "error",
  "code": 101,
  "message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
  "details": "platformOptions.snapchat.placements: CHAT_FEED cannot run alone: add one of INTERSTITIAL_USER, INTERSTITIAL_CONTENT beside it."
}
```

```json 400: Snap not ready theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 369,
  "message": "Unable to boost post. Please try again.",
  "details": "Snapchat is still preparing Snap 6f1c2d3e-0000-4000-8000-00000000000a for ads. No ad was created and nothing spends. Try again in a few minutes with a new idempotency key."
}
```

```json 429: Rate limited theme={"system"}
{
  "action": "rate limit",
  "status": "error",
  "code": 364,
  "message": "You are making too many requests. Please reduce the number of requests.",
  "details": "<Snapchat's own message about the rate limit>"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.