# Request Token

Exchange an API key for a short-lived access token.

```
POST https://api.reson8.dev/v1/auth/token
```

## Request

### Headers

| Header          | Value              | Description        |
|-----------------|--------------------|--------------------|
| Authorization   | `ApiKey <api_key>` | Your API key       |

### Example

=== "curl"

    ```bash
    curl -X POST https://api.reson8.dev/v1/auth/token \
      -H "Authorization: ApiKey <your_api_key>"
    ```

=== "Python"

    ```python
    import requests

    response = requests.post(
        "https://api.reson8.dev/v1/auth/token",
        headers={"Authorization": "ApiKey <your_api_key>"},
    )

    token = response.json()["access_token"]
    ```

## Response

`200 OK`

### Fields

| Field          | Type   | Description                                |
|----------------|--------|--------------------------------------------|
| `access_token` | string | The token to use in `Authorization` header |
| `token_type`   | string | Always `Bearer`                            |
| `expires_in`   | number | Token lifetime in seconds                  |

### Example

```json
{
  "access_token": "<your_access_token>",
  "token_type": "Bearer",
  "expires_in": 600
}
```

## Errors

| Status | Code              | Description                   |
|--------|-------------------|-------------------------------|
| 401    | `UNAUTHORIZED`    | Missing or invalid API key    |
| 500    | `INTERNAL_ERROR`  | Unexpected server error       |
