Analytics

Run an analytics query

Changed on

Aggregates metric values and conversation counts over a time window and returns one series per measure, with a total for the window and per-interval buckets. The same query a dashboard widget runs, without saving anything.

  • measures: what to aggregate. A METRIC measure names its metric by slug; CONVERSATION counts conversations; UPTIME reads health checks. The aggregation defaults by the metric's output type.
  • timeRange: LAST n DAYS/WEEKS/MONTHS, a CALENDAR_ALIGNED period (TODAY, THIS_MONTH, ...), FIXED from/to, or SINCE. Defaults to the last 30 days; at most 731 days. Calendar periods and buckets align to timezone (IANA, default UTC).
  • filters apply to every measure; a measure's own filters add to them.
  • breakdown on a measure returns one series per value (largest 50 kept).
  • comparisonGroups (2 to 5) run every measure once per named filter set; comparisonMode: PREVIOUS_PERIOD adds the preceding window's values.

Values are in the metric's display units. A PASS_RATE is a 0 to 1 share; sampleSize 0 means no data. A query the analytics store cannot answer returns 400 naming the unsupported part.

post/v1/analytics/query

Request

  • Base URL
    https://api.roark.ai
  • URL
    https://api.roark.ai/v1/analytics/query
  • Auth
    HTTP bearer

Request body

interval'HOUR' | 'DAY' | 'WEEK' | 'MONTH'

Bucket size. Defaults from the window's length and steps coarser when the window would exceed 500 buckets.

comparisonMode'NONE' | 'PREVIOUS_PERIOD'

PREVIOUS_PERIOD adds the preceding window of the same length to every series.

timezonestring

IANA zone that buckets and calendar periods align to, e.g. America/New_York. Defaults to UTC.

includeBucketsboolean

Set false to return only the window totals.

Example request

{
  "measures": [
    {
      "metric": "sentiment_score",
      "aggregation": "AVG"
    },
    {
      "type": "CONVERSATION",
      "aggregation": "COUNT"
    }
  ],
  "timeRange": {
    "type": "LAST",
    "value": 7,
    "unit": "DAYS"
  },
  "interval": "DAY",
  "timezone": "Europe/London",
  "filters": [
    {
      "type": "MODALITY",
      "value": "call"
    }
  ]
}

Response

The query result

Changes

    • info

      the request property //// became optional

    • info

      the request property // became optional

    • info

      the request property //// became optional

    • info

      added the new IS_NOT_SET enum value to the request property ////

    • info

      added the new IS_NOT_SET enum value to the request property //

    • info

      added the new IS_NOT_SET enum value to the request property ////

    • info

      added the new IS_NOT_SET enum value to the request property //

    • info

      added the new IS_SET enum value to the request property ////

    • info

      added the new IS_SET enum value to the request property //

    • info

      added the new IS_SET enum value to the request property ////

    • info

      added the new IS_SET enum value to the request property //

    • info

      endpoint added