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

# Create Device Code

> Start the device authorization flow

## Overview

Initiates the device authorization flow for CLI tools and AI agents that cannot open a browser directly. Returns a user code that must be entered at the verification URL to authorize the device.

**Flow:**

1. Agent calls this endpoint to get a `device_code` and `user_code`
2. User opens `verification_url` in their browser and enters the `user_code`
3. Agent polls [Poll Device Token](/api-reference/endpoint/poll_device_token) with the `device_code`
4. Once authorized, the poll returns an API key

No authentication required.

## Body Parameters

<ParamField body="client_name" type="string" default="Unknown Client">
  Name of the client requesting authorization (shown to user during approval)
</ParamField>

## Response

<ResponseField name="device_code" type="string">
  Opaque code for the agent to use when polling for the token
</ResponseField>

<ResponseField name="user_code" type="string">
  Human-readable code in `XXXX-XXXX` format for the user to enter
</ResponseField>

<ResponseField name="verification_url" type="string">
  URL where the user should enter the code
</ResponseField>

<ResponseField name="expires_in" type="integer">
  Seconds until the device code expires (600 = 10 minutes)
</ResponseField>

<ResponseField name="interval" type="integer">
  Minimum seconds between poll requests (5)
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.danubeai.com/v1/auth/device/code" \
    -H "Content-Type: application/json" \
    -d '{"client_name": "Claude Code"}'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "device_code": "dc_a1b2c3d4e5f6...",
    "user_code": "ABCD-1234",
    "verification_url": "https://danubeai.com/device",
    "expires_in": 600,
    "interval": 5
  }
  ```
</ResponseExample>

## Device Auth Flow

```
Agent                          User                         Danube
  |                              |                            |
  |-- POST /auth/device/code --->|                            |
  |<-- device_code, user_code ---|                            |
  |                              |                            |
  |  "Enter ABCD-1234 at URL"   |                            |
  |----------------------------->|                            |
  |                              |-- Opens verification_url ->|
  |                              |-- Enters user_code ------->|
  |                              |<-- "Authorized!" ----------|
  |                              |                            |
  |-- POST /auth/device/token -->|                            |
  |<-- api_key ------------------|                            |
```
