# Create custom audience

Build an audience of your customers, website visitors, mobile app visitors or people similar to them.

Use the following parameters:

<table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>name</td><td>String</td><td>Yes</td><td>Audience name</td></tr><tr><td>rule</td><td>JSON Object</td><td>Yes</td><td><p>Audience rules applied to referring URL. </p><p>Available Fields : <a href="https://developers.facebook.com/docs/marketing-api/audiences/guides/audience-rules">Documentation</a> </p><p></p><pre class="language-shell"><code class="lang-shell">"rule" :
{
   "inclusions": {
     "operator": "or",
     "rules": [
       {
         "event_sources": [
           {
             "id": "814765166375068",
             "type": "pixel"
           }
         ],
         "retention_seconds": 8400,
         "filter": {
           "operator": "and",
           "filters": [
             {
               "field": "url",
               "operator": "i_contains",
               "value": "shoes"
             }
           ]
         }
       }
     ]
   }
}
</code></pre></td></tr><tr><td>retention_days</td><td>Int / Number</td><td>Optional</td><td>Number of days to retain someone in audience. Between 1 and 180 days</td></tr><tr><td>prefill</td><td>Boolean</td><td>Optional</td><td>Optional. Default is true. Available options are: true: Include website activity recorded before audience creation. false: Only include website traffic from the time of audience creation.</td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>

<mark style="color:green;">`POST`</mark> `https://us-central1-appgregator.cloudfunctions.net/facebook/custom-audience/`

#### Query Parameters

| Name                                               | Type   | Description           |
| -------------------------------------------------- | ------ | --------------------- |
| name<mark style="color:red;">\*</mark>             | String | ft-4                  |
| connection\_name<mark style="color:red;">\*</mark> | String | fbads-01              |
| adaccount\_id<mark style="color:red;">\*</mark>    | String | act\_1217648562383717 |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| x-api-key<mark style="color:red;">\*</mark> | String | U2Fsd...    |

{% tabs %}
{% tab title="201: Created Created" %}

```javascript
{
    "id": "23851054958460684"
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>Body JSON</summary>

```shell
{
    "name" : "My new CA",
    "subtype" : "CUSTOM",
    "description" : "People who bought from my website",
    "customer_file_source" : "USER_PROVIDED_ONLY"
}
```

</details>

{% tabs %}
{% tab title="cURL" %}

```shell
curl --location --request POST 'https://us-central1-appgregator.cloudfunctions.net/facebook/custom-audience?name=ft-4&connection_name=fbads-01&adaccount_id=act_1217648562383717' \
--header 'x-api-key: U2Fsd...' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name" : "My new CA",
    "subtype" : "CUSTOM",
    "description" : "People who bought from my website",
    "customer_file_source" : "USER_PROVIDED_ONLY"
}'
```

{% endtab %}

{% tab title="NodeJs - Axios" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "name": "My new CA",
  "subtype": "CUSTOM",
  "description": "People who bought from my website",
  "customer_file_source": "USER_PROVIDED_ONLY"
});

var config = {
  method: 'post',
  url: 'https://us-central1-appgregator.cloudfunctions.net/facebook/custom-audience?name=ft-4&connection_name=fbads-01&adaccount_id=act_1217648562383717',
  headers: { 
    'x-api-key': 'U2Fsd...', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="PHP - cURL" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://us-central1-appgregator.cloudfunctions.net/facebook/custom-audience?name=ft-4&connection_name=fbads-01&adaccount_id=act_1217648562383717',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "name" : "My new CA",
    "subtype" : "CUSTOM",
    "description" : "People who bought from my website",
    "customer_file_source" : "USER_PROVIDED_ONLY"
}',
  CURLOPT_HTTPHEADER => array(
    'x-api-key: U2Fsd...',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}
