Skip to content

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:

TypeBucketsParameters
dateDate histogram (one bucket per interval)interval (required), format
dateRangeOne bucket per supplied date rangeranges (required), format
numericRangeOne bucket per supplied numeric rangeranges (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).

POST /cdp/query/{itemType}/{property}/aggregate
Authorization: Bearer vyg_…
Content-Type: application/json
FieldTypeRequiredDescription
aggregateobjectyes{ type, interval?, format?, ranges? } (see below).
conditionobjectnoUnomi 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 }
]
}
}
{
"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"
}
FieldTypeDescription
itemTypestringThe queried item type.
propertystringThe property the aggregation bucketed on.
resultsobjectBucket→count map plus _all / _filtered / _missing accounting keys.
scopestringYour brand’s connected shop domain.
Terminal window
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"}}'
StatusWhen
400Invalid aggregate (unknown type, missing interval/ranges), property, or condition.
401Missing or invalid credential.
403No connected shop resolves a scope.
404Unknown itemType (only profile and event are supported).
429Query throttle exceeded — retry with backoff.
502The CDP could not evaluate the query.
503The CDP is temporarily unavailable (retry).