Skip to content

This page is available as Markdown at https://developers.klaviyo.com/en/v2025-01-15/reference/query_metric_aggregates.md. An index of every page is at https://developers.klaviyo.com/llms.txt.

KlaviyoKlaviyoDevelopers
v2025-01-15

You're reading the reference for API revision 2025-01-15. The latest revision is 2026-10-15. See this page in the latest revision.

Query Metric Aggregates

POSThttps://a.klaviyo.com/api/metric-aggregates

Query and aggregate event data associated with a metric, including native Klaviyo metrics, integration-specific metrics, and custom events (not to be confused with custom metrics, which are not supported at this time). Queries must be passed in the JSON body of your POST request.

To request campaign and flow performance data that matches the data shown in Klaviyo's UI, we recommend the Reporting API.

Results can be filtered and grouped by time, event, or profile dimensions.

To learn more about how to use this endpoint, check out our new Using the Query Metric Aggregates Endpoint guide.

For a comprehensive list of request body parameters, native Klaviyo metrics, and their associated attributes for grouping and filtering, please refer to the metrics attributes guide.

Revision header
revision: 2025-01-15required
Scopes
metrics:read
Rate limits
Burst: 3/sSteady: 60/m

Headers

  • revision#stringrequired

    API endpoint revision (format: YYYY-MM-DD[.suffix])

    2025-01-15

Request body

Content type: application/vnd.api+jsonrequired

  • data#objectrequired
    Show 2 fields
    • type#stringrequired
      Allowed values:
      • metric-aggregate
    • attributes#objectrequired
      Show 10 fields
      • metric_id#stringrequired

        The metric ID used in the aggregation.

        Example: 0rG4eQ

      • page_cursor#string

        Optional pagination cursor to iterate over large result sets

      • measurements#string[]required

        Measurement key, e.g. unique, sum_value, count

        Allowed values:
        • count
        • sum_value
        • unique
      • interval#stringnullable

        Aggregation interval, e.g. "hour", "day", "week", "month"

        Allowed values:
        • day
        • hour
        • month
        • week

        Default: day

        Example: day

      • page_size#integernullable

        Alter the maximum number of returned rows in a single page of aggregation results

        Default: 500

        Example: 500

      • by#string[]nullable

        Optional attribute(s) used for partitioning by the aggregation function

        Show 33 allowed values
        • $attributed_channel
        • $attributed_flow
        • $attributed_message
        • $attributed_variation
        • $campaign_channel
        • $flow
        • $flow_channel
        • $message
        • $message_send_cohort
        • $value_currency
        • $variation
        • $variation_send_cohort
        • Bot Click
        • Bounce Type
        • Campaign Name
        • Client Canonical
        • Client Name
        • Client Type
        • Email Domain
        • Failure Source
        • Failure Type
        • From Number
        • From Phone Region
        • Inbox Provider
        • List
        • Message Name
        • Message Type
        • Method
        • Subject
        • To Number
        • To Phone Region
        • URL
        • form_id
      • return_fields#string[]nullable

        Provide fields to limit the returned data

      • filter#string[]required

        List of filters, must include time range using ISO 8601 format (YYYY-MM-DDTHH:MM:SS.mmmmmm). These filters follow a similar format to those in GET requests, the primary difference is that this endpoint asks for a list. The time range can be filtered by providing a greater-or-equal and a less-than filter on the datetime field.

      • timezone#stringnullable

        The timezone used for processing the query, e.g. 'America/New_York'. This field is validated against a list of common timezones from the IANA Time Zone Database. While most are supported, a few notable exceptions are Factory, Europe/Kyiv and Pacific/Kanton. This field is case-sensitive.

        Default: UTC

        Example: America/New_York

      • sort#string

        Provide a sort key (e.g. -$message)

        Show 72 allowed values
        • $attributed_channel
        • -$attributed_channel
        • $attributed_flow
        • -$attributed_flow
        • $attributed_message
        • -$attributed_message
        • $attributed_variation
        • -$attributed_variation
        • $campaign_channel
        • -$campaign_channel
        • $flow
        • -$flow
        • $flow_channel
        • -$flow_channel
        • $message
        • -$message
        • $message_send_cohort
        • -$message_send_cohort
        • $value_currency
        • -$value_currency
        • $variation
        • -$variation
        • $variation_send_cohort
        • -$variation_send_cohort
        • Bot Click
        • -Bot Click
        • Bounce Type
        • -Bounce Type
        • Campaign Name
        • -Campaign Name
        • Client Canonical
        • -Client Canonical
        • Client Name
        • -Client Name
        • Client Type
        • -Client Type
        • Email Domain
        • -Email Domain
        • Failure Source
        • -Failure Source
        • Failure Type
        • -Failure Type
        • From Number
        • -From Number
        • From Phone Region
        • -From Phone Region
        • Inbox Provider
        • -Inbox Provider
        • List
        • -List
        • Message Name
        • -Message Name
        • Message Type
        • -Message Type
        • Method
        • -Method
        • Subject
        • -Subject
        • To Number
        • -To Number
        • To Phone Region
        • -To Phone Region
        • URL
        • -URL
        • count
        • -count
        • form_id
        • -form_id
        • sum_value
        • -sum_value
        • unique
        • -unique

Responses

200Success

Content type: application/vnd.api+json

  • data#objectrequired
    Show 4 fields
    • type#stringrequired
      Allowed values:
      • metric-aggregate
    • id#stringrequired

      Ephemeral ID associated with the aggregation query

    • attributes#objectrequired
      Show 2 fields
      • dates#string<date-time>[]required

        The dates of the query range

      • data#object[]required

        Aggregation result data

        Show 2 fields
        • dimensions#string[]required

          List of dimensions associated with this set of measurements

        • measurements#objectrequired

          Dictionary of measurement_key, values

4XXClient Error

Content type: application/vnd.api+json

  • errors#object[]required
    Show 5 fields
    • id#stringrequired
    • code#stringrequired
    • title#stringrequired
    • detail#stringrequired
    • source#object
      Show 2 fields
      • pointer#string
      • parameter#string

5XXServer Error

Content type: application/vnd.api+json

  • errors#object[]required
    Show 5 fields
    • id#stringrequired
    • code#stringrequired
    • title#stringrequired
    • detail#stringrequired
    • source#object
      Show 2 fields
      • pointer#string
      • parameter#string