---
title: "POST /query/batch"
method: POST
path: "/query/batch"
tags: ["query"]
---

# POST /query/batch

`POST /query/batch`

## Request

- Base URL: `https://{axiom-domain}/v1`
- URL: `https://{axiom-domain}/v1/query/batch`
- Auth: OAuth 2
  - Authorization code: `https://accounts.google.com/o/oauth2/v2/auth`
  - Token URL: `https://www.googleapis.com/oauth2/v4/token` scopes: `query|read`
- TypeScript: <https://skmtc.dev/axiom/apis/axiom-query/docs/query/batch/post.ts> (a function with typed inputs; its response is checked against the schema)

Runs several APL and MPL queries in one request and streams each result as a server-sent event when it completes. Each item sets exactly one of `aplRequest` or `mplRequest`; per-item failures, including query limit errors, arrive as `error` events.

## Query parameters

- `maxConcurrency` integer
- `nocache` boolean
- `apl-source` string
- `apl-source-id` string

## Request body

- object[]
  - `aplRequest` APLRequestWithOptions
    - `apl` string, required: APL query string
    - `cursor` string: Pagination cursor
    - `defaultLimit` integer: The default limit to use when no limit is specified in the query.
    - `defaultOrder` object[]: The default order to use when no order is specified in the query.
      - `desc` boolean
      - `field` string
    - `endTime` string: End time for the query range
    - `includeCursor` boolean: Include cursor in response
    - `includeCursorField` boolean: Defines if the _cursor field should be projected in the result
    - `libraries` string[]
    - `maxBinAutoGroups` integer: Maximum number of groups to automatically bin into
    - `queryOptions` QueryOptions
      - `against` string
      - `againstStart` string
      - `againstTimestamp` string
      - `aggChartOpts` string
      - `caseSensitive` string
      - `containsTimeFilter` string
      - `datasets` string
      - `displayNull` string
      - `editorContent` string
      - `endColumn` string
      - `endLineNumber` string
      - `endTime` string
      - `integrationsFilter` string
      - `nanosecondPrecision` string
      - `openIntervals` string
      - `overlayCharts` string
      - `queryObject` string
      - `quickRange` string
      - `resolution` string
      - `resultsHistogram` string
      - `selection` string
      - `shownColumns` string
      - `startColumn` string
      - `startLineNumber` string
      - `startTime` string
      - `timeSeriesVariant` string
      - `timeSeriesView` string
    - `startTime` string: start and end time for the query, these must be specified as RFC3339 strings or using relative time expressions (e.g. now-1h, now-1d, now-1w, etc)
    - `variables` object: Variables is an optional set of additional variables that are inserted into the APL
  - `mplRequest` MetricsRequestWithOptions
    - `endTime` string, required: End time for the query range
    - `mpl` string: The MPL query.
    - `startTime` string, required: start and end time for the query, these must be specified as RFC3339 strings or using relative time expressions (e.g. now-1h, now-1d, now-1w, etc)
  - `queryId` string, required: Unique identifier for this query in the batch

## Response `200`

SSE stream of query results. Each event carries a `kind` field
("apl" or "mpl") indicating how the `data` payload for that
queryId should be interpreted.

Per-item query-limit errors are delivered as SSE error events
with status 429, the QueryLimitError body, and X-QueryLimit-*
headers.

## Other responses

- `default`: The batch is invalid, for example it's empty or has a missing or duplicate `queryId`.

---

[API](https://skmtc.dev/axiom/apis/axiom-query.md) - [All operations](https://skmtc.dev/axiom/apis/axiom-query/llms.txt) - [OpenAPI document](https://skmtc.dev/axiom/apis/axiom-query/revisions/16be903874f4?raw)
