> ## 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 a Snapchat customer list, website or lookalike audience segment to include or exclude when you boost a Snap with Ayrshare.

Create an audience segment on a Snapchat ad account. Three kinds are supported, chosen by `type`:

<ul>
  <li>`customerList`: your own list of people, which you fill with hashed identifiers through [Audience Members](https://www.ayrshare.com/docs/apis/ads/snapchat/audience-members.md).</li>
  <li>`website`: people your Snap Pixel saw fire one event on your site.</li>
  <li>`lookalike`: people in the countries you name who are like the people in one of your customer lists.</li>
</ul>

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

<ul>
  <li>A boost can target a segment once Snapchat has matched enough people. Until then `status.ready` is `false`.</li>
  <li>An ad account holds at most 1,000 customer lists, and a segment name is at most 375 characters. Snapchat refuses more with `code: 369`.</li>
  <li>Snapchat cannot create engagement audiences here. `type: engagement` returns a `400` with `code: 101`.</li>
  <li>Send an `idempotencyKey` if you may retry: a retry with the same key and body returns the first response instead of creating a second segment.</li>
</ul>

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

**accountId** `string` *required*

Your Snapchat ad account ID to create the segment on, for example `5a0d0000-0000-4000-8000-000000000003`.

**name** `string` *required*

The name shown in Snapchat Ads Manager.

**type** `string` *required*

`customerList`, `website` or `lookalike`. The other fields depend on it.

**idempotencyKey** `string`

A unique value per new segment, such as a UUID.

### Customer list

No other fields. The list is empty, and keeps people until you remove them. `customerFileSource` is optional: Snapchat lists hold your own data only, so any value but `USER_PROVIDED_ONLY` returns `code: 101`.

### Website

**pixelId** `string` *required*

Your Snap Pixel id.

**event** `string` *required*

The pixel event a visitor must have fired, as Snapchat spells it: `PAGE_VIEW`, `VIEW_CONTENT`, `ADD_CART`, `START_CHECKOUT`, `PURCHASE`, `SIGN_UP`, `SUBSCRIBE`, `SEARCH`, `ADD_TO_WISHLIST`, `CUSTOM_EVENT_1` to `CUSTOM_EVENT_5`, or another of [Snapchat's pixel events](https://developers.snap.com/marketing-api/Ads-API/audience-creation/website-events). Required on Snapchat.

**retentionDays** `number` *required*

How many days a visitor stays in the segment, 1 to 180.

`urlContains` is not supported on Snapchat: a Snapchat website segment keeps people by pixel event only, so it returns `code: 101`.

### Lookalike

**seedAudienceId** `string` *required*

The customer list to find people like (`type: customerList` in [Audiences](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)). Snapchat builds a lookalike only from a customer list, so a seed that is not one of your customer lists on this ad account (another kind of segment, another account's segment, or a deleted one) returns `code: 101`.

**countries** `array` *required*

The countries to find people in, as two-letter codes such as `US`. Each country once.

**similarity** `string`

`balance` (the default) weighs closeness and size, `similarity` keeps the people most like the seed, and `reach` finds the most people.

**retentionDays** `number`

How many days a person stays in the segment, 1 to 180. Defaults to 180.

A Snapchat lookalike has no size percentage: `ratio` and `allowInternationalSeeds` return `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.