You are viewing docs for v0.25.
The latest release is v0.25.0.

Queries API

Five analytical query endpoints power the dashboard: segmentation, funnel, retention, flows, and sessions. All are POST /api/query/*, require the admin Bearer key (Authorization: Bearer $API_KEY - superadmin key or an account token), and take an optional projectId in the body (defaulting to the caller's oldest project; required for a superadmin key). Dates from and to are YYYY-MM-DD strings.

These are the stable v0 wrapper endpoints every dashboard screen already speaks. POST /api/query runs trend and funnel analyses through the newer Query IR pipeline instead and is the forward path, but is not yet documented here - it takes a free-form IR document rather than a fixed shape, so it does not fit a parameter table the way these five do. All five below are subject to the /api/query/* analytics rate limit (default 30 requests / 60s per authenticated user, or per source IP for the superadmin key).

Segmentation

POST/api/query/segmentation

Time-bucketed event trend, optionally split by a property and filtered.

NameTypeRequiredDefaultDescription
eventstringRequired-

Event name, or the $all_events sentinel to match every event.

fromstring (date)Required-

YYYY-MM-DD, inclusive.

tostring (date)Required-

YYYY-MM-DD, inclusive.

unit"hour" | "day" | "week" | "month"Required-

Bucket size.

type"total" | "unique"Required-

Count every occurrence, or count distinct users.

breakdownstringOptional-

Property key to split the series by; one series per observed value.

filtersPropertyFilter[]Optional-

Up to 20 property filters, ANDed together.

filters[].keystringRequired-

Property key to filter on.

filters[].op"eq" | "neq" | "contains" | "set" | "not_set"Required-

Comparison operator.

filters[].valuestringOptional-

Required for eq/neq/contains; omitted for set/not_set.

projectIdstringOptional-

Defaults to the caller's oldest project. Required for a superadmin key.

bash
curl -X POST https://cohorly-service.velloalabs.com/api/query/segmentation \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"event": "Page Viewed",
"from": "2026-07-01",
"to": "2026-07-31",
"unit": "day",
"type": "unique",
"breakdown": "plan",
"filters": [{ "key": "path", "op": "contains", "value": "/pricing" }]
}'
json
{
"buckets": ["2026-07-01", "2026-07-02"],
"series": [
{
"name": "Signed Up",
"data": [
{ "bucket": "2026-07-01", "value": 12 },
{ "bucket": "2026-07-02", "value": 18 }
]
}
]
}

Funnel

POST/api/query/funnel

Measure how many users complete an ordered sequence of steps within a conversion window.

NameTypeRequiredDefaultDescription
stepsstring[]Required-

2 to 10 ordered event names.

fromstring (date)Required-

YYYY-MM-DD, inclusive.

tostring (date)Required-

YYYY-MM-DD, inclusive.

windowDaysintegerOptional30

Max elapsed days from step 0 for a user to still count as converting at a later step (1-366).

breakdownstringOptional-

Property key to split each step's segments by.

filtersPropertyFilter[]Optional-

Up to 20 property filters, ANDed together (same shape as segmentation).

projectIdstringOptional-

Defaults to the caller's oldest project. Required for a superadmin key.

bash
curl -X POST https://cohorly-service.velloalabs.com/api/query/funnel \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"steps": ["Viewed Pricing", "Signed Up", "Upgraded"],
"from": "2026-07-01",
"to": "2026-07-31",
"windowDays": 14
}'
json
[
{
"event": "Signed Up",
"count": 340,
"conversionFromPrevious": 0.62,
"conversionFromStart": 0.62,
"droppedCount": 208,
"dropoffRate": 0.38,
"convertedUserIds": ["user-42"],
"droppedUserIds": ["user-7"],
"segments": [],
"meanSecondsToConvert": 145.2,
"medianSecondsToConvert": 98
}
]

Retention

POST/api/query/retention

Track how many users who performed a bornEvent came back to perform a returnEvent in later periods.

NameTypeRequiredDefaultDescription
bornEventstringRequired-

Event name, or the $all_events sentinel.

returnEventstringRequired-

Event name, or the $all_events sentinel.

fromstring (date)Required-

YYYY-MM-DD, inclusive.

tostring (date)Required-

YYYY-MM-DD, inclusive.

unit"day" | "week"Optionalweek

Cohort bucket size.

bucketsintegerOptional8

Number of return periods to compute (1-16).

projectIdstringOptional-

Defaults to the caller's oldest project. Required for a superadmin key.

Bucket boundaries (day, week, month) are computed in your workspace's time zone, so daily numbers match what you see in the dashboard. counts[0] is the cohort's own period (same-bucket return); counts[i] is bucket i after that.

bash
curl -X POST https://cohorly-service.velloalabs.com/api/query/retention \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"bornEvent": "Signed Up",
"returnEvent": "$all_events",
"from": "2026-05-01",
"to": "2026-07-31",
"unit": "week",
"buckets": 8
}'
json
[{ "cohort": "2026-07-06", "size": 120, "counts": [120, 54, 40, 31] }]

Flows

POST/api/query/flows

Top user paths before or after an anchor event.

NameTypeRequiredDefaultDescription
eventstringRequired-

Anchor event name - a concrete name, not the $all_events sentinel.

direction"after" | "before"Required-

Walk the path forward or backward from the anchor.

stepsintegerOptional3

Path length to walk from the anchor (1-5).

fromstring (date)Required-

YYYY-MM-DD, inclusive.

tostring (date)Required-

YYYY-MM-DD, inclusive.

limitintegerOptional20

Max number of distinct paths to return (1-100).

projectIdstringOptional-

Defaults to the caller's oldest project. Required for a superadmin key.

total is the number of users counted, and the counts of all paths add up to it. At most 50,000 users with the anchor event are counted, the first ones by distinct_id; past that the response carries "truncated": true and covers only those users. For each user, at most 50 events are read from the anchor on (the anchor included), so a long run of the same event can shorten that user's path.

bash
curl -X POST https://cohorly-service.velloalabs.com/api/query/flows \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"event": "Signed Up",
"direction": "after",
"steps": 3,
"from": "2026-07-01",
"to": "2026-07-31",
"limit": 20
}'
json
{
"paths": [{ "path": ["Signed Up", "Viewed Dashboard", "Upgraded"], "count": 88 }],
"total": 340
}

Sessions

POST/api/query/sessions

Session counts and average duration over time.

Sessions are computed at query time (30 minute inactivity timeout by default, COHORLY_SESSION_TIMEOUT_MS) and bucketed the same way as segmentation.

NameTypeRequiredDefaultDescription
fromstring (date)Required-

YYYY-MM-DD, inclusive.

tostring (date)Required-

YYYY-MM-DD, inclusive.

unit"hour" | "day" | "week" | "month"Optional-

Bucket size.

projectIdstringOptional-

Defaults to the caller's oldest project. Required for a superadmin key.

bash
curl -X POST https://cohorly-service.velloalabs.com/api/query/sessions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "from": "2026-07-01", "to": "2026-07-31", "unit": "day" }'
json
{ "series": [{ "bucket": "2026-07-01", "sessions": 40, "avgDurationSec": 212.5 }] }
PreviousAdmin API
NextAPI keys