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

# Device Login

Browser-based device login endpoints used by the ScreenFramed CLI.

The CLI uses a device authorization flow so local machines can receive a scoped API key without pasting one manually.

## Create a code

**Create device code**

Creates a human-readable code and polling token.

```json
{
  "user_code": "ABCD-2345",
  "poll_token": "64_hex_characters",
  "verification_uri": "https://screenframed.com/device",
  "verification_uri_complete": "https://screenframed.com/device?code=ABCD-2345",
  "expires_in": 900,
  "interval": 5
}
```

## Poll for token

**Poll device token**

Polls until the browser authorization completes or the code expires.

```bash
curl -X POST "https://screenframed.com/v1/device/token" \
  -H "Content-Type: application/json" \
  -d '{ "poll_token": "64_hex_characters" }'
```

Pending response:

```json
{
  "status": "pending",
  "interval": 5,
  "expires_in": 840
}
```

Authorized response:

```json
{
  "status": "authorized",
  "api_key": "sf_live_...",
  "key_id": "01K...",
  "user_id": "..."
}
```

Most users should use `screenframed login` rather than calling these endpoints directly.

` POST /v1/device/code `

Create a CLI device code

## Servers

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

## Responses

### ` 201 ` — Device code

Content type: ` application/json `

- ` value `: type ` object `

  - ` user_code `: type ` string `

  - ` poll_token `: type ` string `

  - ` verification_uri `: type ` string `; format ` uri `

  - ` verification_uri_complete `: type ` string `; format ` uri `

  - ` expires_in `: type ` integer `

  - ` interval `: type ` integer `

### ` 429 ` — Error response

Content type: ` application/json `

- ` value `: type ` object `

  - Required fields: ` error `

  - ` error `: type ` object `

    - Required fields: ` code `, ` message `

    - ` code `: type ` string `

    - ` message `: type ` string `

    - ` details `: type ` object `

    - ` retry_after `: type ` integer `

## Request examples

### cURL

```curl
curl -X POST 'https://screenframed.com/v1/device/code' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://screenframed.com/v1/device/code', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN"
  }
});

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

### Python

```python
import requests

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

response = requests.post('https://screenframed.com/v1/device/code', headers=headers)
print(response.json())
```