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

# オーディエンスを作成

> 顧客リスト、ウェブサイト、類似の Snapchat セグメントを作成し、Ayrshare で Snap をブーストする際に含める・除外します。

Snapchat 広告アカウントにオーディエンスセグメントを作成します。`type` で選ぶ 3 種類に対応しています:

<ul>
  <li>`customerList`: 独自の人のリスト。[オーディエンスメンバー](https://www.ayrshare.com/docs/apis/ads/snapchat/audience-members.md)でハッシュ化した識別子を追加して作成します。</li>
  <li>`website`: Snap Pixel があなたのサイトでイベントを 1 つ検出した人。</li>
  <li>`lookalike`: 指定した国にいる、あなたの顧客リストのいずれかにいる人と似た人。</li>
</ul>

新しいセグメントは、[オーディエンス](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)と同じ形式で `audience` に `status.ready: false` の状態で返されます。Snapchat が時間をかけて蓄積します。一覧表示して `status.ready` が `true` になったことを確認してから、[Snap をブースト](https://www.ayrshare.com/docs/apis/ads/snapchat/boost-post.md#audiences)するときにその `id` を `targeting.audiences` または `targeting.excludedAudiences` で使用します。

<ul>
  <li>Snapchat が十分な人を照合すると、ブーストでセグメントをターゲットにできます。それまでは `status.ready` は `false` です。</li>
  <li>1 つの広告アカウントに置ける顧客リストは最大 1,000 件、セグメント名は最大 375 文字です。それを超えると Snapchat は `code: 369` で拒否します。</li>
  <li>Snapchat ではここでエンゲージメントオーディエンスを作成できません。`type: engagement` は `code: 101` 付きの `400` を返します。</li>
  <li>再試行する可能性がある場合は `idempotencyKey` を送ってください: 同じキーと同じボディで再試行すると、2 つ目のセグメントを作成せずに最初のレスポンスが返されます。</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*

セグメントを作成する Snapchat 広告アカウントの ID。例: `5a0d0000-0000-4000-8000-000000000003`。

**name** `string` *required*

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

**type** `string` *required*

`customerList`、`website`、`lookalike` のいずれか。その他のフィールドはこれによって決まります。

**idempotencyKey** `string`

新しいセグメントごとの一意の値 (UUID など)。

### 顧客リスト

その他のフィールドはありません。リストは空の状態で始まり、削除するまで人を保持します。`customerFileSource` は省略可能です: Snapchat のリストには独自のデータのみが含まれるため、`USER_PROVIDED_ONLY` 以外の値は `code: 101` を返します。

### ウェブサイト

**pixelId** `string` *required*

Snap Pixel の ID。

**event** `string` *required*

訪問者が発生させている必要があるピクセルイベント。Snapchat の表記どおりに指定します: `PAGE_VIEW`、`VIEW_CONTENT`、`ADD_CART`、`START_CHECKOUT`、`PURCHASE`、`SIGN_UP`、`SUBSCRIBE`、`SEARCH`、`ADD_TO_WISHLIST`、`CUSTOM_EVENT_1` から `CUSTOM_EVENT_5`、またはその他の [Snapchat ピクセルイベント](https://developers.snap.com/marketing-api/Ads-API/audience-creation/website-events)。Snapchat では必須です。

**retentionDays** `number` *required*

訪問者がセグメントに留まる日数。1 から 180 まで。

`urlContains` は Snapchat ではサポートされていません: Snapchat のウェブサイトセグメントはピクセルイベントのみで人を保持するため、`code: 101` を返します。

### 類似オーディエンス (lookalike)

**seedAudienceId** `string` *required*

似た人を探す元となる顧客リスト ([オーディエンス](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)の `type: customerList`)。Snapchat は顧客リストからのみ類似オーディエンスを作成するため、この広告アカウント上のあなたの顧客リストでないシード (別の種類のセグメント、別のアカウントのセグメント、削除済みのセグメント) は `code: 101` を返します。

**countries** `array` *required*

人を探す国。`US` のような 2 文字のコードで指定します。各国は 1 回だけ指定します。

**similarity** `string`

`balance` (デフォルト) は類似度と規模のバランスを取り、`similarity` はシードに最も似た人を残し、`reach` は最も多くの人を見つけます。

**retentionDays** `number`

人がセグメントに留まる日数。1 から 180 まで。デフォルトは 180 です。

Snapchat の類似オーディエンスにはサイズの割合がありません: `ratio` と `allowInternationalSeeds` は `code: 101` を返します。

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "type": "lookalike", "name": "Like my subscribers", "seedAudienceId": "8c1e2f3a-0000-4000-8000-000000000101", "countries": ["US", "GB"], "similarity": "balance"}'
```

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

fetch("https://api.ayrshare.com/api/ads/snapchat/audiences", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${API_KEY}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        accountId: "5a0d1b2c-0000-4000-8000-000000000003",
        type: "lookalike",
        name: "Like my subscribers",
        seedAudienceId: "8c1e2f3a-0000-4000-8000-000000000101",
        countries: ["US", "GB"],
        similarity: "balance"
      })
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);
```

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

payload = {
    'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
    'type': 'lookalike',
    'name': 'Like my subscribers',
    'seedAudienceId': '8c1e2f3a-0000-4000-8000-000000000101',
    'countries': ['US', 'GB'],
    'similarity': 'balance'
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}

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

print(r.json())
```

```json 200: Success theme={"system"}
{
  "status": "success",
  "audience": {
    "id": "8c1e2f3a-0000-4000-8000-000000000102",
    "name": "Like my subscribers",
    "type": "lookalike",
    "size": { "lower": 0, "upper": 0 },
    "status": { "ready": false, "code": null, "description": "NOT_READY" },
    "created": "2026-12-02T12:00:00.000Z"
  }
}
```

```json 400: A field Snapchat does not take 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": "ratio is not a recognised field."
}
```

```json 400: Website without an event 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": "event is required on snapchat: one of APP_INSTALL, PURCHASE, ..."
}
```

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


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