> For the complete documentation index, see [llms.txt](https://docs.edgetag.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edgetag.io/features/audience-api.md).

# Audience API

### Overview

The Audience API enables uploading customer segments (audiences) to advertising and marketing platforms through EdgeTag. Instead of connecting each platform individually, a single API call distributes audience data to all configured providers simultaneously.

This is typically used for:

**Custom Audiences** — Uploading user lists to ad platforms (e.g., Facebook Custom Audiences, TikTok Audiences) for targeted advertising

**Primary Audiences** — Syncing your primary customer database to providers for lookalike modeling or suppression

**Segment Sync** — Keeping marketing platform segments in sync with your customer data

{% hint style="info" %}
Key Benefit: One API call pushes audience data to Facebook, TikTok, Klaviyo,and any other configured provider. Each provider handles its own data formatting,hashing, and API communication internally.
{% endhint %}

#### Endpoint Details

<table data-header-hidden><thead><tr><th width="153.68359375"></th><th></th></tr></thead><tbody><tr><td>Property</td><td>Value</td></tr><tr><td>Method</td><td>POST</td></tr><tr><td>Path</td><td>/audience</td></tr><tr><td>Content Type</td><td>multipart/form-data</td></tr><tr><td>Authentication</td><td>Handled via EdgeTag deployment (environment variables)</td></tr></tbody></table>

#### Request Payload

The request body must be sent as  `multipart/form-data` with the following fields :

<table data-header-hidden><thead><tr><th width="102.5390625"></th><th width="86.296875"></th><th width="120.3515625"></th><th></th></tr></thead><tbody><tr><td>Field</td><td>Type</td><td>Required</td><td>Description</td></tr><tr><td><code>name</code></td><td>string</td><td>Required</td><td>The name of the audience/segment. This is the label used in the destination platform (e.g., "High-Value Customers Q1").</td></tr><tr><td><code>type</code></td><td>string</td><td>Optional</td><td><p>Audience type. One of:</p><p>"custom" (default) — A named segment of users</p><p>"primary" — Your primary customer list</p></td></tr><tr><td><code>batch</code></td><td><p>JSON</p><p>string</p></td><td>Required</td><td>Batch metadata for handling large audiences (see Batch Object below).</td></tr><tr><td><code>users</code></td><td><p>JSON</p><p>string</p></td><td>Required</td><td>Array of user objects to include in the audience (see User Object below). Must contain at least one user.</td></tr></tbody></table>

#### Batch Object

The `batch` field is a JSON string representing metadata for splitting large audiences across multiple requests:

<table data-header-hidden><thead><tr><th width="155.37109375"></th><th width="118.55859375"></th><th></th></tr></thead><tbody><tr><td>Field</td><td>Type</td><td>Description</td></tr><tr><td><code>sessionId</code></td><td>number</td><td>Unique identifier tying all batches of the same upload together.</td></tr><tr><td><code>sequence</code></td><td>number</td><td>The index of this batch in the series (starting from 0 or 1).</td></tr><tr><td><code>totalBatches</code></td><td>number</td><td>Total number of batches in this upload session.</td></tr><tr><td><code>totalUsers</code></td><td>number</td><td>Total number of users across all batches.</td></tr><tr><td><code>pullDate</code></td><td>string</td><td><mark style="color:$info;"><strong>Optional</strong></mark> Date the data was pulled, in <code>YYYY-MM-DD</code> format.</td></tr></tbody></table>

#### User Object

Each element in the `user`  array represents a customer with the following fields:

<table data-header-hidden><thead><tr><th width="176.87890625"></th><th width="109.4921875"></th><th></th></tr></thead><tbody><tr><td>Field</td><td>Type</td><td>Description</td></tr><tr><td><code>edgeTagId</code></td><td>string</td><td>The EdgeTag identifier for this user (first-party ID).</td></tr><tr><td><code>email</code></td><td>string</td><td>User's email address. Used as a primary match key by most providers.</td></tr><tr><td><code>phone</code></td><td>string</td><td>User's phone number. Used as a secondary match key.</td></tr><tr><td><code>firstName</code></td><td>string</td><td>User's first name.</td></tr><tr><td><code>lastName</code></td><td>string</td><td>User's last name.</td></tr><tr><td><code>country</code></td><td>string</td><td>User's country.</td></tr><tr><td><code>postalCode</code></td><td>string</td><td>User's postal/zip code.</td></tr><tr><td><code>purchase</code></td><td>object</td><td><p><mark style="color:$info;"><strong>Optional</strong></mark> Purchase data for value-based audiences: </p><ul><li><code>currency</code> (string) — Currency code (e.g., "USD") </li><li><code>profit</code> (number) — Profit from this customer </li><li><code>total7Days</code> (number) — Total spend in last 7 days</li></ul></td></tr></tbody></table>

#### Query Parameters&#x20;

<table data-header-hidden><thead><tr><th width="135.921875"></th><th width="103.5390625"></th><th width="113.5234375"></th><th></th></tr></thead><tbody><tr><td>Parameter</td><td>Type</td><td>Default</td><td>Description</td></tr><tr><td><code>disablePrefix</code></td><td>boolean</td><td><code>false</code></td><td>When <code>true</code> , prevents providers from adding the default <code>blotout_</code> prefix to the segment name. Useful when you want the exact name you specified.</td></tr><tr><td><code>sync</code></td><td>boolean</td><td><code>false</code></td><td>When <code>true</code> , the API waits for all providers to finish before responding. When <code>false</code> (default), work is dispatched in the background and the API responds immediately.</td></tr></tbody></table>

{% hint style="warning" %}
Note on sync mode: When sync=true , the API will return errors from any provider that failed. When sync=false (the default), the response is always {"success": true} because work runs in the background. Use sync mode when you need confirmation that all providers succeeded.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.edgetag.io/features/audience-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
