customerInsights
Requires permission analytics:sales:read.
Analytics for one customer over a date range, for the Insights tab of the customer record. A customer outside your book is refused with the same not-found a missing one gets. Needs the sales analytics read permission.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
query CustomerInsights($partnerId: ID!, $range: AnalyticsRangeInput!) {
customerInsights(partnerId: $partnerId, range: $range) {
partnerId
cadence {
daysSinceLastOrder
enough
expectedNextOrderAt
historyOrderCount
longestGapDays
medianGapDays
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "query CustomerInsights($partnerId: ID!, $range: AnalyticsRangeInput!) {\n customerInsights(partnerId: $partnerId, range: $range) {\n partnerId\n cadence {\n daysSinceLastOrder\n enough\n expectedNextOrderAt\n historyOrderCount\n longestGapDays\n medianGapDays\n }\n }\n}",
"variables": {
"partnerId": "id",
"range": {
"from": "2025-01-15T00:00:00Z",
"to": "2025-01-15T00:00:00Z"
}
}
}
EOF
Variables:
{
"partnerId": "id",
"range": {
"from": "2025-01-15T00:00:00Z",
"to": "2025-01-15T00:00:00Z"
}
}
Response:
{
"data": {
"customerInsights": {
"partnerId": "id",
"cadence": {
"daysSinceLastOrder": 0,
"enough": true,
"expectedNextOrderAt": "2025-01-15T00:00:00Z",
"historyOrderCount": 0,
"longestGapDays": 0,
"medianGapDays": 0
}
}
}
}
customerInsights(
partnerId: ID!
range: AnalyticsRangeInput!
): CustomerInsights!
Arguments
customerInsights.partnerId ● ID! non-null scalar
The ID of the customer.
customerInsights.range ● AnalyticsRangeInput! non-null input
The date range and, optionally, the visibility scope.
Type
CustomerInsights object
The customer's analytics, behind the Insights tab of the partner record.