# Get custom audiences

GET https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience

Retrieve Facebook custom audiences for a location. Without `limit` the response is a plain array. When `limit` is provided (max 100) the response is a paginated `{ customAudiences, paging }` envelope; pass `after` (from `paging.next`) to fetch the next batch. By default each item is returned in full; pass `projection` (comma-separated, dot-notation for nested fields, e.g. ?projection=id,name,dataSource.type) to return only the requested fields — any value outside the known field set is rejected.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `adPublishing.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location identifier |
| `type` | string | Yes | Audience list type |
| `source` | string | No | Audience data source |
| `adAccountId` | string | Yes | Ad account identifier |
| `limit` | string | No | Page size for a paginated fetch (max 100). When set, the response is a { customAudiences, paging } envelope instead of a plain array. |
| `after` | string | No | Opaque cursor for the next batch, taken from the previous response paging.next |
| `projection` | array | No | Fields to return on each item, comma-separated (e.g. ?projection=id,name,dataSource.type). When set, only the requested fields are returned. Nested fields use dot-notation; naming a parent (e.g. dataSource) returns the whole nested object. Any value outside the known field set is rejected. Omit the param entirely to receive the full item as-is. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-04-15"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/ad-publishing/facebook/custom-audience": {
      "get": {
        "summary": "Get custom audiences",
        "operationId": "getCustomAudiences",
        "description": "Retrieve Facebook custom audiences for a location. Without `limit` the response is a plain array. When `limit` is provided (max 100) the response is a paginated `{ customAudiences, paging }` envelope; pass `after` (from `paging.next`) to fetch the next batch. By default each item is returned in full; pass `projection` (comma-separated, dot-notation for nested fields, e.g. ?projection=id,name,dataSource.type) to return only the requested fields — any value outside the known field set is rejected.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location identifier",
            "schema": {
              "example": "loc_abc123",
              "type": "string"
            }
          },
          {
            "name": "type",
            "required": true,
            "in": "query",
            "description": "Audience list type",
            "schema": {
              "example": "custom",
              "enum": [
                "lookalike",
                "custom",
                "all"
              ],
              "type": "string"
            }
          },
          {
            "name": "source",
            "required": false,
            "in": "query",
            "description": "Audience data source",
            "schema": {
              "example": "ad_manager",
              "enum": [
                "ad_manager",
                "integration"
              ],
              "type": "string"
            }
          },
          {
            "name": "adAccountId",
            "required": true,
            "in": "query",
            "description": "Ad account identifier",
            "schema": {
              "example": "act_123456",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Page size for a paginated fetch (max 100). When set, the response is a { customAudiences, paging } envelope instead of a plain array.",
            "schema": {
              "example": "25",
              "type": "string"
            }
          },
          {
            "name": "after",
            "required": false,
            "in": "query",
            "description": "Opaque cursor for the next batch, taken from the previous response paging.next",
            "schema": {
              "example": "QVFIU...",
              "type": "string"
            }
          },
          {
            "name": "projection",
            "required": false,
            "in": "query",
            "description": "Fields to return on each item, comma-separated (e.g. ?projection=id,name,dataSource.type). When set, only the requested fields are returned. Nested fields use dot-notation; naming a parent (e.g. dataSource) returns the whole nested object. Any value outside the known field set is rejected. Omit the param entirely to receive the full item as-is.",
            "schema": {
              "example": [
                "id",
                "name",
                "dataSource.type",
                "deliveryStatus.code"
              ],
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "id",
                  "name",
                  "description",
                  "approximateCountLowerBound",
                  "approximateCountUpperBound",
                  "subtype",
                  "timeCreated",
                  "timeUpdated",
                  "dataSource",
                  "dataSource.type",
                  "dataSource.subType",
                  "dataSource.creationParams",
                  "deliveryStatus",
                  "deliveryStatus.code",
                  "deliveryStatus.description",
                  "operationStatus",
                  "operationStatus.code",
                  "operationStatus.description"
                ]
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A plain array of custom audiences (default), or a { customAudiences, paging } envelope when `limit` is provided. Lookalike and custom audiences share one shape — `subtype` distinguishes them. Supplying `projection` narrows every entry to the requested fields only.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetCustomAudiencesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "adPublishing.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "GetCustomAudiencesResponse": {
        "oneOf": [
          {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Audience id",
                  "example": "120250373909070122"
                },
                "name": {
                  "type": "string",
                  "description": "Audience name",
                  "example": "Website Visitors - Last 30 Days"
                },
                "description": {
                  "type": "string",
                  "description": "Audience description. Empty string when not set.",
                  "example": ""
                },
                "subtype": {
                  "type": "string",
                  "description": "How the audience was built. `LOOKALIKE` for lookalikes; `CUSTOM`, `ENGAGEMENT`, `WEBSITE`, and `LEAD` for the rest.",
                  "example": "ENGAGEMENT"
                },
                "approximateCountLowerBound": {
                  "type": "number",
                  "description": "Lower bound of the audience size. Facebook floors small audiences — `1000` and `20` are placeholders, not counts.",
                  "example": 19900000
                },
                "approximateCountUpperBound": {
                  "type": "number",
                  "description": "Upper bound of the audience size",
                  "example": 23400000
                },
                "deliveryStatus": {
                  "description": "Whether the audience can be used in a campaign right now",
                  "example": {
                    "code": 200,
                    "description": "This audience is ready for use."
                  },
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "number",
                          "description": "Meta status code. `200` is the healthy case; anything else is explained by `description`.",
                          "example": 200
                        },
                        "description": {
                          "type": "string",
                          "description": "Human-readable status, safe to show to a user",
                          "example": "This audience is ready for use."
                        }
                      },
                      "required": [
                        "code",
                        "description"
                      ],
                      "title": "FacebookAudienceStatusDTO"
                    }
                  ]
                },
                "operationStatus": {
                  "description": "Whether Facebook is still building or refreshing the audience",
                  "example": {
                    "code": 200,
                    "description": "This audience is ready for use."
                  },
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "number",
                          "description": "Meta status code. `200` is the healthy case; anything else is explained by `description`.",
                          "example": 200
                        },
                        "description": {
                          "type": "string",
                          "description": "Human-readable status, safe to show to a user",
                          "example": "This audience is ready for use."
                        }
                      },
                      "required": [
                        "code",
                        "description"
                      ],
                      "title": "FacebookAudienceStatusDTO"
                    }
                  ]
                },
                "dataSource": {
                  "description": "Where the audience gets its members from",
                  "example": {
                    "type": "EVENT_BASED",
                    "subType": "WEB_PIXEL_HITS",
                    "creationParams": "[]"
                  },
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "description": "How the audience is populated. Passed through from Meta, which does not publish a closed list — `EVENT_BASED`, `SEED_BASED`, and `UNKNOWN` are the values seen in practice, so treat this as an open string rather than an exhaustive enum.",
                          "example": "EVENT_BASED"
                        },
                        "subType": {
                          "type": "string",
                          "description": "More specific origin within `type`. Observed pairings are `EVENT_BASED` with `WEB_PIXEL_HITS` or `ENGAGEMENT_EVENTS`, `SEED_BASED` with `PAGE_FANS` or `PLATFORM_USERS`, and `UNKNOWN` with `ANYTHING`, which is what a customer-list upload reports. Also passed through from Meta and not a closed list.",
                          "example": "WEB_PIXEL_HITS"
                        },
                        "creationParams": {
                          "type": "string",
                          "description": "Facebook creation parameters, delivered as a JSON string rather than an object.",
                          "example": "[]"
                        }
                      },
                      "required": [
                        "type",
                        "subType",
                        "creationParams"
                      ],
                      "title": "FacebookAudienceDataSourceDTO"
                    }
                  ]
                },
                "timeCreated": {
                  "type": "number",
                  "description": "Creation time as a Unix timestamp in seconds, not milliseconds and not ISO-8601.",
                  "example": 1787123977
                },
                "timeUpdated": {
                  "type": "number",
                  "description": "Last update time as a Unix timestamp in seconds. Equals `timeCreated` when never edited.",
                  "example": 1787123977
                }
              },
              "title": "FacebookCustomAudienceDTO"
            }
          },
          {
            "type": "object",
            "properties": {
              "customAudiences": {
                "type": "array",
                "description": "Page of Facebook custom audiences",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                },
                "example": [
                  {
                    "id": "23851234567890",
                    "name": "Website Visitors - Last 30 Days",
                    "subtype": "WEBSITE"
                  }
                ]
              },
              "paging": {
                "description": "Pagination cursor",
                "example": {
                  "next": "QVFIU..."
                },
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "next": {
                        "type": "string",
                        "description": "Cursor for the next page of results, or null when there are no more pages",
                        "example": "QVFIU...",
                        "nullable": true
                      }
                    },
                    "required": [
                      "next"
                    ],
                    "title": "FacebookPagingDTO"
                  }
                ]
              }
            },
            "required": [
              "customAudiences",
              "paging"
            ],
            "title": "PaginatedFacebookCustomAudiencesDTO"
          }
        ]
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for an unexpected server error",
            "example": 500
          },
          "message": {
            "type": "string",
            "description": "Error message describing the server failure",
            "example": "Internal Server Error"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-04-15"
}

params = {
    "locationId": "<LOCATIONID>",
    "type": "<TYPE>",
    "adAccountId": "<ADACCOUNTID>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-04-15")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-04-15"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/ad-publishing/facebook/custom-audience?locationId=<LOCATIONID>&type=<TYPE>&adAccountId=<ADACCOUNTID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
