> For the complete documentation index, see [llms.txt](https://edrus.gitbook.io/appgregator-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edrus.gitbook.io/appgregator-api-docs/appgregators/marketing/facebook-ads/before-starting/api/adspixel/create-a-new-pixel.md).

# Create a new Pixel

A Facebook pixel is a small piece of JavaScript code that an advertiser places on every page of their website. This piece of code provides a set of lightweight functionalities for sending user-specific events and event-specific custom data to Facebook. Advertisers can use the Facebook pixel to capture intent information about how people are using their website. A single Facebook pixel is added to all pages of a website, and is then used to create website custom audiences

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

#### 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": "814765166375068"
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request" %}

```javascript
{
    "error": {
        "message": "More than one pixel exist for this account",
        "type": "OAuthException",
        "code": 6202,
        "error_subcode": 1784012,
        "is_transient": false,
        "error_user_title": "Too many pixels in ad account",
        "error_user_msg": "We found more than 1 ads pixels in ad account 23850279712480684, and cannot decide which one to use.Please specify the ads pixel ID that you would like to use.",
        "fbtrace_id": "AEfFiSfcyPEbpoAz_KML7fK"
    }
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>Body JSON</summary>

```shell
{
    "name" : "WCA Pixel-1",
    "app_id" : "600957674560496",
    "app_secret" : "7459f5c27e9a0482cf62879ba5723fbd"
}
```

</details>

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

```shell
curl --location --request POST 'https://us-central1-appgregator.cloudfunctions.net/facebook/adpixel?name=ft-4&connection_name=fbads-01&adaccount_id=act_1217648562383717' \
--header 'x-api-key: U2Fsd...' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name" : "WCA Pixel-1",
    "app_id" : "600957674560496",
    "app_secret" : "7459f5c27e9a0482cf62879ba5723fbd"
}'
```

{% endtab %}

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

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "name": "WCA Pixel-1",
  "app_id": "600957674560496",
  "app_secret": "7459f5c27e9a0482cf62879ba5723fbd"
});

var config = {
  method: 'post',
  url: 'https://us-central1-appgregator.cloudfunctions.net/facebook/adpixel?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/adpixel?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" : "WCA Pixel-1",
    "app_id" : "600957674560496",
    "app_secret" : "7459f5c27e9a0482cf62879ba5723fbd"
}',
  CURLOPT_HTTPHEADER => array(
    'x-api-key: U2Fsd...',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}
