Skip to main content
POST
/
platform-api
/
v1
/
analytics
/
query
Query analytics
curl --request POST \
  --url https://app.sagepilot.ai/platform-api/v1/analytics/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "dataset": "<string>",
  "measures": [
    "<string>"
  ]
}
'
{
  "dataset": "tickets",
  "rows": [],
  "summary": {
    "ticket_count": 1128
  },
  "meta": {
    "applied_filters": {
      "channel_ids": [],
      "channel_kinds": [],
      "statuses": [],
      "priorities": [],
      "assignee_ids": [],
      "assignee_types": [],
      "team_ids": [],
      "tag_ids": [],
      "excluded_tag_ids": [],
      "queue_statuses": [],
      "inferred_csat_scores": [],
      "user_csat_scores": [],
      "custom_fields": [],
      "score_sources": [],
      "actor_ids": [],
      "actor_types": [],
      "entity_types": []
    },
    "grain": null,
    "timezone": "UTC",
    "time_anchor": "created_at",
    "requested_measures": [
      "ticket_count"
    ],
    "requested_dimensions": [],
    "generated_at": "2026-05-29T16:16:53.572328Z",
    "cursor": null
  }
}
{
  "dataset": "tickets",
  "rows": [],
  "summary": {
    "ticket_count": 1128
  },
  "meta": {
    "applied_filters": {
      "channel_ids": [],
      "channel_kinds": [],
      "statuses": [],
      "priorities": [],
      "assignee_ids": [],
      "assignee_types": [],
      "team_ids": [],
      "tag_ids": [],
      "excluded_tag_ids": [],
      "queue_statuses": [],
      "inferred_csat_scores": [],
      "user_csat_scores": [],
      "custom_fields": [],
      "score_sources": [],
      "actor_ids": [],
      "actor_types": [],
      "entity_types": []
    },
    "grain": null,
    "timezone": "UTC",
    "time_anchor": "created_at",
    "requested_measures": [
      "ticket_count"
    ],
    "requested_dimensions": [],
    "generated_at": "2026-05-29T16:16:53.572328Z",
    "cursor": null
  }
}
Use this endpoint to run analytics queries for a granted dataset. Query results can be returned as summary totals or grouped rows.

Required access

AuthenticationScopeDataset grant
API client v2analytics.queryThe dataset used in the request body, such as tickets, messages, outbound_messages, marketing_attribution, csat, or workforce_activity.

Body

dataset
string
required
Dataset to query. For example, tickets, messages, outbound_messages, marketing_attribution, csat, or workforce_activity.
measures
string[]
required
Measures to calculate. For example, ["ticket_count", "open_ticket_count"] for the tickets dataset or ["message_count", "customer_message_count"] for the messages dataset.
dimensions
string[]
Optional dimensions to group results. For example, ["channel_kind"], ["priority"], or ["day_of_week", "hour_of_day"].
filters
object
Optional filter object. For example, { "channel_ids": ["<channel_id>"], "statuses": ["open"] }. For channel, agent, pilot, team, or workspace IDs, see Resource IDs.
time
object
Optional time window. Include this for trend queries or date-bounded summaries.
time.start
string
ISO start timestamp. For example, 2026-05-01T00:00:00.000Z.
time.end
string
ISO end timestamp. For example, 2026-05-29T23:59:59.999Z.
time.timezone
string
Timezone used to interpret the time window. For example, Asia/Kolkata or UTC.
time.grain
string
Time grain for grouped trend results. Use day, week, or month.
time.anchor
string
Timestamp field used for the query window. For example, created_at, closed_at, message_created_at, sent_at, or order_created_at.
business_hours
object
Optional business-hours configuration for business-hours duration measures.
business_hours.timezone
string
Business-hours timezone. For example, Asia/Kolkata.
business_hours.start_time
string
Local business day start time. For example, 09:00.
business_hours.end_time
string
Local business day end time. For example, 18:00.
business_hours.working_days
integer[]
Working days as weekday numbers. For example, [1, 2, 3, 4, 5] for Monday through Friday.
result_format
string
default:"rows"
Response shape. Use summary for aggregate totals or rows for grouped rows.
sort
object[]
Optional sort instructions. For example, [{ "field": "ticket_count", "direction": "desc" }].
sort[].field
string
Field to sort by, usually a requested measure or dimension.
sort[].direction
string
Sort direction. Use asc or desc.
limit
integer
Maximum number of rows to return. For example, 100.
cursor
string
Cursor from the previous response when paginating through row results.

Notes

  • This endpoint uses API client v2 credentials. See API client v2.