> ## 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 公開個人檔案所發布的 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>預算設定在廣告組上，使用您廣告帳戶的貨幣。請勿傳送 `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 限時動態，請單獨傳送 `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.