# Preview audiences

URL: https://docs.hanzo.ai/docs/openapi/marketing/get-marketing-audiences-by-id-preview

> Evaluates the cohort LIVE — the same resolution an enrollment would run — and reports how big it is and how many real mailboxes it reaches.

`GET /v1/marketing/audiences/{id}/preview`

> [Marketing →](https://docs.hanzo.ai/docs/openapi/marketing) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                            |
| ------------- | ---------------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/marketing/audiences/{id}/preview` |
| **Method**    | `GET`                                                      |
| **Operation** | `get_marketing_audiences_by_id_preview`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`                     |

Evaluates the cohort LIVE — the same resolution an enrollment
would run — and reports how big it is and how many real mailboxes it reaches.
It is the honest answer to "is this send worth making": a cohort of 500 that
mails 3 says so, in deliverable and unmatched. Nothing is sent.

## Request

1 field.

| Field | In   | Type   | Required | Description                                                 |
| ----- | ---- | ------ | -------- | ----------------------------------------------------------- |
| `id`  | path | string | yes      | ID is the audience id from the path, as returned by create. |

## Response

| Status    | Body                      | Meaning |
| --------- | ------------------------- | ------- |
| `200`     | marketing.AudiencePreview | ok      |
| `default` | problem-details           | refused |

`200` body — 7 fields.

| Field         | In   | Type            | Always | Description                                                                                                                                                                                                         |
| ------------- | ---- | --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `available`   | body | boolean         | —      | Available is false when the roster or the warehouse could not be read; the counts are then zero because nothing was measured, not because the cohort is empty, and Reason says which read failed.                   |
| `count`       | body | integer (int64) | —      | Count is the cohort size: distinct warehouse identifiers for an event audience, mailable customers for an event-less (whole-org) one.                                                                               |
| `deliverable` | body | integer (int64) | —      | Deliverable is how many de-duplicated mailboxes a send would reach.                                                                                                                                                 |
| `reason`      | body | string          | —      | Reason is the error text of the read that failed: the org's roster could not be loaded ("identity store unavailable…"), or the cohort query had no warehouse to run against ("analytics warehouse not configured"). |
| `sample`      | body | string\[]       | —      | Sample is up to 1000 cohort IDENTIFIERS — never addresses, which product analytics does not hold.                                                                                                                   |
| `source`      | body | string          | —      | Source names where the cohort was read: the events table for an event audience, "iam:\<org>" for the whole-org one.                                                                                                 |
| `unmatched`   | body | integer (int64) | —      | Unmatched is how many cohort identifiers named nobody on the org's roster and so have no address to mail.                                                                                                           |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo marketing audiences preview <id>
```

**SDK**

**.ts**

```ts
import { Configuration, MarketingApi } from 'hanzoai';

const api = new MarketingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getMarketingAudiencesByIdPreview({ id: 'id' });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import MarketingApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = MarketingApi(client).get_marketing_audiences_by_id_preview(id='id')
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.MarketingAPI.GetMarketingAudiencesByIdPreview(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, marketing_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = marketing_api::get_marketing_audiences_by_id_preview(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.MarketingApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new MarketingApi(client).getMarketingAudiencesByIdPreview();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/marketing/audiences/<id>/preview \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **marketing** through the `marketing` tool, which names its 35 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_marketing_audiences"
         }
       }
     }'
```

---

[Marketing API](https://docs.hanzo.ai/docs/openapi/marketing) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
