---
title: "Create an export"
method: POST
path: "/v1/ai-cost-management/exports"
tags: ["exports"]
---

# Create an export

`POST /v1/ai-cost-management/exports`

## Request

- Base URL: `https://global.api.konghq.com`
- URL: `https://global.api.konghq.com/v1/ai-cost-management/exports`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Queues a one-time export and returns it with `status` set to `pending`. The server assigns the identifier.

The export runs asynchronously. A client reads it again with `GET /v1/ai-cost-management/exports/{exportId}` to follow its progress. Once it succeeds, the client requests a download URL for one file at a time with `POST /v1/ai-cost-management/exports/{exportId}/downloads`.

If the body is invalid, the request fails with `400`, including when `ends_at` is later than the end of the day in progress in `time_zone`. That check on `ends_at` runs last: a body with other errors gets those errors first, and the corrected body then gets the error on `ends_at`.

If the organization already has 20 `pending` one-time exports, the request fails with `409`. Exports that a schedule creates don't count toward that limit.

## Request body

- union
  - object: The body of a request that creates a one-time export: the dataset, the file format and compression, the time range, and optional filters and labels. The labels can't change after creation.
    - `dataset` 'usage_events' | 'focus', required: The data the export holds.
    - `schema_version` 1: The schema version of the data files within the dataset, which fixes their columns and values. Defaults to `1`, also once newer schema versions exist.
    - `focus` AICostFocusOptionsInput: The FOCUS options of a `focus` export. Required when `dataset` is `focus`, and isn't accepted for any other dataset.
      - `version` '1.3' | '1.4', required: The FOCUS version of the files, which decides what their cost columns hold.
      - `charge_period` 'day' | 'hour': The length of each row's charge period. Defaults to `day`.
      - `tag_keys` string[]: Tag keys whose values split the rows. Events with different values for a named key, or without the key, go into different rows. A row's `Tags` column holds the named keys that its events carry, with their values. A key with a different value for every agent session or CI run, such as `agent-session` or `ci-run`, makes about one row per session or run. At most 64 keys, each listed once and following the tag key rules: 1 to 128 characters, each a lowercase ASCII letter, a digit, `.`, `_`, or `-`. Defaults to `[]`.
    - `format` intersection, required: The file format of the data files.
      - [`AICostExportFormat`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportFormat)
      - 'csv'
    - `compression` intersection, required: How the data files are compressed. `none` or `gzip` for `csv`, and `zstd` for `parquet`.
      - [`AICostExportCompression`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportCompression)
      - 'none' | 'gzip'
    - `starts_at` string, date-time, required: The start of the range, inclusive, as an RFC 3339 timestamp. The export holds the events whose `time` is at or after `starts_at`. At most 9 fractional-second digits.
    - `ends_at` string, date-time, required: The end of the range, exclusive, as an RFC 3339 timestamp. The export holds the events whose `time` is before `ends_at`. At most 9 fractional-second digits. It must be: - after `starts_at`. - at most 13 calendar months after `starts_at`, counted in `time_zone`. - no later than the end of the day in progress in `time_zone` when the request arrives, so a range can include the day in progress.
    - `time_zone` string, iana-time-zone: The IANA time zone that decides where each file's period starts: a day for a `usage_events` export, or a calendar month for a `focus` export. For a `focus` export, it also decides where the charge and billing periods start. An IANA time zone name as the time zone database spells it, such as `Europe/Budapest`. Offsets such as `+02:00` aren't accepted. Defaults to `UTC`.
    - `filters` object: Filters that select the events to export, with the same fields, operators, and shape as the `filters` of `POST /v1/ai-cost-management/events/query`. Every filter must match. Defaults to `{}`.
    - `labels` Labels: Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".
  - object: The body of a request that creates a one-time export: the dataset, the file format and compression, the time range, and optional filters and labels. The labels can't change after creation.
    - `dataset` 'usage_events' | 'focus', required: The data the export holds.
    - `schema_version` 1: The schema version of the data files within the dataset, which fixes their columns and values. Defaults to `1`, also once newer schema versions exist.
    - `focus` AICostFocusOptionsInput: The FOCUS options of a `focus` export. Required when `dataset` is `focus`, and isn't accepted for any other dataset.
      - `version` '1.3' | '1.4', required: The FOCUS version of the files, which decides what their cost columns hold.
      - `charge_period` 'day' | 'hour': The length of each row's charge period. Defaults to `day`.
      - `tag_keys` string[]: Tag keys whose values split the rows. Events with different values for a named key, or without the key, go into different rows. A row's `Tags` column holds the named keys that its events carry, with their values. A key with a different value for every agent session or CI run, such as `agent-session` or `ci-run`, makes about one row per session or run. At most 64 keys, each listed once and following the tag key rules: 1 to 128 characters, each a lowercase ASCII letter, a digit, `.`, `_`, or `-`. Defaults to `[]`.
    - `format` intersection, required: The file format of the data files.
      - [`AICostExportFormat`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportFormat)
      - 'parquet'
    - `compression` intersection, required: How the data files are compressed. `none` or `gzip` for `csv`, and `zstd` for `parquet`.
      - [`AICostExportCompression`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportCompression)
      - 'zstd'
    - `starts_at` string, date-time, required: The start of the range, inclusive, as an RFC 3339 timestamp. The export holds the events whose `time` is at or after `starts_at`. At most 9 fractional-second digits.
    - `ends_at` string, date-time, required: The end of the range, exclusive, as an RFC 3339 timestamp. The export holds the events whose `time` is before `ends_at`. At most 9 fractional-second digits. It must be: - after `starts_at`. - at most 13 calendar months after `starts_at`, counted in `time_zone`. - no later than the end of the day in progress in `time_zone` when the request arrives, so a range can include the day in progress.
    - `time_zone` string, iana-time-zone: The IANA time zone that decides where each file's period starts: a day for a `usage_events` export, or a calendar month for a `focus` export. For a `focus` export, it also decides where the charge and billing periods start. An IANA time zone name as the time zone database spells it, such as `Europe/Budapest`. Offsets such as `+02:00` aren't accepted. Defaults to `UTC`.
    - `filters` object: Filters that select the events to export, with the same fields, operators, and shape as the `filters` of `POST /v1/ai-cost-management/events/query`. Every filter must match. Defaults to `{}`.
    - `labels` Labels: Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

## Response `202`

The queued export, with `status` set to `pending`.

- union
  - object: An export copies the organization's stored usage events in a time range into files to download. It runs asynchronously: `status` follows its progress, and once it succeeds, `files` lists the data files, which can be downloaded until `expires_at`. After creation, only an export's status and results change. A client creates a one-time export, and an export schedule creates one export of each of its periods.
    - `id` string, uuid, required: Contains a unique identifier used for this resource.
    - `dataset` 'usage_events' | 'focus', required: The data the export holds.
    - `schema_version` 1, required: The schema version of the data files within the dataset, which fixes their columns and values.
    - `focus` AICostFocusOptions, nullable, required: The FOCUS options of the export, with defaults applied. `null` unless `dataset` is `focus`.
      - `version` '1.3' | '1.4', required: The FOCUS version that the files follow.
      - `charge_period` 'day' | 'hour', required: The length of each row's charge period: a calendar day or an hour in `time_zone`, which `ChargePeriodStart` and `ChargePeriodEnd` bound. The range selects the events and doesn't shorten the first or last period, so those periods can extend beyond `starts_at` and `ends_at`.
      - `tag_keys` string[], required: The tag keys whose values split the rows. A row's `Tags` column holds the named keys that its events carry, with their values. `[]` when the request named none.
    - `format` intersection, required: The file format of the export's data files.
      - [`AICostExportFormat`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportFormat)
      - 'csv'
    - `compression` intersection, required: How the export's data files are compressed. Together with `format`, it sets the files' extension and content type.
      - [`AICostExportCompression`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportCompression)
      - 'none' | 'gzip'
    - `starts_at` string, date-time, required: The start of the range, inclusive, as an RFC 3339 timestamp in UTC. The export holds the events whose `time` is at or after `starts_at`.
    - `ends_at` string, date-time, required: The end of the range, exclusive, as an RFC 3339 timestamp in UTC. The export holds the events whose `time` is before `ends_at`.
    - `time_zone` string, iana-time-zone, required: The IANA time zone that decides where each file's period starts: a day for a `usage_events` export, or a calendar month for a `focus` export. For a `focus` export, it also decides where the charge and billing periods start.
    - `filters` object, required: The filters that select the exported events. `{}` for none.
    - `schedule` object, nullable, required: The schedule that created the export. `null` for a one-time export, and once the schedule is deleted.
      - `id` string, uuid, required: The identifier of the schedule that created the export, which the export schedule operations take as `scheduleId`.
    - `labels` Labels, required: Key-value metadata on the export, set when it's created, or copied from the schedule that created it. The export list can filter by label. Labels don't change which events the export holds.
    - `status` 'pending' | 'running' | 'succeeded' | 'failed' | 'expired', required: Where the export is in its lifecycle. A client reads the export again with `GET /v1/ai-cost-management/exports/{exportId}` to follow its progress.
    - `failure_reason` string, nullable, required: Why the export failed. `query_limit_exceeded` means that reading the events took more time or memory than one export may use, so an export with a shorter range or narrower filters can succeed, and a `focus` export can also name fewer `tag_keys` or use `day` for `charge_period`. `attempts_exhausted` means that every attempt failed for a reason that a later attempt could overcome, such as an outage, so the same export created later can succeed. A schedule doesn't create a failed export again. The set of reasons can grow, so a client treats a reason it doesn't know as a general failure. `null` unless `status` is `failed`.
    - `record_count` integer, nullable, required: The number of records across all data files. `null` until the export succeeds.
    - `data_read_at` string, date-time, nullable, required: When the successful attempt began reading the stored events, as an RFC 3339 timestamp in UTC. An event stored after this time can be missing from the files. Comparing the `data_read_at` and `record_count` of 2 exports of the same range and filters shows whether they differ. `null` until the export succeeds.
    - `files` object[], required: The data files, in date order. A `usage_events` export has one file for each day of the range in `time_zone`, and a `focus` export has one for each calendar month. The first and last files can cover part of their period, and a period without matching events still has a file, with no records. The list doesn't include `manifest.json`. `[]` until the export succeeds.
      - `name` string, required: The file's name, which the download operation takes as `file`. A `usage_events` file is named by its day as `YYYY-MM-DD`, and a `focus` file by its month as `YYYY-MM`, both in the export's `time_zone`. The extension that `format` and `compression` set follows, as in `2026-09-01.parquet` or `2026-09.csv.gz`.
      - `record_count` integer, required: The number of records in the file.
      - `size_bytes` integer, required: The size of the file as downloaded, in bytes.
      - `sha256` string, required: The SHA-256 digest of the file as downloaded. A client checks a download by comparing its size and digest with `size_bytes` and `sha256`. 64 lowercase hexadecimal digits.
    - `created_at` string, date-time, required: An ISO-8601 timestamp representation of entity creation date.
    - `updated_at` string, date-time, required: An ISO-8601 timestamp representation of entity update date.
    - `started_at` string, date-time, nullable, required: When the first attempt started, as an RFC 3339 timestamp in UTC. `null` while the export is `pending`.
    - `finished_at` string, date-time, nullable, required: When the export succeeded or failed, as an RFC 3339 timestamp in UTC. `null` until then.
    - `expires_at` string, date-time, nullable, required: An ISO-8601 timestamp representation of entity expiration date.
  - object: An export copies the organization's stored usage events in a time range into files to download. It runs asynchronously: `status` follows its progress, and once it succeeds, `files` lists the data files, which can be downloaded until `expires_at`. After creation, only an export's status and results change. A client creates a one-time export, and an export schedule creates one export of each of its periods.
    - `id` string, uuid, required: Contains a unique identifier used for this resource.
    - `dataset` 'usage_events' | 'focus', required: The data the export holds.
    - `schema_version` 1, required: The schema version of the data files within the dataset, which fixes their columns and values.
    - `focus` AICostFocusOptions, nullable, required: The FOCUS options of the export, with defaults applied. `null` unless `dataset` is `focus`.
      - `version` '1.3' | '1.4', required: The FOCUS version that the files follow.
      - `charge_period` 'day' | 'hour', required: The length of each row's charge period: a calendar day or an hour in `time_zone`, which `ChargePeriodStart` and `ChargePeriodEnd` bound. The range selects the events and doesn't shorten the first or last period, so those periods can extend beyond `starts_at` and `ends_at`.
      - `tag_keys` string[], required: The tag keys whose values split the rows. A row's `Tags` column holds the named keys that its events carry, with their values. `[]` when the request named none.
    - `format` intersection, required: The file format of the export's data files.
      - [`AICostExportFormat`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportFormat)
      - 'parquet'
    - `compression` intersection, required: How the export's data files are compressed. Together with `format`, it sets the files' extension and content type.
      - [`AICostExportCompression`](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4/schema?at=%2Fcomponents%2Fschemas%2FAICostExportCompression)
      - 'zstd'
    - `starts_at` string, date-time, required: The start of the range, inclusive, as an RFC 3339 timestamp in UTC. The export holds the events whose `time` is at or after `starts_at`.
    - `ends_at` string, date-time, required: The end of the range, exclusive, as an RFC 3339 timestamp in UTC. The export holds the events whose `time` is before `ends_at`.
    - `time_zone` string, iana-time-zone, required: The IANA time zone that decides where each file's period starts: a day for a `usage_events` export, or a calendar month for a `focus` export. For a `focus` export, it also decides where the charge and billing periods start.
    - `filters` object, required: The filters that select the exported events. `{}` for none.
    - `schedule` object, nullable, required: The schedule that created the export. `null` for a one-time export, and once the schedule is deleted.
      - `id` string, uuid, required: The identifier of the schedule that created the export, which the export schedule operations take as `scheduleId`.
    - `labels` Labels, required: Key-value metadata on the export, set when it's created, or copied from the schedule that created it. The export list can filter by label. Labels don't change which events the export holds.
    - `status` 'pending' | 'running' | 'succeeded' | 'failed' | 'expired', required: Where the export is in its lifecycle. A client reads the export again with `GET /v1/ai-cost-management/exports/{exportId}` to follow its progress.
    - `failure_reason` string, nullable, required: Why the export failed. `query_limit_exceeded` means that reading the events took more time or memory than one export may use, so an export with a shorter range or narrower filters can succeed, and a `focus` export can also name fewer `tag_keys` or use `day` for `charge_period`. `attempts_exhausted` means that every attempt failed for a reason that a later attempt could overcome, such as an outage, so the same export created later can succeed. A schedule doesn't create a failed export again. The set of reasons can grow, so a client treats a reason it doesn't know as a general failure. `null` unless `status` is `failed`.
    - `record_count` integer, nullable, required: The number of records across all data files. `null` until the export succeeds.
    - `data_read_at` string, date-time, nullable, required: When the successful attempt began reading the stored events, as an RFC 3339 timestamp in UTC. An event stored after this time can be missing from the files. Comparing the `data_read_at` and `record_count` of 2 exports of the same range and filters shows whether they differ. `null` until the export succeeds.
    - `files` object[], required: The data files, in date order. A `usage_events` export has one file for each day of the range in `time_zone`, and a `focus` export has one for each calendar month. The first and last files can cover part of their period, and a period without matching events still has a file, with no records. The list doesn't include `manifest.json`. `[]` until the export succeeds.
      - `name` string, required: The file's name, which the download operation takes as `file`. A `usage_events` file is named by its day as `YYYY-MM-DD`, and a `focus` file by its month as `YYYY-MM`, both in the export's `time_zone`. The extension that `format` and `compression` set follows, as in `2026-09-01.parquet` or `2026-09.csv.gz`.
      - `record_count` integer, required: The number of records in the file.
      - `size_bytes` integer, required: The size of the file as downloaded, in bytes.
      - `sha256` string, required: The SHA-256 digest of the file as downloaded. A client checks a download by comparing its size and digest with `size_bytes` and `sha256`. 64 lowercase hexadecimal digits.
    - `created_at` string, date-time, required: An ISO-8601 timestamp representation of entity creation date.
    - `updated_at` string, date-time, required: An ISO-8601 timestamp representation of entity update date.
    - `started_at` string, date-time, nullable, required: When the first attempt started, as an RFC 3339 timestamp in UTC. `null` while the export is `pending`.
    - `finished_at` string, date-time, nullable, required: When the export succeeded or failed, as an RFC 3339 timestamp in UTC. `null` until then.
    - `expires_at` string, date-time, nullable, required: An ISO-8601 timestamp representation of entity expiration date.

## Other responses

- `400`: The request body is invalid. `invalid_parameters` names each invalid field.
- `401`: The request has no valid access token. The token is missing, malformed, or expired, or it fails another check, and the response doesn't say which.
- `403`: The access token is valid, but its principal lacks the permission this operation requires. For an operation on one resource, the response doesn't reveal whether that resource exists.
- `409`: The organization already has 20 `pending` one-time exports. Another can be created once one of them starts or is deleted.

## Changes

- **2026-11-19** `3b071797f6e4`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/konnect-api-go-sdk/changes/v1/ai-cost-management/exports/post.md)

---

[API](https://skmtc.dev/kong/apis/konnect-api-go-sdk.md) - [All operations](https://skmtc.dev/kong/apis/konnect-api-go-sdk/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/konnect-api-go-sdk/revisions/3b071797f6e4?raw)
