> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Export API Requests

> Read settled API key usage as one row per request, with cost and token counts.

This endpoint returns one settled row per API request made with a workspace or personal API key. Each row includes cost and token counts. It does not include prompt or completion text.

For a total per API key, use [Export API Key Usage](https://docs.langdock.com/en/developer/usage-export-api/export-api-keys.md). To download one row per API call as a CSV file from **Settings > API** instead, see [API Usage Export](https://docs.langdock.com/en/admin/compliance-and-governance/api-usage-export.md).

## Before You Start

* **Prerequisites and rate limits**: See the [Usage Export API overview](https://docs.langdock.com/en/developer/usage-export-api/intro-to-usage-export-api.md).
* **Browser requests**: Langdock intentionally blocks browser-origin requests to protect your API key. Use API keys server-side and store them securely. See [API Key Best Practices](https://docs.langdock.com/en/admin/ai-adoption-and-rollout/best-practices/api-key-best-practices.md).

## Base URL

```
https://api.langdock.com/usage/v1/requests
```

> [!WARNING]
>
> **Dedicated deployments**
>
> Replace `api.langdock.com` with `<your-deployment-url>/api/public` in all requests.

## Request

| Parameter | Required | Description |
| - | - | - |
| `from` | Yes | Start of the window, ISO 8601 with a time zone offset (for example `2026-11-20T00:00:00Z`) |
| `to` | No | End of the window. Defaults to now |
| `limit` | No | Page size. Default `1000`, maximum `10000` |
| `cursor` | No | `next_cursor` from the previous page |
| `api_key_id` | No | Limit the page to this API key UUID |

A `from` earlier than 366 days ago is treated as 366 days ago, and a `to` in the future is treated as now. If `to` is before `from`, the API returns `400 Bad Request`.

## Paging

Rows are oldest first. `next_cursor` is `null` on the last page. When it is a string, send it as `cursor` with the same `from` and `to`. An invalid `cursor` returns `400 Bad Request`. An empty window returns `200` with `data: []` and `next_cursor: null`.

## When Rows Appear

For requests sent to the Model Gateway on `gateway.langdock.com`, `id` matches the `x-request-id` response header from that completion call. An `x-request-id` you send in the request does not become `id`. The row appears a few seconds later, once the cost is settled. Rows from the [Completion API](https://docs.langdock.com/en/developer/completion-api/completion-overview.md) on `api.langdock.com` appear when the request finishes.

## Data Included

| Column | Description |
| - | - |
| `id` | ID of the request. For Model Gateway requests (`gateway.langdock.com`), the `x-request-id` response header from the completion call |
| `created_at` | UTC time the usage was recorded |
| `api_key_id` | ID of the API key |
| `api_key_name` | Name of the API key. `null` after the key is deleted |
| `user_id` | ID of the user. Included only when User-level data is enabled |
| `user_email` | Email of the user. Included only when User-level data is enabled |
| `model` | Model name |
| `provider` | Model provider |
| `input_tokens` | All prompt tokens, including cache reads and writes |
| `cached_input_tokens` | Cache-read input tokens |
| `cache_write_tokens` | Cache-write input tokens |
| `output_tokens` | Output tokens |
| `reasoning_tokens` | Reasoning tokens |
| `cost_usd` | USD price. Net amount on a BYOK row, gross amount otherwise |
| `cost_eur` | Billed amount in EUR. `null` for BYOK. `0` when the row was not billed |
| `is_byok` | Whether this row was BYOK |
| `service_tier` | Service tier, or `null` |
| `finish_reason` | Finish reason, or `null` |
| `duration_ms` | Request duration in milliseconds, or `null` |
| `time_to_first_token_ms` | Time to first token in milliseconds, or `null` |

## Example

```bash theme={null}
curl "https://api.langdock.com/usage/v1/requests?from=2026-11-20T00:00:00Z&to=2026-11-21T00:00:00Z&limit=2" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```json theme={null}
{
  "data": [
    {
      "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
      "created_at": "2026-11-20T10:00:00.000000Z",
      "api_key_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "api_key_name": "Billing export",
      "model": "claude-sonnet-4-5",
      "provider": "anthropic",
      "input_tokens": 1100,
      "cached_input_tokens": 1000,
      "cache_write_tokens": 0,
      "output_tokens": 50,
      "reasoning_tokens": 10,
      "cost_usd": 0.0012,
      "cost_eur": 0.0011,
      "is_byok": false,
      "service_tier": null,
      "finish_reason": "stop",
      "duration_ms": 900,
      "time_to_first_token_ms": 300
    },
    {
      "id": "3b6c8e2a-91d4-4f0b-8c7e-2a1b9d0e4f55",
      "created_at": "2026-11-20T10:01:00.000000Z",
      "api_key_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "api_key_name": "Billing export",
      "model": "claude-sonnet-4-5",
      "provider": "anthropic",
      "input_tokens": 240,
      "cached_input_tokens": 0,
      "cache_write_tokens": 0,
      "output_tokens": 80,
      "reasoning_tokens": 0,
      "cost_usd": 0.0008,
      "cost_eur": 0.0008,
      "is_byok": false,
      "service_tier": null,
      "finish_reason": "stop",
      "duration_ms": 640,
      "time_to_first_token_ms": 210
    }
  ],
  "next_cursor": "MjAyNi0xMS0yMFQxMDowMTowMC4wMDAwMDBafDNiNmM4ZTJhLTkxZDQtNGYwYi04YzdlLTJhMWI5ZDBlNGY1NQ"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.