Console API: usage-export
This page is generated from server/api/openapi.yaml. Do not edit it by hand.
V3 B4. Asynchronous CSV exports of usage records with signed download links. Handlers: internal/console/usageexport.
GET /api/v1/usage/exports
Section titled “GET /api/v1/usage/exports”List the organisation’s usage exports
operationId usageExportList · auth: orgSession
Needs the same permission as GET /api/v1/usage (view_usage). Every member who may read usage sees every export of the organisation.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
cursor |
query | string | no | Opaque cursor from a previous page’s next_cursor. |
limit |
query | integer<int32> | no | (minimum: 1, maximum: 200, default: 50) |
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json UsageExportPage |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — UsageExportPage
data(array of UsageExport, required)id(string, required) status(UsageExportStatus, required)from(string, required) to(string, required) api_key_id(string, required, nullable) model(string, required) — "" = all models.usage_status(string, required) — "" = all statuses.rows(integer, required) — Rows written so far (running) or in the file (succeeded). bytes(integer, required) error_code(string, required) — Set when failed (usage_export_too_large, usage_export_failed, usage_export_abandoned).created_at(string, required) finished_at(string, required, nullable) expires_at(string, required, nullable) — When the file is deleted (succeeded only). download_url(string, required, nullable) — Signed, short-lived link; present only on GET of a single succeeded export.download_expires_at(string, required, nullable)
next_cursor(string, required, nullable)has_more(boolean, required)
POST /api/v1/usage/exports
Section titled “POST /api/v1/usage/exports”Queue a CSV export of usage records
operationId usageExportCreate · auth: orgSession
The filter means the same as the query of GET /api/v1/usage; from and to are required and may span at most
400 days. The export runs in the background; poll GET /api/v1/usage/exports/{export_id} or wait for the email.
429 usage_export_limit when the organisation already has export.max_active_per_org exports queued or
running. An export matching more than export.max_rows rows fails with error_code usage_export_too_large.
Request body (required) application/json — UsageExportRequest
from(string, required) — Inclusive. to(string, required) — Exclusive. api_key_id(string) model(string) — Exact model slug.status(UsageStatus)
| Status | Meaning | Body |
|---|---|---|
| 202 | Queued | application/json UsageExport |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 202 application/json — UsageExport
id(string, required) status(UsageExportStatus, required)from(string, required) to(string, required) api_key_id(string, required, nullable) model(string, required) — "" = all models.usage_status(string, required) — "" = all statuses.rows(integer, required) — Rows written so far (running) or in the file (succeeded). bytes(integer, required) error_code(string, required) — Set when failed (usage_export_too_large, usage_export_failed, usage_export_abandoned).created_at(string, required) finished_at(string, required, nullable) expires_at(string, required, nullable) — When the file is deleted (succeeded only). download_url(string, required, nullable) — Signed, short-lived link; present only on GET of a single succeeded export.download_expires_at(string, required, nullable)
GET /api/v1/usage/exports/{export_id}
Section titled “GET /api/v1/usage/exports/{export_id}”One usage export, with a fresh signed download link when it is ready
operationId usageExportGet · auth: orgSession
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
export_id |
path | string<uuid> | yes |
| Status | Meaning | Body |
|---|---|---|
| 200 | OK | application/json UsageExport |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 application/json — UsageExport
id(string, required) status(UsageExportStatus, required)from(string, required) to(string, required) api_key_id(string, required, nullable) model(string, required) — "" = all models.usage_status(string, required) — "" = all statuses.rows(integer, required) — Rows written so far (running) or in the file (succeeded). bytes(integer, required) error_code(string, required) — Set when failed (usage_export_too_large, usage_export_failed, usage_export_abandoned).created_at(string, required) finished_at(string, required, nullable) expires_at(string, required, nullable) — When the file is deleted (succeeded only). download_url(string, required, nullable) — Signed, short-lived link; present only on GET of a single succeeded export.download_expires_at(string, required, nullable)
GET /api/v1/usage/exports/{export_id}/download
Section titled “GET /api/v1/usage/exports/{export_id}/download”Download an export file through a signed link
operationId usageExportDownload · auth: public
Public: the signature in the query (from download_url) is the credential, like an object store’s presigned
URL, so the link also works in a new tab or with curl. It expires after export.link_ttl_minutes; ask for
the export again to get a new one. 403 usage_export_link_invalid for a wrong or expired signature, 422
usage_export_not_ready once the file was deleted. The body is RFC 4180 CSV (UTF-8, header row first,
newest record first); cells that would start with = + - @ TAB or CR are prefixed with a single quote.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
export_id |
path | string<uuid> | yes | |
expires |
query | integer<int64> | yes | Unix seconds. |
sig |
query | string | yes |
| Status | Meaning | Body |
|---|---|---|
| 200 | The CSV file | text/csv string<binary> |
| default | Error envelope. The HTTP status follows the error kind. | application/json Error |
Response 200 text/csv — string