# Audience Targeting API

> Current Froomle documentation · [View canonical page](https://docs.froomle.com/froomle-doc-main/v2/api_reference/audience/index.html)

The Audience Targeting API manages subscription pools and selects users who are most relevant for a promotion.

A pool is a set of users with a specific eligibility for push communication. Froomle uses the users in a pool to find the most relevant audience for a promotion. Rate limits can be applied to each audience request to control how often users are selected.

<a id="_specifications"></a>

## Specifications

<a id="_create_or_replace_a_pool"></a>

### Create or replace a pool

Creates or fully replaces a pool for an environment. The `environment` and `pool_id` in the request body must match the path. Pool members use typed `user_id` or `device_id` identities. Repeated members are deduplicated.

```console
$ curl --location --request POST 'https://{subdomain}.froomle.com/api/{environment}/audience/pools/{pool_id}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "environment": "20min",
  "pool_id": "midterms_subscribers",
  "users": [
    {"device_id": 1},
    {"user_id": 2}
  ],
  "metadata": {}
}'
```

<a id="_manage_pool_memberships"></a>

### Manage pool memberships

Use the pool membership route to retrieve, add, or remove addressed memberships:

```console
$ curl --location 'https://{subdomain}.froomle.com/api/{environment}/audience/pools/{pool_id}/users/{user_id}' \
--header 'Authorization: Bearer X'

$ curl --location --request PUT 'https://{subdomain}.froomle.com/api/{environment}/audience/pools/{pool_id}/users/{user_id}' \
--header 'Authorization: Bearer X'

$ curl --location --request DELETE 'https://{subdomain}.froomle.com/api/{environment}/audience/pools/{pool_id}/users/{user_id}' \
--header 'Authorization: Bearer X'
```

Use `value_type=string` or `value_type=integer` when a digit-only identifier needs disambiguation. An untyped path addresses both identity types.

<a id="_submit_an_audience_request"></a>

### Submit an audience request

Audience generation is asynchronous. A valid request returns `202 Accepted` with a request ID, status URL, and polling guidance.

```console
$ curl --location --request POST 'https://{subdomain}.froomle.com/api/{environment}/audience/requests' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer X' \
--data-raw '{
  "item_id": "item-1",
  "when": "2030-01-01T12:00:00Z",
  "pool_id": "midterms_subscribers",
  "size": 100,
  "size_type": "hard_limit",
  "list_name": "midterms",
  "rate_limits": {"1d": 1, "7d": 3}
}'
```

The response includes an opaque request ID:

```json
{
  "request_id": "2f3d9d4a-6b5e-4b18-98cb-4fd3f7c07110",
  "status": "pending",
  "status_url": "/api/20min/audience/requests/2f3d9d4a-6b5e-4b18-98cb-4fd3f7c07110",
  "created_at": "2030-01-01T12:00:00Z",
  "retry_after_seconds": 5
}
```

<a id="_get_request_status_and_result"></a>

### Get request status and result

Poll the status URL until the request is `succeeded` or `failed`. When it succeeds, retrieve the result. Requesting the completed result increments the push pressure counter for the returned audience. Results may contain `next_page_token`; pass it as `page_token` to retrieve the next page.

```console
$ curl --location 'https://{subdomain}.froomle.com/api/{environment}/audience/requests/{request_id}' \
--header 'Authorization: Bearer X'

$ curl --location 'https://{subdomain}.froomle.com/api/{environment}/audience/requests/{request_id}/result' \
--header 'Authorization: Bearer X'
```

The API does not schedule delivery. Interaction filtering, when enabled, excludes users who already consumed the relevant item before the requested size is applied.

<a id="_definitions"></a>

## Definitions

<a id="_pool_request"></a>

### Pool request

| Field | Description |
| --- | --- |
| `environment` | Environment identifier. Must match the path. |
| `pool_id` | Subscription pool identifier. Must match the path. |
| `users` | Typed `user_id` or `device_id` identities. Integer and string values remain distinct. |
| `metadata` | Custom metadata associated with the pool for enrichment in reporting. |

<a id="_audience_request"></a>

### Audience request

| Field | Description |
| --- | --- |
| `item_id` | Item or promotion identifier. |
| `when` | Planned contact time in ISO 8601 date-time format. |
| `pool_id` | Pool from which eligible users are selected. |
| `size` | Maximum number of users to return. |
| `size_type` | Must be `hard_limit`. |
| `list_name` | Configured audience list name. |
| `rate_limits` | Rolling pressure limits, such as `{"1d": 1, "7d": 3}` for a maximum of one contact per day and three contacts per seven days. |
| `exclude_interacted_users` | Optional override for the configured interaction-filtering policy. |

<a id="_errors"></a>

### Errors

Errors contain `code`, `message`, and optional field-level `details`. A result requested before completion returns `409`; expired request data returns `410`; overly frequent status polling returns `429`.
