# Usage

`GET https://api.search.brave.com/admin/v1/usage`

Usage in UTC buckets, oldest first. See `data_refreshed_at` for freshness.

## Query Parameters

| Name | Location | Type | Required | Constraints | Description |
|------|----------|------|----------|-------------|-------------|
| `starting_at` | query | string | Yes |  | Start of the first bucket, with a UTC offset, rounded down to the bucket width and at most 12 months back. |
| `ending_at` | query | string | No |  | End of the range, with a UTC offset, rounded up to the bucket width and capped at now (the default). |
| `bucket_width` | query | string | No | `1h`, `1d`, `1mo`; default `1d` |  |
| `group_by` | query | string[] | No |  | Split each bucket by these; without it a bucket has one total. |
| `api_key_ids` | query | string[] | No |  |  |
| `endpoints` | query | string[] | No |  | Endpoint names as in the docs, e.g. web, news, llm_context. |
| `plan_ids` | query | string[] | No |  |  |
| `limit` | query | int | No | min `1` | Buckets per page for 1h / 1d / 1mo: default 24 / 7 / 3, at most 168 / 31 / 12. |
| `page` | query | string | No | length max `256` | `next_page` of the previous page. |

## Headers

| Name | Location | Type | Required | Constraints | Description |
|------|----------|------|----------|-------------|-------------|
| `authorization` | header | string | No |  | `Bearer <admin key>`. |
| `x-admin-key` | header | string | No |  | The admin key, if you can't send `Authorization`. |
| `api-version` | header | string | No |  | Pins the response format, one of 2026-11-12. |

## Responses

### 200
Successful Response

| Field | Type | Constraints | Description |
|-------|------|-------------|-------------|
| `object` | string? | `list`; default `list` |  |
| `data` | UsageBucket[] |  |  |
| `data[].object` | string? | `usage_bucket`; default `usage_bucket` |  |
| `data[].starting_at` | string? |  |  |
| `data[].ending_at` | string? |  |  |
| `data[].results` | UsageResult[] |  |  |
| `data[].results[].api_key_id` | string? |  | Null when not grouped by key, or for usage recorded without one. |
| `data[].results[].endpoint` | string? |  | Null when not grouped by endpoint, or for usage recorded without one. |
| `data[].results[].plan_id` | string? |  | Null when not grouped by plan. |
| `data[].results[].requests` | int? |  | Null when requests apply to no plan in this row. |
| `data[].results[].queries` | int? |  | Null when queries apply to no plan in this row. |
| `data[].results[].input_tokens` | int? |  | Null when tokens apply to no plan in this row. |
| `data[].results[].output_tokens` | int? |  | Null when tokens apply to no plan in this row. |
| `api_keys` | object |  | Labels for every api_key_id on this page. |
| `plans` | object |  | Labels for every plan with usage on this page; billed_on says which measures apply to each. |
| `has_more` | bool |  |  |
| `next_page` | string? |  |  |
| `data_refreshed_at` | string? |  | When the last usage sync finished. Requests from the 5-10 minutes before it may not be in yet; buckets ending 2 hours before it are final. |

#### Example

```json
{
  "object": "list",
  "data": [
    {
      "object": "usage_bucket",
      "starting_at": "2023-11-07T05:31:56Z",
      "ending_at": "2023-11-07T05:31:56Z",
      "results": [
        {
          "api_key_id": "<string>",
          "endpoint": "<string>",
          "plan_id": "<string>",
          "requests": 0,
          "queries": 0,
          "input_tokens": 0,
          "output_tokens": 0
        }
      ]
    }
  ],
  "api_keys": {},
  "plans": {},
  "has_more": false,
  "next_page": "<string>",
  "data_refreshed_at": "2023-11-07T05:31:56Z"
}
```

## Errors

| Status | Error code | Detail |
|--------|------------|--------|
| 401 | `ADMIN_KEY_INVALID` | Missing, invalid, paused, deactivated, deleted or expired admin key. Admin keys start with bsk_admin_; search API keys don't work here. |
| 403 | `ADMIN_KEY_SCOPE_MISSING` | This admin key doesn't have the scope this endpoint needs. |
| 404 | `API_VERSION_NOT_FOUND` | The requested product api version is not found. |
| 422 | `VALIDATION` | Unable to validate request parameter(s). |
| 422 | `INVALID_TIME_RANGE` | The time range provided is invalid. |
| 429 | `ADMIN_RATE_LIMITED` | Admin API rate limit exceeded for this organization. Usage updates every 5 minutes or so; poll at most that often. |
| 503 | `ADMIN_OVERLOADED` | The Admin API is busy. Retry after the number of seconds in Retry-After. |

Body: `AdminErrorResponse` (see [Schemas](#schemas)).

## Schemas

Types named in the tables above that are not expanded inline. Field paths are relative to the type.

### AdminErrorResponse

| Field | Type | Constraints | Description |
|-------|------|-------------|-------------|
| `type` | string? | default `ErrorResponse` | Always `ErrorResponse`. |
| `error` | AdminErrorModel |  |  |
| `error.id` | string |  | A unique identifier for this particular occurrence of the problem. |
| `error.status` | int |  | The HTTP status code applicable to this problem. |
| `error.detail` | string? |  | Explanation specific to this occurrence of the problem. Like title, this field's value can be localized. |
| `error.meta` | object? |  | A meta object containing non-standard meta-information about the error. |
| `error.code` | string | `VALIDATION`, `INVALID_TIME_RANGE`, `API_VERSION_NOT_FOUND`, `ADMIN_KEY_INVALID`, `ADMIN_KEY_SCOPE_MISSING`, `ADMIN_RATE_LIMITED`, `ADMIN_OVERLOADED` | An Admin API error code, such as `ADMIN_KEY_INVALID` or `ADMIN_RATE_LIMITED`. |
| `time` | int? | default `0` | Unix time in seconds when the error occurred. |