Preview a segment
POST/v1/segments/preview
Try rules out before you save them: how many contacts match, and up to five of their addresses. Nothing is stored.
Required scope: contacts:manage
Request body
| Field | Type |
|---|---|
audience_idrequired | string |
matchoptional | "all" | "any" |
rulesrequired | any[] |
Unknown fields are rejected, so a typo never silently does nothing.
Example
curl -X POST 'https://api.sendsend.email/v1/segments/preview' \
-H "Authorization: Bearer $SENDSEND_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"audience_id": "aud_7Qe2…",
"match": "all",
"rules": [
{
"field": "property",
"key": "plan",
"op": "equals",
"value": "pro"
},
{
"field": "status",
"op": "is",
"value": "subscribed"
}
]
}'Response 200
{
"object": "segment_preview",
"count": 184,
"sample": [
"maria@example.com",
"li@example.com"
]
}Errors
| Status | Code | When |
|---|---|---|
| 400 | validation_error | The request body or parameters are invalid. The message says which field. |
| 404 | not_found | No such resource in this project. |
| 401 | unauthorized | The API key is missing, invalid or revoked. |
| 403 | forbidden | The key does not have the scope this endpoint needs. |
Every error has the same shape. See Errors.