Fetch Workspace Stats

Closed Beta — not yet enabled for all workspaces (403 otherwise). Request access at https://developers.myclickfunnels.com/page/code-support.

Aggregate statistics over a filtered set of records, without listing the records. Use this for any
"how many", "what's the breakdown", or "what's the total" question: it is dramatically cheaper than paging
a collection and counting client-side.

One workspace endpoint serves every analyzable resource. Name the resource and request the stats you want
as query parameters:

GET /api/v2/workspaces/{workspace_id}/stats?resource=contact&count=true&count_by[property]=is_active&filter[tag_ids]=42

A flag of true computes the stat; an object-style query supplies a stat's parameters. Omit a stat (or pass
false) to skip it. Calling with only resource returns a 422 that lists the stats and property values the
named resource supports, so the endpoint is self-describing.

Narrowing the set

The same selectors the resource's own index accepts, composed with AND:

  • filter - simple field matches, e.g. filter[tag_ids]=42 for contacts
  • stable_id - a one-off Refine filter token, e.g. from POST /workspaces/{workspace_id}/contacts/filters
  • stored_filter_id - a saved Refine filter id

Omit all three to report on every record of that resource in the workspace.

Counts are capped

Counting a large filtered audience scans every matching row, so every stat here is bounded. When the
matching set exceeds the cap, count returns the cap and the response carries count_capped_at - the real
total is higher, so narrow the filter. Exact aggregates (created_at_range, sum) are not computed at all
beyond the cap; they are named in unavailable rather than returned as a confidently wrong number.

Access

Computing a statistic persists nothing, so a token with read-only access may call it. Authorization
follows the category of the resource being analyzed: contact requires read access to Contacts, order
requires read access to Store.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Path Params
string
required
Query Params
string
enum
required

The resource to report on.

Allowed:
boolean
Defaults to false

How many records match. Capped - see count_capped_at in the response.

count_by
object

Breaks the matching set down by one allow-listed property, returning a count per distinct value.

boolean
Defaults to false

The earliest and latest created_at in the matching set. Exact, so it is only computed when the set is within the cap.

sum
object

Totals one allow-listed numeric property. Exact, so it is only computed when the set is within the cap. Not available for every resource.

filter
object

Simple field matches, using the same keys the resource's index accepts - contact: id, email_address, is_active, tag_ids; order: id, contact_id, order_type, billing_status, service_status, live_mode. Comma-separated values match any of them.

string

A URL-encoded Refine stable_id token, applied to the set before computing. Same token format the resource's index accepts; for contacts it can come from POST /workspaces/{workspace_id}/contacts/filters. Pass it exactly as returned.

string

The id or public_id of a saved Refine filter in this workspace, applied to the set before computing. Must match the resource's filter type.

Responses

Language
Credentials
Bearer
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json