menu
Count contacts by audience filter
Counts the contacts an audience filter matches, without returning them. Same body and same filters as the search below - use this when you only need the size, such as previewing how many recipients a campaign would reach, rather than paging the whole audience to measure it.
Endpoint
POST https://api.sendstreak.com/v2/accounts/{accountId}/contacts/search/count
All v2 endpoints require a bearer token - see Authentication.
Path parameters
| Parameter | Type | Description |
|---|---|---|
accountId | string | The account the request is scoped to. |
Request body
Audience selection spec for contact search.
| Field | Type | Required | Description |
|---|---|---|---|
attributes | array of objects | no | Attribute conditions a contact must match; conditions are combined with AND. |
attributes[].slug | string | yes | Attribute slug to test - see the attribute metas endpoint. |
attributes[].operator | one of: exists, not_exists, true, false, s_equal, s_not_equal, contains, not_contains, n_equal, n_not_equal, greater_than, greater_than_equal, less_than, less_than_equal, after, before, d_equal, d_not_equal | yes | Comparison to apply. The s_/n_/d_ prefixes select string, number and date comparison; pick the family that matches the attributeās type. |
attributes[].value | any | no | Value to compare against. Its type is dictated by the operator: send an empty string for exists, not_exists, true and false; a number for the n_ and greater_/less_than operators; a date for after, before, d_equal and d_not_equal; a string for the rest. |
includeUnsubscribed | boolean | yes | Include unsubscribed contacts in the results. |
topicId | string | no | Restrict to contacts not unsubscribed from this announcement topic. |
Response
The matching count.
{
"count": 42
}
Errors
| Status | Description |
|---|---|
400 | The request body or parameters failed validation. |
401 | Missing or invalid token, or the token is not authorized for this account/user. |
See Errors and rate limits for what error responses look like.
Curl example
curl --location --request POST 'https://api.sendstreak.com/v2/accounts/YOUR_ACCOUNT_ID/contacts/search/count' \
--header 'Authorization: Bearer YOUR_API_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"attributes": [
{
"slug": "plan",
"operator": "s_equal",
"value": "professional"
}
],
"includeUnsubscribed": false,
"topicId": "6651dd2e4f9b110014ab90cd"
}'