# Audiences (/docs/api/agents/audiences)

An audience is a set of targeting rules. A visitor is in the audience when every rule matches, and an audience without rules matches everyone. Audiences belong to the organization and are shared by all environments.

An audience belongs to a space, like the tests and flags that use it. Paths start with `/api/agent/organizations/{organizationId}/spaces/{spaceId}/audiences`. Reading needs any role; creating, changing and deleting need `editor` or higher.

## Rules [#rules]

| Rule      | Values                                                                             |
| --------- | ---------------------------------------------------------------------------------- |
| `country` | ISO 3166-1 alpha-2 code, from IP geolocation, e.g. `NL`                            |
| `device`  | `wearable`, `mobile`, `tablet`, `console`, `smarttv`, `embedded`, `desktop`        |
| `browser` | `chrome`, `safari`, `firefox`, `edge`, `ie`, `samsung internet`, `social`, `other` |
| `os`      | `mac os`, `ios`, `android`, `windows`, `unix`                                      |
| `pointer` | `coarse` (touch), `fine` (mouse)                                                   |

## Create an audience [#create-an-audience]

```bash
curl -X POST https://improve.obelism.studio/api/agent/organizations/$ORG/audiences \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Dutch mobile","rules":{"country":"NL","device":"mobile"}}'
```

```json
{
	"audience": {
		"audienceId": "aud_01H8XYZ",
		"name": "Dutch mobile",
		"slug": "dutch-mobile",
		"rules": { "country": "NL", "device": "mobile" },
		"createdAt": "2026-10-08T12:00:00.000Z",
		"updatedAt": "2026-10-08T12:00:00.000Z"
	}
}
```

`slug` is optional and defaults to the slugified name. A slug you send must already be lowercase letters, digits and `-`.

## Other operations [#other-operations]

| Method   | Path                      | Does                                                  |
| -------- | ------------------------- | ----------------------------------------------------- |
| `GET`    | `/audiences`              | List the audiences                                    |
| `GET`    | `/audiences/{audienceId}` | Get one audience                                      |
| `PATCH`  | `/audiences/{audienceId}` | Change the fields you send; `rules` is replaced whole |
| `DELETE` | `/audiences/{audienceId}` | Delete the audience (`204`)                           |

Tests and flags refer to an audience by its `audienceId`. Deleting an audience doesn't update the tests and flags that use it, so point them at another audience first.
