---
title: "Ask Analytics Question"
description: "How to call Ask Analytics Question (POST /api/ksql-ask) in the Klaviyo REST API: authentication, parameters, request and response bodies, and an example request."
url: "https://developers.klaviyo.com/en/reference/ask_analytics_question_beta"
revision: "2026-10-15.pre"
operationId: "ask_analytics_question_beta"
aliases: ["create_ksql_ask"]
method: "POST"
endpoint: "https://a.klaviyo.com/api/ksql-ask"
authentication: "privateKey"
scopes: ["agents:read","campaigns:read","catalogs:read","events:read","lists:read","metrics:read","profiles:read","segments:read"]
rateLimits: {"burst":"1/s","steady":"15/m"}
revisionHeader: {"name":"revision","required":true}
deprecated: false
preRelease: "BETA"
openApi: "https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15.pre/openapi/beta/apis/ask_analytics_question_beta.json"
jsonApi: {"fields":{"ksql-ask":["answer","id","result_sets","status","warnings"]}}
related: ["https://developers.klaviyo.com/en/reference/reporting-beta/llms.txt","https://developers.klaviyo.com/en/reference/query_location_values_beta.md","https://developers.klaviyo.com/en/reference/query_location_series_beta.md","https://developers.klaviyo.com/en/reference/query_social_series_beta.md","https://developers.klaviyo.com/en/reference/query_social_values_beta.md"]
---

# Ask Analytics Question

> This is the Markdown version of https://developers.klaviyo.com/en/reference/ask_analytics_question_beta

```http
POST https://a.klaviyo.com/api/ksql-ask
```


> [!WARNING]
> **This endpoint is in beta and subject to change.**
> A beta revision header (2026-10-15.pre) is required to use our beta APIs. Klaviyo APIs in beta are not intended for use in production. See our [versioning and deprecation policy](https://developers.klaviyo.com/en/docs/api_versioning_and_deprecation_policy.md) for more information.


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.pre` (required)
- Scopes: `agents:read`, `campaigns:read`, `catalogs:read`, `events:read`, `lists:read`, `metrics:read`, `profiles:read`, `segments:read`
- Rate limits: Burst: `1/s`, Steady: `15/m`
- OpenAPI: [Download this endpoint's OpenAPI document](https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15.pre/openapi/beta/apis/ask_analytics_question_beta.json)

Steady: `15/m`

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

## Example request

### curl

```bash
curl --request POST \
     --url 'https://a.klaviyo.com/api/ksql-ask' \
     --header 'Authorization: Klaviyo-API-Key your-private-api-key' \
     --header 'accept: application/vnd.api+json' \
     --header 'revision: 2026-10-15.pre' \
     --header 'content-type: application/vnd.api+json' \
     --data '{
  "data": {
    "type": "ksql-ask",
    "attributes": {
      "question": "How many orders were placed last week?",
      "max_rows": 100
    }
  }
}'
```

### CLI

```bash
klaviyo beta reporting ask-analytics-question \
  -d '{
  "data": {
    "type": "ksql-ask",
    "attributes": {
      "question": "How many orders were placed last week?",
      "max_rows": 100
    }
  }
}'
```

Sign in first with `klaviyo auth login`. [Install the Klaviyo CLI](https://developers.klaviyo.com/en/docs/klaviyo_cli.md)

## Query parameters

- `fields[ksql-ask]` (string[]): For more information please visit [API overview](https://developers.klaviyo.com/en/reference.md) Allowed values: `answer`, `id`, `result_sets`, `status`, `warnings`

## Headers

- `revision` (string, required): API endpoint revision (format: YYYY-MM-DD[.suffix]) Default: `2026-10-15.pre`

## Request body

Content type: `application/vnd.api+json` (required)

- `data` (object, required)
  - `type` (string, required): Allowed values: `ksql-ask`
  - `attributes` (object, required)
    - `question` (string, required): 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`

### Example request body

```json
{
  "data": {
    "type": "ksql-ask",
    "attributes": {
      "question": "How many orders were placed last week?",
      "max_rows": 100
    }
  }
}
```

## Responses

### 200: Success

Content type: `application/vnd.api+json`

- `data` (object, required)
  - `type` (string, required): Allowed values: `ksql-ask`
  - `id` (string, required): Identifier for this ask, for joining logs across services.
  - `attributes` (object, required)
    - `status` (string, required): Whether this ask was answered or needs more input. Allowed values: `success`, `clarification`
    - `answer` (string, required): 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: `[]`
      - `columns` (object[], required): The result set's columns, in the order their values appear in each row. Fields nested this deep are in [the endpoint's OpenAPI document](https://raw.githubusercontent.com/klaviyo/openapi/2026-10-15.pre/openapi/beta/apis/ask_analytics_question_beta.json).
      - `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` (integer, required): The number of rows in the query's result. Example: `42`
      - `rows_returned` (integer, required): 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` (string, required): 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` (string, nullable): A short plain-language description of what this result set contains. Example: `Order count and average price for last week.`
      - `sql` (string, nullable): 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: `[]`
  - `links` (object, required)
    - `self` (string<uri>, required)
- `links` (ObjectLinks): Same fields as the first ObjectLinks above.

#### Example response body

```json
{
  "data": {
    "type": "ksql-ask",
    "id": "string",
    "attributes": {
      "status": "success",
      "answer": "string",
      "result_sets": [],
      "warnings": [
        "Showing the first 100 of 4,182 matching orders."
      ]
    },
    "links": {
      "self": "https://www.example.com"
    }
  },
  "links": {
    "self": "https://www.example.com"
  }
}
```

### 4XX: Client Error

Content type: `application/vnd.api+json`

- `errors` (object[], required)
  - `id` (string, required)
  - `code` (string, required)
  - `title` (string, required)
  - `detail` (string, required)
  - `source` (object)
    - `pointer` (string)
    - `parameter` (string)

#### Example response body

```json
{
  "errors": [
    {
      "id": "string",
      "code": "string",
      "title": "string",
      "detail": "string",
      "source": {
        "pointer": "string",
        "parameter": "string"
      }
    }
  ]
}
```

### 5XX: Server Error

Content type: `application/vnd.api+json`

- `errors` (object[], required)
  - `id` (string, required)
  - `code` (string, required)
  - `title` (string, required)
  - `detail` (string, required)
  - `source` (object)
    - `pointer` (string)
    - `parameter` (string)

#### Example response body

```json
{
  "errors": [
    {
      "id": "string",
      "code": "string",
      "title": "string",
      "detail": "string",
      "source": {
        "pointer": "string",
        "parameter": "string"
      }
    }
  ]
}
```
