> ## 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カスタムオーディエンスを作成し、投稿をブーストするときに含める・除外します。

Redditの広告アカウントにカスタムオーディエンスを作成します。`type`で選べる2種類に対応しています。

<ul>
  <li>`customerList`: 独自の人物リスト。[オーディエンスメンバー](https://www.ayrshare.com/docs/apis/ads/reddit/audience-members.md)からハッシュ化した識別子で追加します。</li>
  <li>`website`: Redditピクセルがサイト上で検出した人。</li>
</ul>

新しいオーディエンスは、[オーディエンス](https://www.ayrshare.com/docs/apis/ads/reddit/get-audiences.md)と同じ形式で`audience`に`status.ready: false`として返されます。Redditはその後、時間をかけてオーディエンスを作成します。一覧表示して`status.ready`が`true`になったことを確認し、[投稿をブースト](https://www.ayrshare.com/docs/apis/ads/reddit/boost-post.md#audiences)するときにその`id`を`targeting.audiences`または`targeting.excludedAudiences`に指定します。

<ul>
  <li>Redditでは、ここでエンゲージメントオーディエンスや類似オーディエンスは作成できません。`type: engagement`または`type: lookalike`を送信すると、`code: 101`付きの`400`が返されます。</li>
  <li>ブーストでターゲットにするには、オーディエンスで1,000人以上がマッチングされている必要があります。</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*

Redditの広告アカウントID。例: `a2_abc123`。

**name** `string` *required*

Reddit Ads Managerに表示される名前。

**type** `string` *required*

`customerList`または`website`。各タイプは以下に示す専用のフィールドのみを受け付けます。別のタイプのフィールドを指定すると、そのフィールド名を示す`code: 101`付きの`400`が返されます。

**idempotencyKey** `string`

新しいオーディエンスごとの新しい一意の値（UUIDなど）。同じキーでリクエストを繰り返すと、Ayrshareは`idempotentReplayed: true`を付けた最初のレスポンスを返し、2つ目のオーディエンスは作成しません。キーは代わりに`Idempotency-Key`ヘッダーで送ることもできます。両方を送る場合は一致させる必要があります。別のリクエストでキーを再利用した場合や、最初のリクエストがまだ処理中の場合は`409`が返されます。`503`はキーを確保できず何も作成されなかったことを意味します。後で同じキーで再試行してください。

### 顧客リストオーディエンス

顧客リストには他の必須フィールドはなく、空の状態で作成されます。[オーディエンスメンバー](https://www.ayrshare.com/docs/apis/ads/reddit/audience-members.md)で人を追加します。ハッシュ化した識別子も個人データです。リストをアップロードする前にそのページを読んでください。

Redditでは、`customerFileSource`は`USER_PROVIDED_ONLY`以外は受け付けません。Redditが受け付けるのは独自のリストのみです。

### ウェブサイトオーディエンス

**pixelId** `string` *required*

RedditのピクセルID。Reddit Ads Events Managerで確認できます。

**retentionDays** `number` *required*

最後の訪問後に訪問者がオーディエンスに残る日数（1〜90）。

**event** `string`

このイベントを発生させた訪問者のみを対象にします。Redditの標準イベントは`PAGE_VISIT`、`VIEW_CONTENT`、`SEARCH`、`ADD_TO_CART`、`ADD_TO_WISHLIST`、`PURCHASE`、`LEAD`、`SIGN_UP`で、大文字・小文字は問いません。それ以外の値はカスタムイベント名として送信されます。省略するとすべての訪問を数えます。

Redditでは`urlContains`は受け付けません。RedditのウェブサイトオーディエンスにはURLフィルターがありません。

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/reddit/audiences \
-d '{"accountId": "a2_abcdefg", "name": "Site visitors 30d", "type": "website", "pixelId": "t2_pixel123", "retentionDays": 30, "event": "purchase"}'
```

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

fetch("https://api.ayrshare.com/api/ads/reddit/audiences", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${API_KEY}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
    "accountId": "a2_abcdefg",
    "name": "Site visitors 30d",
    "type": "website",
    "pixelId": "t2_pixel123",
    "retentionDays": 30,
    "event": "purchase"
  })
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {'Authorization': 'Bearer API_KEY', 'Content-Type': 'application/json'}
payload = {
  "accountId": "a2_abcdefg",
  "name": "Site visitors 30d",
  "type": "website",
  "pixelId": "t2_pixel123",
  "retentionDays": 30,
  "event": "purchase"
}

r = requests.post('https://api.ayrshare.com/api/ads/reddit/audiences', json=payload, headers=headers)

print(r.json())
```

```json 200: Success theme={"system"}
{
  "status": "success",
  "audience": {
    "id": "ca.129482487242999",
    "name": "Site visitors 30d",
    "type": "website",
    "size": null,
    "status": { "ready": false, "code": null, "description": "PENDING" },
    "created": "2026-12-02T10:05:00.000Z"
  }
}
```

```json 400: Lookback over 90 days 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": "retentionDays on reddit is at most 90."
}
```

```json 400: Reddit refused the request 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": "Reddit's reason"
}
```

```json 400: Reddit failed the request theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 369,
  "message": "Unable to create the audience. Please try again.",
  "details": "Reddit's reason"
}
```


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