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

# Authorize a device code (browser /device page calls this)

` POST /api/v1/device/authorize `

Authorize a device code (browser /device page calls this)

## Servers

- ` https://littledemo.com ` — Production

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` cookieAuth `: ` apiKey `

  - Credential: ` better-auth.session_token ` in ` cookie `

  - Dashboard session cookie.

## Request body (optional)

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` user_code `

  - ` user_code `: type ` string `

    - minLength: ` 1 `

    - maxLength: ` 20 `

## Responses

### ` 200 ` — Authorized — CLI will pick up the token on next poll

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` ok `, ` client_name `

  - ` ok `: type ` boolean `

    - enum: ` [true] `

  - ` client_name `: type ` string `

### ` 401 ` — Not signed in

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` error `

  - ` error `: type ` string `

### ` 404 ` — Code not found or expired

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` error `

  - ` error `: type ` string `

### ` 409 ` — Code already used

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` error `

  - ` error `: type ` string `

## Request examples

### cURL

```curl
curl -X POST 'https://littledemo.com/api/v1/device/authorize' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "user_code": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://littledemo.com/api/v1/device/authorize', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "user_code": "string"
  })
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://littledemo.com/api/v1/device/authorize', headers=headers, json={
  "user_code": "string"
})
print(response.json())
```