Query Aggregate
POST /cdp/query/{itemType}/{property}/aggregate — bucketed aggregation over a property for
the items matching a condition. itemType is profile or event; anything else returns
404. Three aggregate types are supported:
| Type | Buckets | Parameters |
|---|---|---|
date | Date histogram (one bucket per interval) | interval (required), format |
dateRange | One bucket per supplied date range | ranges (required), format |
numericRange | One bucket per supplied numeric range | ranges (required) |
Your brand’s scope is AND-ed into the condition server-side, so every bucket — and the
_all / _filtered / _missing accounting — only ever covers your brand’s data. The
optional condition uses the same public condition subset as
Query Count, and the same property allowlist as
Query Metrics applies (no systemProperties, no scope paths).
Request
Section titled “Request”POST /cdp/query/{itemType}/{property}/aggregateAuthorization: Bearer vyg_…Content-Type: application/json| Field | Type | Required | Description |
|---|---|---|---|
aggregate | object | yes | { type, interval?, format?, ranges? } (see below). |
condition | object | no | Unomi condition (public subset). Omit for in-scope. |
Date histogram (weekly buckets over event timestamps):
{ "aggregate": { "type": "date", "interval": "1w", "format": "yyyy-MM-dd" }, "condition": { "type": "eventTypeCondition", "parameterValues": { "eventTypeId": "order" } }}Numeric ranges (ranges entries take from / to numbers and an optional key; date
ranges take date strings — at most 20 ranges per request):
{ "aggregate": { "type": "numericRange", "ranges": [ { "key": "low", "to": 50 }, { "key": "mid", "from": 50, "to": 250 }, { "key": "high", "from": 250 } ] }}Response 200
Section titled “Response 200”{ "itemType": "event", "property": "timeStamp", "results": { "_all": 9120, "_filtered": 4211, "2026-05-04": 980, "2026-05-11": 1102, "2026-05-18": 1064, "2026-05-25": 1065, "_missing": 0 }, "scope": "your-shop.myshopify.com"}| Field | Type | Description |
|---|---|---|
itemType | string | The queried item type. |
property | string | The property the aggregation bucketed on. |
results | object | Bucket→count map plus _all / _filtered / _missing accounting keys. |
scope | string | Your brand’s connected shop domain. |
Example
Section titled “Example”curl -s -X POST "https://cdp.vyg.app/cdp/query/event/timeStamp/aggregate" \ -H "Authorization: Bearer vyg_your_key_here" \ -H "Content-Type: application/json" \ -d '{"aggregate":{"type":"date","interval":"1w","format":"yyyy-MM-dd"}}'Errors
Section titled “Errors”| Status | When |
|---|---|
400 | Invalid aggregate (unknown type, missing interval/ranges), property, or condition. |
401 | Missing or invalid credential. |
403 | No connected shop resolves a scope. |
404 | Unknown itemType (only profile and event are supported). |
429 | Query throttle exceeded — retry with backoff. |
502 | The CDP could not evaluate the query. |
503 | The CDP is temporarily unavailable (retry). |