Queries API
Three analytical query endpoints power the dashboard: segmentation, funnels, and retention. All are POST /api/query/*, require the admin Bearer key, and take an optional projectId in the body (defaulting to the default project). Dates from and to are YYYY-MM-DD strings.
Segmentation
Count occurrences of an event over time, bucketed by unit, optionally split by a breakdown property and filtered.
Request
tsinterface SegmentationQuery {event: string;from: string; // YYYY-MM-DDto: string;unit: "hour" | "day" | "week" | "month";type: "total" | "unique"; // total events or unique usersbreakdown?: string; // property to split series byfilters?: PropertyFilter[];projectId?: number;}interface PropertyFilter {key: string;op: "eq" | "neq" | "contains" | "set" | "not_set";value?: string;}
bashcurl -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-06-01","to": "2026-06-30","unit": "day","type": "unique","breakdown": "plan","filters": [{ "key": "path", "op": "contains", "value": "/pricing" }]}'
Response
One series per breakdown value (or a single series if no breakdown), aligned to a shared buckets axis.
tsinterface SegmentationResult {buckets: string[];series: {name: string; // breakdown value or event namedata: { bucket: string; value: number }[];}[];}
Funnel
Measure how many users complete an ordered sequence of steps within a conversion window.
Request
tsinterface FunnelQuery {steps: string[]; // ordered event namesfrom: string;to: string;windowDays: number; // conversion window per userprojectId?: number;}
bashcurl -X POST https://cohorly-service.velloalabs.com/api/query/funnel \-H "Authorization: Bearer $API_KEY" \-H "Content-Type: application/json" \-d '{"steps": ["Signed Up", "Item Added", "Purchased"],"from": "2026-06-01","to": "2026-06-30","windowDays": 7}'
Response
An array of step results, one per step in order.
tsinterface FunnelStepResult {event: string;count: number; // unique users reaching this stepconversionFromPrevious: number; // 0..1conversionFromStart: number; // 0..1}
Retention
Track how many users who performed a bornEvent came back to perform a returnEvent in later periods.
Request
tsinterface RetentionQuery {bornEvent: string;returnEvent: string;from: string;to: string;unit: "day" | "week";buckets: number; // number of return periods to computeprojectId?: number;}
bashcurl -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": "Page Viewed","from": "2026-06-01","to": "2026-06-30","unit": "week","buckets": 6}'
Response
An array of cohorts. counts[i] is the number of users from that cohort who returned in period i (0 = the cohort's own period).
tsinterface RetentionCohort {cohort: string; // bucket start datesize: number;counts: number[]; // counts[i] = users returning in bucket i}