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

# Tokens API

> Create, list, and revoke API tokens.

# Tokens API

## Create a token

```http theme={null}
POST /api/v1/tokens
```

**Request body:**

```json theme={null}
{
  "name": "CI Pipeline",
  "scopes": ["write:secrets"],
  "ttlDays": 90
}
```

| Field     | Type           | Required | Description                                 |
| --------- | -------------- | -------- | ------------------------------------------- |
| `name`    | string         | Yes      | Human-readable name (max 100 chars)         |
| `scopes`  | string\[]      | Yes      | `read:secrets`, `write:secrets`, or `admin` |
| `ttlDays` | number \| null | No       | Days until expiry. `null` = no expiry       |

**Response `201`:**

```json theme={null}
{
  "success": true,
  "data": {
    "id": "64b1f2...",
    "name": "CI Pipeline",
    "rawToken": "env_live_...",
    "displayPrefix": "env_live_ae3",
    "scopes": ["write:secrets"],
    "expiresAt": "2026-11-18T00:00:00.000Z"
  }
}
```

***

## List tokens

```http theme={null}
GET /api/v1/tokens
```

Returns all active tokens for the authenticated user.

**Response `200`:**

```json theme={null}
{
  "success": true,
  "data": [
    {
      "id": "64b1f2...",
      "name": "CI Pipeline",
      "displayPrefix": "env_live_ae3",
      "scopes": ["write:secrets"],
      "createdAt": "2026-08-18T10:00:00.000Z",
      "expiresAt": "2026-11-18T00:00:00.000Z",
      "lastUsedAt": "2026-08-20T09:00:00.000Z"
    }
  ]
}
```

***

## Revoke a token

```http theme={null}
DELETE /api/v1/tokens/:id
```

Permanently deletes the token. This action is irreversible.

**Response `200`:**

```json theme={null}
{ "success": true }
```
