Concept
Sync vs async counts
Most counts complete in milliseconds and run synchronously through /data/count. When a query is too heavy for the request window (or you want to fan out several variants on the same base), switch to /count_requests and poll for the result.
When to go async
Use POST /api/v1/data/count when you want a single number back in the same response. Use POST /api/v1/count_requests when any of these are true:
- The filter is broad enough that the count won't finish inside the synchronous request window.
- You need several related counts that share a base filter. Derivative counts let you compute them all in one job instead of N round-trips.
- You're running counts in the background of a UI and don't want the user's request to wait.
Submitting a job
The body looks exactly like a sync count, with the same data_source_id, filters, select_type, and suppression. The response is a job object with status: "pending" and an id you'll poll.
{
"data_source_id": 1,
"filters": [
{ "field": "state", "values": ["TX"] }
]
}
{
"id": 8412,
"status": "pending",
"submitted_at": "2026-05-20T14:22:11Z"
}
Polling for results
Hit GET /api/v1/count_requests/:id on an interval until status flips from "pending" to "ready". Most jobs finish in seconds; allow several minutes for very broad filters. A reasonable backoff is 1s → 3s → 10s, capped at 30s.
{ "id": 8412, "status": "pending" }
{
"id": 8412,
"status": "ready",
"results": { "base": 134195581 }
}
Derivative counts
Derivatives are modifications layered on top of the base filter. Each one inherits everything from the base and then applies its own additional fields or filters, so you can answer "how many of these also have a phone? have an email? are 18–21?" in a single job.
{
"data_source_id": 1,
"filters": [{ "field": "state", "values": ["TX"] }],
"derivatives": [
{ "emails": "all" },
{ "dnc": false },
{ "filters": [{ "field": "est_age", "values": ["18-21", "25-30"] }] }
]
}
The result array is positionally aligned to your derivatives array, with the base count alongside.
{
"id": 8413,
"status": "ready",
"results": {
"base": 18962721,
"derivatives": [12042001, 17820944, 4012845]
}
}
Used by