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

# オーディエンスを作成

> サイト訪問者、エンゲージした人、類似、顧客リストの Instagram カスタムオーディエンスを作成し、ブーストで含める・除外します。

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

<ul>
  <li>`website`: Meta ピクセルがサイト上で検出した人。</li>
  <li>`engagement`: Facebook ページ、Instagram アカウント、または動画にエンゲージした人。</li>
  <li>`lookalike`: 既存のオーディエンスに似た人。</li>
  <li>`customerList`: 独自の人物リスト。[オーディエンスメンバー](https://www.ayrshare.com/docs/apis/ads/instagram/audience-members.md)からハッシュ化した識別子で追加します。</li>
</ul>

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

> [!NOTE]
>
> オーディエンスを作成または使用する前に、広告アカウントで役割を持つユーザーが Meta の Custom Audience 規約に一度同意する必要があります。同意は `https://business.facebook.com/ads/manage/customaudiences/tos/?act=<ad account id>` で行います。Ayrshare が代わりに同意することはできません。同意するまで、このエンドポイントは `code: 101` を含む `400` を返し、`details` にアカウントと規約に同意するページが示されます。同意済みかどうかは、[広告アカウント](https://www.ayrshare.com/docs/apis/ads/instagram/get-ad-accounts.md)の `tosAccepted.customAudienceTos` で確認できます。

> [!WARNING]
>
> Meta は、住宅、雇用、金融の広告で類似オーディエンスを許可していません。これらの[特別な広告カテゴリ](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post.md#param-special-ad-categories)のブーストでは、ウェブサイト、エンゲージメント、顧客リストのオーディエンスを含めたり除外したりできますが、類似オーディエンスは使用できません。

## ヘッダーパラメータ

**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`

## ボディパラメータ

すべての `type` で次のパラメータを使用します。

**accountId** `string` *required*

オーディエンスを作成する広告アカウント。[広告アカウント](https://www.ayrshare.com/docs/apis/ads/instagram/get-ad-accounts.md)から取得し、`act_` プレフィックスの有無は問いません。

**name** `string` *required*

Ads Manager に表示される名前。

**type** `string` *required*

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

**idempotencyKey** `string`

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

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

**pixelId** `string` *required*

イベントからオーディエンスを作成する Meta ピクセル。

**retentionDays** `number` *required*

最後の訪問後に訪問者がオーディエンスに残る日数(1〜180)。

**urlContains** `array`

これらの文字列のいずれかを含む URL への訪問のみを対象にします。例: `["/pricing"]`。

**event** `string`

このピクセルイベントを発生させた訪問者のみを対象にします。例: `Purchase` またはカスタムイベント名。省略するとすべての訪問を数えます。

### エンゲージメントオーディエンス

**source** `string` *required*

エンゲージメントが発生した場所: `page`(Instagram ページ)、`instagram`(Instagram アカウント)、または `video`。

**sourceIds** `array` *required*

エンゲージメントを数えるページ ID、Instagram アカウント ID、または動画 ID(文字列)。

**event** `string` *required*

数えるエンゲージメント。値は Meta 独自の名前で、`source` によって異なります。

<ul>
  <li>`page`: `page_engaged`, `page_visited`, `page_liked`, `page_messaged`, `page_cta_clicked`, `page_or_post_save`, `page_post_interaction`</li>
  <li>`instagram`: `ig_business_profile_all`, `ig_business_profile_engaged`, `ig_business_profile_visit`, `ig_business_profile_ad_saved`, `ig_user_messaged_business`, `ig_ad_like`, `ig_ad_comment`, `ig_ad_share`, `ig_ad_save`, `ig_ad_cta_click`, `ig_ad_carousel_swipe`, `ig_organic_like`, `ig_organic_comment`, `ig_organic_share`, `ig_organic_save`, `ig_organic_swipe`, `ig_organic_carousel_swipe`</li>
  <li>`video`: `video_watched`, `video_completed`, `video_view_10s`, `video_view_15s`, `video_view_25_percent`, `video_view_50_percent`, `video_view_75_percent`</li>
</ul>

それ以外の値を指定すると、そのソースで使える値を列挙した `code: 101` 付きの `400` が返ります。

**retentionDays** `number` *required*

最後のエンゲージメント後に人がオーディエンスに残る日数: `page` と `instagram` は 1〜730、`video` は 1〜365。

### 類似オーディエンス

**seedAudienceId** `string` *required*

似た人を探す元のオーディエンス。[オーディエンス](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md)から取得します。Meta には 100 人以上が必要です。

**ratio** `number` *required*

類似オーディエンスの規模。ブーストがターゲットにする国の人口に対する整数のパーセントで、1(最も近い一致)〜20(最も広いリーチ)です。

**allowInternationalSeeds** `boolean`

ある国のソースとなる人が少なすぎる場合に、Meta が他の国からソースとなる人を取れるようにします。デフォルトは `false` です。

類似オーディエンスには独自の国がありません。対象者は[ブーストの `targeting.locations`](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post) で指定した国から選ばれます。`country` を送ると `code: 101` 付きの `400` が返ります。Meta が類似オーディエンスを作成するには数時間かかります。

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

**customerFileSource** `string` (default: USER\_PROVIDED\_ONLY)

リストのデータの入手元(Meta の用語): `USER_PROVIDED_ONLY`(本人から提供)、`PARTNER_PROVIDED_ONLY`(パートナーから提供)、または `BOTH_USER_AND_PARTNER_PROVIDED`。

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

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/instagram/audiences \
-d '{"accountId": "1234567890", "name": "Site visitors 30d", "type": "website", "pixelId": "987654321098765", "retentionDays": 30, "urlContains": ["/pricing"]}'
```

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

fetch("https://api.ayrshare.com/api/ads/instagram/audiences", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${API_KEY}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
    "accountId": "1234567890",
    "name": "Site visitors 30d",
    "type": "website",
    "pixelId": "987654321098765",
    "retentionDays": 30,
    "urlContains": [
      "/pricing"
    ]
  })
    })
      .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": "1234567890",
  "name": "Site visitors 30d",
  "type": "website",
  "pixelId": "987654321098765",
  "retentionDays": 30,
  "urlContains": [
    "/pricing"
  ]
}

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

print(r.json())
```

```json 200: Success theme={"system"}
{
  "status": "success",
  "audience": {
    "id": "23851234567890123",
    "name": "Site visitors 30d",
    "type": "website",
    "size": null,
    "status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
    "created": "2026-10-29T10:05:00.000Z"
  }
}
```

```json 400: Field from another type 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: Terms not accepted 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": "Creating a custom audience needs the Custom Audience terms accepted on ad account act_123456789. A person with a role on the account accepts them at https://business.facebook.com/ads/manage/customaudiences/tos/?act=123456789"
}
```

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


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