Visitar URL original
Ask Analytics Question | Klaviyo API ReferenceSkip to content

This page is available as Markdown at https://developers.klaviyo.com/en/reference/ask_analytics_question_beta.md. Its OpenAPI document is at https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15.pre/openapi/beta/apis/ask_analytics_question_beta.json. An index of every page is at https://developers.klaviyo.com/llms.txt.

KlaviyoKlaviyoDevelopers

This endpoint is in beta. Call it with the revision header 2026-10-15.pre. Beta endpoints may change before they're generally available. See our versioning and deprecation policy for more information.

POSThttps://a.klaviyo.com/api/ksql-ask

Ask a question about your account data in plain language and get a plain-language answer.

K-SQL turns your question into read-only queries over your account's data, runs them, and summarizes the results. The result sets behind the answer are included so you can see how it was reached.

If the question is too ambiguous to answer, status is clarification and answer contains a question for you. Ask again with more detail.

An answer can only draw on data that your API key or OAuth token has scopes for. Each request uses Composer AI Credits. This API is available to accounts that have been enabled for it.

Answers can take several seconds, so allow for this in your client's request timeout.

Revision header
revision: 2026-10-15.prerequired
Scopes
agents:readcampaigns:readcatalogs:readevents:readlists:readmetrics:readprofiles:readsegments:read
Rate limits
Burst: 1/sSteady: 15/m

Steady: 15/m

Optional Scopes: agents:read campaigns:read catalogs:read events:read lists:read metrics:read profiles:read segments:read

Query parameters

  • fields[ksql-ask]#string[]

    For more information please visit API overview

    Allowed values:
    • answer
    • id
    • result_sets
    • status
    • warnings

Headers

  • revision#stringrequired

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

    2026-10-15.pre

Request body

Content type: application/vnd.api+jsonrequired

  • data#objectrequired
    Show 2 fields
    • type#stringrequired
      Allowed values:
      • ksql-ask
    • attributes#objectrequired
      Show 2 fields
      • question#stringrequired

        The natural-language question to ask. 1-2000 characters.

        Example: How many orders were placed last week?

      • max_rows#integer

        Cap on rows per result set. 1-1000.

        Default: 100

        Example: 100

Responses

200Success

Content type: application/vnd.api+json

  • data#objectrequired
    Show 4 fields
    • type#stringrequired
      Allowed values:
      • ksql-ask
    • id#stringrequired

      Identifier for this ask, for joining logs across services.

    • attributes#objectrequired
      Show 4 fields
      • status#stringrequired

        Whether this ask was answered or needs more input.

        Allowed values:
        • success
        • clarification
      • answer#stringrequired

        Plain-language answer when status is success, or the clarifying question back to the caller when status is clarification.

      • result_sets#object[]

        The executed queries' typed result sets supporting answer. Always empty when status is clarification; may also be empty on success when the answer required no query execution.

        Default: []

        Show 8 fields
        • columns#object[]required

          The result set's columns, in the order their values appear in each row.

          Show 2 fields
          • name#stringrequired

            The column's name.

            Example: order_count

          • type#stringrequired

            The column's data type. It determines how the column's values appear in rows.

            Allowed values:
            • boolean
            • long
            • double
            • string
            • timestamptz
            • unknown

            Example: long

        • rows#string | integer | number | boolean[][]required

          The result rows. Each row is a list of values in the same order as columns. A value is a boolean for boolean columns, a number for long and double columns, and a string for every other type. A missing value is null.

        • row_count#integerrequired

          The number of rows in the query's result.

          Example: 42

        • rows_returned#integerrequired

          The number of rows included in rows. This is lower than row_count when row data was left out by a cap.

          Example: 42

        • completeness#stringrequired

          Whether the QUERY's result was complete -- it says nothing about this payload. sample means the query's row count equalled its own LIMIT, so the underlying result may be larger; truncated means it hit K-SQL's own result cap. Compare rows_returned to row_count for payload elision, which is separate: complete with rows_returned below row_count is a full query result only partially included here.

          Allowed values:
          • complete
          • sample
          • truncated

          Example: complete

        • description#stringnullable

          A short plain-language description of what this result set contains.

          Example: Order count and average price for last week.

        • sql#stringnullable

          The K-SQL query that produced this result set, so you can see how the numbers were derived. Read-only and for explanation only: it is not a stable interface while K-SQL is in alpha -- do not parse it or store it. To run a K-SQL query yourself, see POST /api/ksql-query.

          Example: SELECT count(*) FROM orders WHERE placed_at >= '2026-09-01'

        • caveats#string[]

          Caveats about this result set, in plain language and safe to show an end user as sent. The same sentences also appear in the response-level warnings; read them here when you need to know which result set a caveat applies to.

          Default: []

      • warnings#string[]

        Caveats that change how answer and result_sets should be read -- a sampled result set, row data elided by a cap, a table withheld from this ask. Several conditions are reported nowhere else, so surface these alongside the answer rather than discarding them.

        Default: []

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