CDP REST APIAPI Reference
Query Metrics
Compute sum/avg/min/max over a property for profiles or events in your scope.
POST /cdp/query/{itemType}/{property}/metrics — compute a requested subset of
sum / avg / min / max over a numeric property, for the items matching a condition.
itemType is profile or event; anything else returns 404.
Your brand's scope is AND-ed into the condition server-side, so the metrics only ever
cover your brand's data. The condition (optional) uses the same public condition subset as
Query Count.
Property allowlist
| itemType | Addressable properties |
|---|---|
profile | properties.* |
event | properties.*, flattenedProperties.*, timeStamp, eventType |
systemProperties and scope/shopDomain paths are rejected with 400.
Request
POST /cdp/query/{itemType}/{property}/metrics
Authorization: Bearer vyg_…
Content-Type: application/json| Field | Type | Required | Description |
|---|---|---|---|
metrics | string[] | yes | Non-empty subset of sum, avg, min, max. |
condition | object | no | Unomi condition (public subset). Omit for in-scope. |
{
"metrics": ["sum", "avg"],
"condition": {
"type": "eventTypeCondition",
"parameterValues": { "eventTypeId": "order" }
}
}Response 200
{
"itemType": "event",
"property": "properties.total",
"metrics": { "_sum": 125430.5, "_avg": 87.2 },
"scope": "your-shop.myshopify.com"
}| Field | Type | Description |
|---|---|---|
itemType | string | The queried item type. |
property | string | The property the metrics were computed over. |
metrics | object | Metric map as computed by the CDP (keys like _sum, _avg, …). |
scope | string | Your brand's connected shop domain. |
Example
curl -s -X POST "https://cdp.vyg.app/cdp/query/event/properties.total/metrics" \
-H "Authorization: Bearer vyg_your_key_here" \
-H "Content-Type: application/json" \
-d '{"metrics":["sum","avg","max"]}'Errors
| Status | When |
|---|---|
400 | Missing/unknown metrics, property not in the allowlist, or bad 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). |