---
title: "Create Analytics Queries"
method: POST
path: "/analytics"
tags: ["Analytics"]
---

# Create Analytics Queries

`POST /analytics`

## Request body

- AnalyticsQueryDTO
  - `queries` AnalyticsQuery[], required — This is the list of metric queries you want to perform.
    - `table` 'call' | 'subscription', required — This is the table you want to query.
    - `groupBy` string[] — This is the list of columns you want to group by.
    - `groupByVariableValue` VariableValueGroupBy[] — This is the list of variable value keys you want to group by.
      - `key` string, required — This is the key of the variable value to group by.
    - `name` string, required — This is the name of the query. This will be used to identify the query in the response.
    - `timeRange` TimeRange
      - `step` 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'decade' | 'century' | 'millennium' — This is the time step for aggregations. If not provided, defaults to returning for the entire time range.
      - `start` string, date-time — This is the start date for the time range. If not provided, defaults to the 7 days ago.
      - `end` string, date-time — This is the end date for the time range. If not provided, defaults to now.
      - `timezone` string — This is the timezone you want to set for the query. If not provided, defaults to UTC.
    - `operations` AnalyticsOperation[], required — This is the list of operations you want to perform.
      - `operation` 'sum' | 'avg' | 'count' | 'min' | 'max' | 'history', required — This is the aggregation operation you want to perform.
      - `column` 'id' | 'cost' | 'costBreakdown.llm' | 'costBreakdown.stt' | 'costBreakdown.tts' | 'costBreakdown.vapi' | 'costBreakdown.transport' | 'costBreakdown.analysisBreakdown.summary' | 'costBreakdown.transcriber' | 'costBreakdown.ttsCharacters' | 'costBreakdown.llmPromptTokens' | 'costBreakdown.llmCompletionTokens' | 'costBreakdown.llmCachedPromptTokens' | 'duration' | 'concurrency' | 'minutesUsed', required — This is the columns you want to perform the aggregation operation on.
      - `alias` string — This is the alias for column name returned. Defaults to `${operation}${column}`.

## Response `200`

- AnalyticsQueryResult[]
  - `name` string, required — This is the unique key for the query.
  - `timeRange` TimeRange, required
    - `step` 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'decade' | 'century' | 'millennium' — This is the time step for aggregations. If not provided, defaults to returning for the entire time range.
    - `start` string, date-time — This is the start date for the time range. If not provided, defaults to the 7 days ago.
    - `end` string, date-time — This is the end date for the time range. If not provided, defaults to now.
    - `timezone` string — This is the timezone you want to set for the query. If not provided, defaults to UTC.
  - `result` object[], required — This is the result of the query, a list of unique groups with result of their aggregations. Example: "result": [ { "date": "2023-01-01", "assistantId": "123", "endedReason": "customer-ended-call", "sumDuration": 120, "avgCost": 10.5 }, { "date": "2023-01-02", "assistantId": "123", "endedReason": "customer-did-not-give-microphone-permission", "sumDuration": 0, "avgCost": 0 }, // Additional results ]

## Other responses

- `201`

## Changes

> 57 revisions in range; 2 not diffed, 9 could not be searched.

- **2025-08-20** `c43b85e5bd25` — 3 info
  - added the new `costBreakdown.analysisBreakdown.summary` enum value to the request property `queries/items/operations/items/column`
  - added the new `costBreakdown.transcriber` enum value to the request property `queries/items/operations/items/column`
  - added the new `costBreakdown.transport` enum value to the request property `queries/items/operations/items/column`

[Change history](https://skmtc.dev/vapiai/apis/vapi-api/changes/analytics/post.md)

---

[API](https://skmtc.dev/vapiai/apis/vapi-api.md) · [All operations](https://skmtc.dev/vapiai/apis/vapi-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/vapiai/vapi-api/revisions/872ff45af53b/schema)
