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

# 创建推广授权

> 允许您账户中的一个 Profile（付款方）用其广告账户推广其他 Profile 的帖子。请使用 Primary Profile 的 API Key 发送请求。

推广授权允许您账户中的一个 Profile（即付款方，payer）推广您账户中其他 Profile 发布的帖子。付款方是由其广告账户为广告付费的 Profile。

推广授权使用 Primary Profile（主 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（用户 Profile）。可以是最多 1,000 个包含 `refId` 的对象列表，也可以是 `"all"`，表示您账户中当前除付款方以外的所有 User Profile。Primary Profile 不能作为所有者（owner）。

1,000 的上限同样适用于 `"all"`：如果您的账户中除付款方以外有超过 1,000 个 User Profile，请求将被拒绝并返回 code 101，且不会创建任何内容。此时请改为分批发送 `owners`，每个请求最多包含 1,000 个 Profile 的列表。

`"all"` 不包括您之后创建的 Profile。如需添加这些 Profile，请再次发送该请求。

**payer** `object`

付费的 Profile，以包含 `refId` 的对象表示。省略此参数则使用您的 Primary Profile。

**platforms** `array` *required*

要授权的广告平台，例如 `["instagram"]`。仅接受支持[代为推广](https://www.ayrshare.com/docs/apis/ads/delegations/boost-on-behalf.md)的平台，其他平台会返回 `101`。每个所有者和平台的组合
各对应一条推广授权。

Profile 通过 `refId` 指定，该值会在您[创建 Profile](https://www.ayrshare.com/docs/apis/profiles/create-profile.md) 或[获取 Profile](https://www.ayrshare.com/docs/apis/profiles/get-profiles.md) 时返回。

每个所有者和平台的组合都有各自的推广授权，并拥有各自的 `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.