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

# Create Audience

> Create an Instagram custom audience of site visitors, engaged people, a lookalike or your own customer list, to include or exclude when boosting a post.

Create a custom audience on an Instagram ad account. Four kinds are supported, chosen by `type`:

<ul>
  <li>`website`: people a Meta pixel saw on your site.</li>
  <li>`engagement`: people who engaged with a Facebook Page, an Instagram account or a video.</li>
  <li>`lookalike`: people like an audience you already have.</li>
  <li>`customerList`: your own list of people, which you fill with hashed identifiers through [Audience Members](https://www.ayrshare.com/docs/apis/ads/instagram/audience-members.md).</li>
</ul>

The new audience is returned under `audience` in the same shape as [Audiences](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md), with `status.ready: false`. Meta fills it over the next hours; list it to see when `status.ready` turns `true`, then use its `id` in `targeting.audiences` or `targeting.excludedAudiences` when you [boost a post](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post.md#audiences).

> [!NOTE]
>
> Before any audience can be created or used, a person with a role on the ad account must accept Meta's Custom Audience terms once, at `https://business.facebook.com/ads/manage/customaudiences/tos/?act=<ad account id>`. Ayrshare cannot accept them for you. Until then this endpoint returns a `400` with `code: 101`, and `details` names the account and the page where the terms are accepted. [Ad accounts](https://www.ayrshare.com/docs/apis/ads/instagram/get-ad-accounts.md) shows whether they are accepted in `tosAccepted.customAudienceTos`.

> [!WARNING]
>
> Meta does not allow lookalike audiences on housing, employment or financial ads. A boost in one of those [special ad categories](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post.md#param-special-ad-categories) can include or exclude website, engagement and customer-list audiences, but not a lookalike.

## Header Parameters

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

## Body Parameters

Every `type` takes these:

**accountId** `string` *required*

The ad account to create the audience on, from [ad accounts](https://www.ayrshare.com/docs/apis/ads/instagram/get-ad-accounts.md), with or without the `act_` prefix.

**name** `string` *required*

The name shown in Ads Manager.

**type** `string` *required*

`website`, `engagement`, `lookalike` or `customerList`. Each type takes only its own fields below. A field from another type returns a `400` with `code: 101` naming it.

**idempotencyKey** `string`

A new unique value, such as a UUID, for each new audience. If you repeat a request with the same key, Ayrshare returns the first response, marked `idempotentReplayed: true`, and creates no second audience. You can send the key as the `Idempotency-Key` header instead; if you send both, they must match. Reusing a key with a different request, or while the first request is still in progress, returns a `409`. A `503` means the key could not be reserved and nothing was created: retry later with the same key.

### Website audiences

**pixelId** `string` *required*

The Meta pixel whose events build the audience.

**retentionDays** `number` *required*

How many days a visitor stays in the audience after their last visit, 1 to 180.

**urlContains** `array`

Keep only visits to URLs containing one of these strings, for example `["/pricing"]`.

**event** `string`

Keep only visitors who fired this pixel event, for example `Purchase` or a custom event name. Leave it out to count every visit.

### Engagement audiences

**source** `string` *required*

Where the engagement happened: `page` (a Facebook Page), `instagram` (an Instagram account) or `video`.

**sourceIds** `array` *required*

The Page ids, Instagram account ids or video ids to count engagement on, as strings.

**event** `string` *required*

The engagement counted. The values are Meta's own names and depend on `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>

Any other value returns a `400` with `code: 101` listing the values for that source.

**retentionDays** `number` *required*

How many days a person stays in the audience after they last engaged: 1 to 730 for `page` and `instagram`, 1 to 365 for `video`.

### Lookalike audiences

**seedAudienceId** `string` *required*

The audience to find people like, from [Audiences](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md). Meta needs at least 100 people in it.

**ratio** `number` *required*

How large the lookalike is, as a whole percent of the people in the countries the boost targets: 1 (closest match) to 20 (widest reach).

**allowInternationalSeeds** `boolean`

Let Meta take seed people from other countries when a country has too few. Defaults to `false`.

A lookalike has no country of its own: the people come from the countries the [boost's `targeting.locations`](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post) names. Sending a `country` returns a `400` with `code: 101`. A lookalike takes Meta a few hours to fill.

### Customer-list audiences

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

Where the list's data came from, in Meta's terms: `USER_PROVIDED_ONLY` (people gave it to you), `PARTNER_PROVIDED_ONLY` (a partner gave it to you) or `BOTH_USER_AND_PARTNER_PROVIDED`.

A customer list starts empty. Add people with [Audience Members](https://www.ayrshare.com/docs/apis/ads/instagram/audience-members.md). Hashed identifiers are still personal data: read that page before you upload a list.

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