> ## 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.

# 推廣貼文

> 將 TikTok 影片作為 Spark Ad 推廣。Ayrshare 在您的 TikTok 廣告帳戶建立廣告活動、廣告群組和廣告，套用目標、預算與目標設定。

將 TikTok 影片作為 Spark Ad 推廣。廣告會原樣投放該影片，以其創作者的帳戶名義顯示，影片保留其按讚、留言和追蹤。Ayrshare 會在您的 TikTok 廣告帳戶中建立一個廣告活動、一個廣告群組和一則廣告。

<ul>
  <li>連結 TikTok，然後在儀表板中連接一個 TikTok 廣告帳戶。廣告會從該廣告帳戶投放。</li>
  <li>對於來自您已連結 TikTok 帳戶的影片，您不需要代碼。如果該 TikTok 帳戶在 TikTok 中已連結到您的廣告帳戶，廣告會以該帳戶身分投放。否則，Ayrshare 會為您建立 Spark Ads 代碼。</li>
  <li>對於其他創作者的影片，由創作者在 TikTok 應用程式中產生 Spark Ads 代碼並提供給您。請在 `platformOptions.tiktok.sparkAuthCode` 中傳送該代碼。代碼必須對應您要推廣的影片，否則回應為 `code: 101`。</li>
  <li>預算設定在廣告群組上，使用您廣告帳戶的貨幣。請勿傳送 `budget.currency` 或 `budget.level: "campaign"`。</li>
  <li>最低預算為每天 20（以您廣告帳戶的貨幣計）。總預算為每個排程日至少 20。</li>
  <li>廣告投放期間，影片會保留在創作者的個人檔案上。傳送 `platformOptions.tiktok.adsOnly: true` 可僅將其作為廣告顯示。</li>
  <li>如果您傳送請求的速度超過 TikTok 允許的速度，回應為 `code: 364`，HTTP 狀態碼為 429，`details` 中包含 TikTok 的訊息。請等待一分鐘，然後使用新的 `idempotencyKey` 重試。</li>
  <li>廣告包含在 Premium Plan、Business Plan 和 Enterprise Plan 中，詳見 [Ads 概覽](https://www.ayrshare.com/docs/zh-Hant/apis/ads/overview.md)。使用其他方案時，回應為 `code: 169`。</li>
  <li>如果 TikTok 撤銷了 Ayrshare 對您廣告帳戶的存取權限，回應為 `code: 420`，HTTP 狀態碼為 401，並且 `ads` webhook 會傳送 `accountRevoked`。請在儀表板中重新連接 TikTok 廣告帳戶。</li>
  <li>TikTok 廣告按帳戶開啟。請聯絡我們開啟。</li>
</ul>

### TikTok 支援的內容

| 選項 | TikTok |
| - | - |
| 目標 | `brand_awareness`, `video_views`, `traffic` |
| 預算 | `daily` 或 `lifetime`，設定在廣告群組上 |
| 目標設定 | 國家、地區和城市、年齡層、性別、興趣 |
| 不支援 | `targeting.keywords`、`targeting.audiences`、`targeting.excludedLocations`、`attachTo`、訊息按鈕 |
| 廣告狀態更新 | `ACTIVE`, `PAUSED`, `DELETED` |

### 廣告目標

<ul>
  <li>`brand_awareness`: 向盡可能多的人顯示影片。</li>
  <li>`video_views`: 獲得更多影片觀看次數。</li>
  <li>`traffic`: 將使用者導向您的網站。需要帶有連結的 `callToAction`。</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*

您的 TikTok 廣告帳戶（廣告主）ID，例如 `7100000000000000001`。必須是您已連接的廣告帳戶。

**postId** `string`

要推廣的 Ayrshare 貼文 ID。請傳送 `postId` 或 `socialPostId`。

**socialPostId** `string`

要推廣的 TikTok 影片 ID。

**goal** `string` *required*

[廣告目標](#ad-goals)之一。

**budget** `object` *required*

**子屬性**

**amount** `number` *required*

花費金額，至少 20，最多兩位小數。

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

`daily` 或 `lifetime`。總預算需要 `schedule.end`。

**schedule** `object`

**子屬性**

**start** `string`

廣告開始的 ISO 日期時間。預設為目前時間。

**end** `string`

廣告停止的 ISO 日期時間。省略則廣告會持續投放，直到您暫停。

**targeting** `object` *required*

**子屬性**

**locations** `object` *required*

廣告的顯示位置：在 `countries` 下填寫兩個字母的國家代碼，或在 `regions` 或 `cities` 下填寫來自 `GET /ads/tiktok/regions?search=<term>` 的位置 ID。

```json theme={"system"}
{ "countries": ["US"], "regions": [{ "key": "5332921" }] }
```

**ageMin** `number`

TikTok 某個年齡層的起始值：18、25、35、45 或 55。

**ageMax** `number`

TikTok 某個年齡層的結束值：24、34、44、54，或 65（表示 55 歲以上）。

**genders** `string`

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

**interests** `array`

來自 `GET /ads/tiktok/interests?search=<term>` 的興趣類別 ID。

**callToAction** `object`

`traffic` 目標必填。

**子屬性**

**type** `string` *required*

`LEARN_MORE`、`SHOP_NOW`、`SIGN_UP`、`CONTACT_US`、`APPLY_NOW`、`BOOK_NOW`、`DOWNLOAD_NOW`、`GET_QUOTE`、`ORDER_NOW`、`SUBSCRIBE`、`WATCH_NOW` 或 `READ_MORE`。

**link** `string`

要開啟的頁面。`traffic` 目標必填。

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

`active` 或 `paused`。

**idempotencyKey** `string`

此推廣請求的唯一非空金鑰。使用相同的金鑰重試相同的請求內容，可避免建立重複的廣告：系統會重播第一次的回應，包括錯誤。以不同的請求內容重複使用該金鑰會返回 HTTP 409。該金鑰僅適用於此平台：在其他平台上使用相同的金鑰會啟動一次單獨的推廣。仍在處理中的請求也會返回 409；無法取得保留時會返回 503，且不會建立廣告。

**platformOptions.tiktok** `object`

**子屬性**

**sparkAuthCode** `string`

影片創作者在 TikTok 應用程式中為此影片產生的 Spark Ads 代碼。對於並非來自您已連結 TikTok 帳戶的影片，此項必填。

**adsOnly** `boolean` (default: false)

`true` 表示僅將影片作為廣告顯示，不顯示在創作者的個人檔案上。

```bash cURL theme={"system"}
curl -X POST https://api.ayrshare.com/api/ads/tiktok/boost \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "7100000000000000001",
    "socialPostId": "7400000000000000001",
    "goal": "brand_awareness",
    "budget": { "amount": 20, "type": "daily" },
    "targeting": { "locations": { "countries": ["US"] } },
    "platformOptions": { "tiktok": { "sparkAuthCode": "#AbCdEf123" } }
  }'
```

```json 200: Video Boosted theme={"system"}
{
  "status": "success",
  "id": "1800000000000000003",
  "platform": "tiktok",
  "adStatus": "ACTIVE",
  "budget": { "amount": 20, "type": "daily", "level": "adSet", "currency": "USD" },
  "schedule": { "start": 1792584000000 },
  "platformIds": {
    "campaignId": "1800000000000000001",
    "adGroupId": "1800000000000000002",
    "adId": "1800000000000000003"
  }
}
```

```json 400: Code for another video 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.tiktok.sparkAuthCode is for TikTok video 7400000000000000002, not the boosted post 7400000000000000001."
}
```

```json 400: Budget too small 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": "budget.amount on tiktok is at least 20 in the ad account's currency."
}
```

```json 401: Ad account access removed theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 420,
  "message": "Ads permissions missing for this social account. Please unlink the account and relink it in the social account linking page, granting all ads permissions.",
  "details": "Relink tiktok and grant the ads permissions to use ads on tiktok."
}
```

```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": "Too many requests. Please retry in some time."
}
```


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