# GET /api/v1/tokens

> List tokens

- **Tag:** api-tokens
- **Operation ID:** `list_tokens_api_v1_tokens_get`

## Description

List all API tokens for current user

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Parameters

- `include_revoked` (query, boolean, optional) — Include revoked tokens
- `cursor` (query, string, optional) — Cursor for pagination
- `limit` (query, integer, optional) — Pagination limit
- `direction` (query, string, optional) — Pagination direction: 'next' or 'prev'
- `include_total_count` (query, boolean, optional) — Whether to include total count (expensive - avoid if possible)
- `sort_by` (query, string, optional) — Column name to sort by (e.g. 'created_at', 'amount', 'name'). When changing sort, reset cursor to None.
- `descending` (query, boolean, optional) — Sort direction: true for descending (newest/largest first), false for ascending

## Responses

### 200 — Successful Response

Schema: `APITokenListResponse`

- `items` (array · APITokenResponse · required) → `APITokenResponse` — List of items
  - `id` (string · required) — Token record ID
  - `jti` (string · required) — Unique token identifier (JWT ID)
  - `name` (string) — Human-readable token name
  - `description` (string) — Optional token description
  - `token_prefix` (string · required) — First characters of the token for display (e.g. dz_abc...)
  - `token_type` (string) — Token type (always 'api')
  - `created_at` (string · date-time · required) — When the token was created
  - `last_used_at` (string · date-time) — Last time the token was used for authentication
  - `expires_at` (string · date-time) — When the token expires (null = never)
  - `revoked_at` (string · date-time) — When the token was revoked (null = active)
  - `revocation_reason` (string) — Reason the token was revoked
- `total` (integer) — Total number of items (null when not calculated for performance)
- `limit` (integer) — Pagination limit
- `next_cursor` (string) — Cursor for next page
- `prev_cursor` (string) — Cursor for previous page
- `has_next` (boolean · required) — Whether there are more items
- `has_prev` (boolean · required) — Whether there are previous items

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X GET 'https://api.ondayzero.com/api/v1/tokens' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/tokens', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
  },
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

response = httpx.get("https://api.ondayzero.com/api/v1/tokens", headers=headers)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/api-tokens/list-tokens
- OpenAPI slice: https://www.ondayzero.com/docs/reference/api-tokens/list-tokens/openapi.json
- Other endpoints in **api-tokens**: https://www.ondayzero.com/docs/reference/api-tokens
