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

# 推廣貼文

> 將 Reddit 社群貼文作為推廣貼文推廣。Ayrshare 建立廣告活動、廣告群組和廣告，並設定廣告目標、預算和自訂受眾鎖定。

推廣一則現有的 Reddit 貼文。Ayrshare 會在您的 Reddit 廣告帳戶中建立一個活動、一個廣告群組以及一個推廣您貼文的廣告。

### 限制

<ul>
  <li>Reddit 廣告需按帳戶個別開通。請聯絡我們以啟用此功能。</li>
  <li>**僅限社群貼文。** 您可以推廣社群（subreddit）中的貼文。您個人檔案（`r/u_<username>`）上的貼文無法推廣，並會返回 `code: 101`。</li>
  <li>**必須提供轉換像素。** 無論目標為何，Reddit 都不會在沒有轉換像素的情況下投放任何廣告。請在 `platformOptions.reddit.pixelId` 中發送您的像素 ID，否則推廣會返回 `code: 101`。您可以在 Reddit Ads Events Manager 中找到它。</li>
</ul>

<ul>
  <li>請連結 Reddit 並授予廣告權限（`adsread`、`adsedit`、`adsconversions`）。如果尚未連結 Reddit，將返回 `code: 156`。如果缺少廣告權限，或 Reddit 不再接受該連結，將返回 `code: 420`：請重新連結 Reddit 並授予這些權限。</li>
  <li>預算使用您廣告帳戶的幣別。請勿發送 `budget.currency`：發送它會返回 `code: 101`。</li>
  <li>預算設定在廣告群組層級。`budget.level: "campaign"` 會返回 `code: 101`。</li>
  <li>您的廣告帳戶需要一個付款工具。如果沒有，推廣會返回 `code: 101`：請在 Reddit Ads 中新增付款方式。如果有多個，請在 `platformOptions.reddit.fundingInstrumentId` 中指定。</li>
  <li>Reddit 不接受 `callToAction`、`attachTo`、`targeting.excludedLocations`、年齡目標設定、`targeting.locations.regions` 和 `targeting.locations.cities`。發送這些參數會返回 `code: 101`。</li>
  <li>Reddit 會審核每則新廣告。在獲得核准之前，廣告會顯示為 `review.status: "PENDING_APPROVAL"`。</li>
  <li>如果 Reddit 未能啟用新廣告，推廣仍會被建立，且回應中會包含 `warning`。廣告通常處於暫停狀態（`adStatus: "PAUSED"`），請透過[狀態更新](https://www.ayrshare.com/docs/apis/ads/reddit/put-ad-update.md)來恢復投放。如果 Reddit 無法確認廣告已暫停，回應會顯示 `adStatus: "ACTIVE"`，並警告廣告可能正在投放並產生花費。請檢查廣告，必要時透過狀態更新將其暫停。</li>
  <li>如果將狀態更新為 `active` 失敗，且 Reddit 無法確認廣告已重新停止，錯誤中會包含 `warning`，提示廣告可能正在投放並產生花費，廣告會顯示 `adStatus: "ACTIVE"`。請檢查廣告，必要時透過狀態更新將其暫停。</li>
  <li>如果您發送請求的速度超過 Reddit 允許的上限，將返回 `code: 364` 及 HTTP 429。`details` 中會附上 Reddit 的訊息，若 Reddit 有提供，也會註明需等待幾秒後才能重試。</li>
  <li>洞察數據以您廣告帳戶的幣別顯示花費。僅當該幣別為 USD 時才會設定 `spendUsd`，否則為 `null`。</li>
</ul>

### 廣告目標

<ul>
  <li>`brand_awareness`：將貼文展示給盡可能多的人。</li>
  <li>`website_visits`：獲取前往您網站的點擊。</li>
  <li>`leads`：獲取由您的像素追蹤的註冊或潛在客戶。</li>
  <li>`sales`：獲取由您的像素追蹤的購買。</li>
</ul>

## 鎖定自訂受眾

若要觸及或排除您 Reddit 自訂受眾中的人，請傳送 `targeting.audiences` 和 `targeting.excludedAudiences`。兩者都是來自[受眾](https://www.ayrshare.com/docs/apis/ads/reddit/get-audiences.md)的受眾 ID 清單：您的顧客名單、網站訪客，以及廣告帳戶上的任何其他受眾。您可以透過[建立受眾](https://www.ayrshare.com/docs/apis/ads/reddit/create-audience.md)或在 Reddit Ads Manager 中建立受眾。

```json theme={"system"}
{
  "accountId": "a2_abc123",
  "socialPostId": "1abc27",
  "goal": "website_visits",
  "budget": { "amount": 20, "type": "daily" },
  "targeting": {
    "locations": { "countries": ["US"] },
    "audiences": ["ca.129482487242828"],
    "excludedAudiences": ["ca.129482487242999"]
  },
  "platformOptions": { "reddit": { "pixelId": "t2_pixel123" } }
}
```

<ul>
  <li>`targeting.audiences`：廣告會在您設定的其他目標設定範圍內，觸及屬於這些受眾中任一受眾的人。</li>
  <li>`targeting.excludedAudiences`：屬於這些受眾中任一受眾的人永遠不會看到該廣告。</li>
  <li>仍在填充中的受眾（`status.ready: false`）在 Reddit 比對到至少 1,000 人之前可能無法投放。</li>
  <li>`targeting.locations` 仍為必填。</li>
  <li>每個清單至少需要一個 ID；若沒有 ID，請省略該欄位，而不要傳送空清單。空清單或不是 Reddit 受眾 ID 的 ID，會在建立任何內容之前返回帶有 `code: 101` 的 `400`。</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`

## 請求體參數

**idempotencyKey** `string`

此推廣請求的唯一非空鍵。使用相同的鍵重試相同的負載，可避免建立重複的廣告。以不同的負載重用該鍵會返回 HTTP 409。該鍵僅適用於此平台：在其他平台上使用相同的鍵會建立一個獨立的推廣。仍在處理中的請求同樣會返回 409；預留不可用時會返回 503，且不會建立廣告。

**accountId** `string` *required*

您的 Reddit 廣告帳戶 ID，例如 `a2_abc123`。

**postId** `string`

要推廣的 Ayrshare 貼文 ID。請發送 `postId` 或 `socialPostId`。如果同時傳送兩者，`postId` 必須是您自己的貼文之一，否則推廣會失敗並回傳 `code: 369`。

**socialPostId** `string`

Reddit 貼文 ID，可包含或不包含 `t3_`，例如 `1abc27`。該貼文必須位於社群中。Reddit 無法識別的 ID 會返回 `code: 369`。

**goal** `string` *required*

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

**budget** `object` *required*

**子屬性**

**amount** `number` *required*

花費金額，最多保留兩位小數。

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

`daily` 或 `lifetime`。總預算（lifetime）需要設定 `schedule.end`。

**schedule** `object`

**子屬性**

**start** `string`

廣告開始投放的 ISO 日期時間。預設為目前時間。若開始時間已過，廣告會立即開始投放。

**end** `string`

廣告停止投放的 ISO 日期時間。若不設定，廣告將持續投放，直到您將其暫停。它必須晚於 `start`。兩個日期都不能超過 10 年之後。違反任一規則會返回 `code: 101`。

**targeting** `object` *required*

**子屬性**

**locations** `object` *required*

廣告的展示地點：在 `countries` 下至少填入一個大寫的兩個字母國家代碼。小寫代碼（例如 `"us"`）會返回 `code: 101`。

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

**genders** `string`

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

**interests** `array`

來自[興趣](https://www.ayrshare.com/docs/apis/ads/reddit/get-ad-interests.md)的興趣 ID。

**keywords** `array`

要展示廣告的搜尋字詞，每個最多 100 個字元。

**audiences** `array`

要觸及的自訂受眾 ID，來自[受眾](https://www.ayrshare.com/docs/apis/ads/reddit/get-audiences.md)，至少一個。請參閱[鎖定自訂受眾](#audiences)。

**excludedAudiences** `array`

其中的人永遠不會看到該廣告的自訂受眾 ID，至少一個。請參閱[鎖定自訂受眾](#audiences)。

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

`active` 或 `paused`。

**platformOptions.reddit** `object` *required*

**子屬性**

**pixelId** `string` *required*

您的 Reddit 轉換像素 ID。

**fundingInstrumentId** `string`

支付廣告費用的付款工具。當您的廣告帳戶有多個付款工具時為必填。

**communities** `array`

要展示廣告的社群，以不含 `r/` 的名稱表示，例如 `["gardening"]`。每個名稱由 2 到 21 個字母、數字或底線組成。若不需要，請省略此欄位，而不要傳送空清單。

**adName** `string`

活動、廣告群組和廣告的名稱，最多 255 個字元。預設由您的公司名稱、貼文和時間組成。如果您傳送 `idempotencyKey`，預設名稱結尾還會附加一個簡短的請求識別碼，同一金鑰的識別碼保持不變。

```bash cURL theme={"system"}
curl -X POST https://api.ayrshare.com/api/ads/reddit/boost \
  -H "Authorization: Bearer API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "accountId": "a2_abc123",
    "socialPostId": "1abc27",
    "goal": "website_visits",
    "budget": { "amount": 50, "type": "daily" },
    "targeting": { "locations": { "countries": ["US"] } },
    "platformOptions": { "reddit": { "pixelId": "YOUR_PIXEL_ID" } }
  }'
```

```json 200: Post Boosted theme={"system"}
{
  "status": "success",
  "id": "2707300000000000001",
  "platform": "reddit",
  "adStatus": "ACTIVE",
  "budget": { "amount": 50, "type": "daily", "level": "adSet", "currency": "USD" },
  "schedule": { "start": 1791892800000 },
  "platformIds": {
    "campaignId": "2707100000000000001",
    "adGroupId": "2707200000000000001",
    "adId": "2707300000000000001"
  }
}
```

```json 400: No pixel 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.reddit.pixelId is required on reddit: Reddit runs no ad without a conversion pixel. Find it in Reddit Ads Events Manager."
}
```

```json 400: Profile post 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": "Post 1abc27 is on a Reddit profile (r/u_example). reddit boosts posts in communities only."
}
```

```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 Retry in 30 seconds."
}
```


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