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

# 建立推廣委派

> 讓您帳戶中的某個個人檔案（付款方）以其廣告帳戶推廣其他個人檔案的貼文。請使用 Primary Profile 的 API Key 傳送請求。

推廣委派可讓您帳戶中的某個個人檔案（即付款方）推廣您帳戶中其他個人檔案所發布的貼文。付款方是以其廣告帳戶支付廣告費用的個人檔案。

委派需使用您 Primary Profile（主要個人檔案）的 API Key 進行管理。傳送請求時請勿附帶 `Profile-Key`。

## 請求頭參數

**Authorization** `string` *required*

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

Format: `Authorization: Bearer API_KEY`

## 請求體參數

**owners** `array | string` *required*

付款方可推廣其貼文的 User Profile（使用者個人檔案）。可以是最多 1,000 個包含 `refId` 的物件清單，或是 `"all"`，代表您帳戶中目前除付款方以外的所有 User Profile。您的 Primary Profile 不能作為擁有者。

1,000 的上限同樣適用於 `"all"`：若您的帳戶中除付款方以外有超過 1,000 個 User Profile，請求會以 code 101 被拒絕，且不會建立任何項目。請改為在每次請求中以最多 1,000 個個人檔案的清單傳送 `owners`。

`"all"` 不包含您之後建立的個人檔案。若要加入這些個人檔案，請再次傳送請求。

**payer** `object`

負責付款的個人檔案，以包含 `refId` 的物件表示。若省略，則使用您的 Primary Profile。

**platforms** `array` *required*

要委派的廣告平台，例如 `["instagram"]`。僅接受支援[代為推廣](https://www.ayrshare.com/docs/apis/ads/delegations/boost-on-behalf.md)的平台，其他平台會返回 `101`。每個擁有者與平台的組合
都會各自產生一筆委派。

個人檔案以您 [建立個人檔案](https://www.ayrshare.com/docs/apis/profiles/create-profile.md) 或 [取得個人檔案](https://www.ayrshare.com/docs/apis/profiles/get-profiles.md) 時返回的 `refId` 來指定。

每個擁有者與平台的組合都有各自的委派及各自的 `id`。再次傳送請求時，只會建立尚不存在的委派，既有的委派則會原樣返回。唯一的例外是：若擁有者在網路上拒絕了權限，該委派的 `permission` 會恢復為 `unknown`，以便下次推廣時重新請求權限。請在擁有者重新連結帳戶後再傳送請求。若此請求中某個擁有者與平台的委派先前已被撤銷，該委派會以相同的 `id` 重新啟用；該擁有者在其他平台上已撤銷的委派則維持撤銷狀態。

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/delegations \
-d '{"owners": [{"refId": "140b8709bd6ade099b242d895e268fb886130c53"}], "platforms": ["instagram"]}'
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/delegations", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${API_KEY}`
  },
  body: JSON.stringify({
    owners: [{ refId: "140b8709bd6ade099b242d895e268fb886130c53" }],
    platforms: ["instagram"]
  })
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```json 200 theme={"system"}
{
  "status": "success",
  "delegations": [
    {
      "id": "Kx3v9QpL2mZ7tR1wYb4N",
      "owner": { "refId": "140b8709bd6ade099b242d895e268fb886130c53", "title": "Agent One" },
      "payer": { "refId": "9f1c3e7a2b4d", "title": "Agency" },
      "platform": "instagram",
      "permission": "unknown",
      "status": "active"
    }
  ]
}
```

```json 400 theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 400,
  "message": "These owner profiles are not found in this account: 140b8709bd6ade."
}
```


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