SegmentsPreview segment size

Preview segment size

Count the people a draft definition matches, without saving it. Readable with an agency key (ak_, plus ?location_id=), a viewer key (sk_) or an mcp_ key with segments:read. Attribute-only drafts are counted at read time. Drafts with events run the membership query live, so a preview costs the same as one membership refresh.

curl -X POST "https://mythic-analytics.gulp.workers.dev/builder/segments/preview?location_id=acme-retail" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "definition": {
    "events": [
      {
        "event": "Purchase",
        "within_days": 30,
        "min_count": 10,
        "filters": [
          {
            "property": "$pathname",
            "op": "eq",
            "value": "example_string"
          }
        ]
      }
    ],
    "attribution": "first",
    "search": "acme",
    "has_email": true,
    "channel": "organic",
    "utm_source": "google",
    "utm_medium": "cpc",
    "utm_campaign": "example_string",
    "country": "US",
    "device_type": "mobile",
    "min_sessions": 3,
    "min_identities": 2,
    "active_within_days": 30,
    "inactive_days": 90,
    "first_seen_within_days": 7
  }
}'
{
  "count": 1284
}
POST
/segments/preview
POST
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token
Bearer Tokenstring
Required

Builder key as a bearer token. Use an agency key for full CRUD (Bearer ak_...) or a viewer key for read-only access (Bearer sk_...). Scoped keys (mcp_) are accepted too and need segments:read or segments:write. See Using an mcp_ key over HTTP.

Builder key as a bearer token. Use an agency key for full CRUD (Bearer ak_...) or a viewer key for read-only access (Bearer sk_...). Scoped keys (mcp_) are accepted too and need segments:read or segments:write. See Using an mcp_ key over HTTP.
query
location_idstring

Client location to scope the request to. Required when authenticating with an agency key (ak_). Ignored for viewer keys (sk_).

Content-Typestring
Required

The media type of the request body

Options: application/json
definitionobject
Required

Person-attribute filters plus an optional events list of event conditions. Everything present combines with AND. Any subset may be used; at least one filter or condition is required. Unknown keys are rejected. Examples: { "events": [{ "event": "Purchase" }] } = people who have ever done Purchase. { "events": [{ "event": "$pageview", "within_days": 30, "filters": [{ "property": "$pathname", "op": "eq", "value": "/xyz" }] }] } = people who visited /xyz in the last 30 days. The attribution field picks which touch the attribution filters (channel, utm_source, utm_medium, utm_campaign, country, device_type) match against — last (default), first, or session. Example: { "utm_source": "fb", "attribution": "session" } = "everyone who ever had a session that arrived via fb".

Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. Builder key as a bearer token. Use an agency key for full CRUD (Bearer ak_...) or a viewer key for read-only access (Bearer sk_...). Scoped keys (mcp_) are accepted too and need segments:read or segments:write. See Using an mcp_ key over HTTP.

Query Parameters

location_idstring

Client location to scope the request to. Required when authenticating with an agency key (ak_). Ignored for viewer keys (sk_).

Example:
acme-retail

Body

application/json
definitionobject
Required

Person-attribute filters plus an optional events list of event conditions. Everything present combines with AND. Any subset may be used; at least one filter or condition is required. Unknown keys are rejected.

Examples: { "events": [{ "event": "Purchase" }] } = people who have ever done Purchase. { "events": [{ "event": "$pageview", "within_days": 30, "filters": [{ "property": "$pathname", "op": "eq", "value": "/xyz" }] }] } = people who visited /xyz in the last 30 days.

The attribution field picks which touch the attribution filters (channel, utm_source, utm_medium, utm_campaign, country, device_type) match against — last (default), first, or session. Example: { "utm_source": "fb", "attribution": "session" } = "everyone who ever had a session that arrived via fb".

Responses

countinteger

Distinct people matching the draft right now.