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

# Audience बनाएँ

> साइट विज़िटर, engaged लोगों, lookalike या अपनी customer list की Instagram custom audience बनाएँ, ताकि पोस्ट boost करते समय उसे शामिल या बाहर कर सकें।

Instagram ad account पर custom audience बनाएँ। चार प्रकार समर्थित हैं, जिन्हें `type` से चुना जाता है:

<ul>
  <li>`website`: वे लोग जिन्हें Meta pixel ने आपकी साइट पर देखा।</li>
  <li>`engagement`: वे लोग जिन्होंने किसी Facebook Page, Instagram account या वीडियो के साथ engage किया।</li>
  <li>`lookalike`: आपकी पहले से मौजूद किसी audience जैसे लोग।</li>
  <li>`customerList`: लोगों की आपकी अपनी सूची, जिसे आप [Audience Members](https://www.ayrshare.com/docs/apis/ads/instagram/audience-members.md) के ज़रिए hashed identifiers से भरते हैं।</li>
</ul>

नई audience `audience` के अंतर्गत उसी रूप में लौटाई जाती है जैसी [Audiences](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md) में, `status.ready: false` के साथ। Meta अगले कुछ घंटों में उसे भरता है; यह देखने के लिए उसे सूचीबद्ध करें कि `status.ready` कब `true` होता है, फिर जब आप [कोई पोस्ट boost करें](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post.md#audiences), तो उसका `id` `targeting.audiences` या `targeting.excludedAudiences` में उपयोग करें।

> [!NOTE]
>
> कोई भी audience बनाने या उपयोग करने से पहले, ad account पर role वाले किसी व्यक्ति को एक बार Meta की Custom Audience terms स्वीकार करनी होंगी, `https://business.facebook.com/ads/manage/customaudiences/tos/?act=<ad account id>` पर। Ayrshare आपकी ओर से उन्हें स्वीकार नहीं कर सकता। तब तक यह endpoint `code: 101` के साथ `400` लौटाता है, और `details` में account और वह पेज बताया जाता है जहाँ terms स्वीकार की जाती हैं। [Ad accounts](https://www.ayrshare.com/docs/apis/ads/instagram/get-ad-accounts.md) `tosAccepted.customAudienceTos` में दिखाता है कि वे स्वीकार की गई हैं या नहीं।

> [!WARNING]
>
> Meta housing, employment या financial विज्ञापनों पर lookalike audiences की अनुमति नहीं देता। इन [special ad categories](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post.md#param-special-ad-categories) में से किसी एक का boost website, engagement और customer-list audiences को शामिल या बाहर कर सकता है, लेकिन lookalike को नहीं।

## हैडर पैरामीटर

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

वह ad account जिस पर audience बनानी है, [ad accounts](https://www.ayrshare.com/docs/apis/ads/instagram/get-ad-accounts.md) से, `act_` prefix के साथ या उसके बिना।

**name** `string` *required*

Ads Manager में दिखने वाला नाम।

**type** `string` *required*

`website`, `engagement`, `lookalike` या `customerList`। हर type सिर्फ़ नीचे दिए अपने fields लेता है। किसी दूसरे type का field उसके नाम के साथ `code: 101` वाला `400` लौटाता है।

**idempotencyKey** `string`

हर नई audience के लिए एक नया unique मान, जैसे UUID। अगर आप उसी key से request दोहराते हैं, तो Ayrshare पहला response लौटाता है, `idempotentReplayed: true` से चिह्नित, और दूसरी audience नहीं बनाता। आप key को इसके बजाय `Idempotency-Key` header में भी भेज सकते हैं; अगर दोनों भेजते हैं, तो वे मेल खाने चाहिए। किसी अलग request के साथ, या जब पहला request अभी चल रहा हो, key दोबारा उपयोग करने पर `409` मिलता है। `503` का मतलब है कि key reserve नहीं हो सकी और कुछ भी नहीं बना: उसी key से बाद में फिर कोशिश करें।

### Website audiences

**pixelId** `string` *required*

वह Meta pixel जिसकी events से audience बनती है।

**retentionDays** `number` *required*

किसी विज़िटर के आख़िरी visit के बाद वह कितने दिन audience में रहता है, 1 से 180।

**urlContains** `array`

सिर्फ़ उन URLs के visits रखें जिनमें इनमें से कोई string हो, उदाहरण के लिए `["/pricing"]`।

**event** `string`

सिर्फ़ उन विज़िटर को रखें जिन्होंने यह pixel event trigger किया, उदाहरण के लिए `Purchase` या किसी custom event का नाम। हर visit गिनने के लिए इसे छोड़ दें।

### Engagement audiences

**source** `string` *required*

Engagement कहाँ हुआ: `page` (एक Facebook Page), `instagram` (एक Instagram account) या `video`।

**sourceIds** `array` *required*

वे Page ids, Instagram account ids या video ids जिन पर engagement गिना जाता है, strings के रूप में।

**event** `string` *required*

गिना जाने वाला engagement। मान 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>

कोई भी अन्य मान उस source के मानों की सूची के साथ `code: 101` वाला `400` लौटाता है।

**retentionDays** `number` *required*

आख़िरी engagement के बाद कोई व्यक्ति कितने दिन audience में रहता है: `page` और `instagram` के लिए 1 से 730, `video` के लिए 1 से 365।

### Lookalike audiences

**seedAudienceId** `string` *required*

वह audience जिसके जैसे लोग खोजने हैं, [Audiences](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md) से। Meta को इसमें कम से कम 100 लोग चाहिए।

**ratio** `number` *required*

Lookalike कितनी बड़ी है, उन देशों के लोगों के पूर्ण प्रतिशत के रूप में जिन्हें boost target करता है: 1 (सबसे नज़दीकी मिलान) से 20 (सबसे व्यापक पहुँच)।

**allowInternationalSeeds** `boolean`

जब किसी देश में बहुत कम seed लोग हों, तो Meta को दूसरे देशों से seed लोग लेने दें। डिफ़ॉल्ट `false` है।

Lookalike का अपना कोई देश नहीं होता: लोग उन देशों से आते हैं जो [boost के `targeting.locations`](https://www.ayrshare.com/docs/apis/ads/instagram/boost-post) में दिए होते हैं। `country` भेजने पर `code: 101` वाला `400` मिलता है। Lookalike भरने में Meta को कुछ घंटे लगते हैं।

### Customer-list audiences

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

सूची का डेटा कहाँ से आया, Meta की शब्दावली में: `USER_PROVIDED_ONLY` (लोगों ने आपको दिया), `PARTNER_PROVIDED_ONLY` (किसी partner ने आपको दिया) या `BOTH_USER_AND_PARTNER_PROVIDED`।

Customer list खाली शुरू होती है। [Audience Members](https://www.ayrshare.com/docs/apis/ads/instagram/audience-members.md) से लोग जोड़ें। Hashed identifiers फिर भी personal data हैं: सूची upload करने से पहले वह पेज पढ़ें।

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