Agents · createDeviceCode
Start connecting an agent (device code)
POST /v1/device/code
No credentials: how a client without an API key gets one (logu login). client_name suggests the agent's name and client_kind (claude-code, codex, cli) lets the app suggest an existing agent of that kind; test: true asks for a test API key (lg_test_…, logu login --test). Returns a secret device_code for the client and a short user_code for the human, who opens verification_uri_complete (the app's /connect page), checks the code and approves it in a workspace. Then poll POST /v1/device/token. Codes expire in 10 minutes. Field names follow RFC 8628. Rate-limited per IP address.
- Who may call it
- Anyone (no credentials)
- Server
- https://api.logu.dev
Request body#
Content type application/json (required).
| Field | Type | Required | Notes |
|---|---|---|---|
client_name | string | optional | 1–64 chars |
client_kind | "claude-code" | "codex" | "cli" | optional | |
test | boolean | optional |
{
"client_name": "Claude Code on kevins-mac",
"client_kind": "claude-code"
}
Example#
curl -s -X POST "https://api.logu.dev/v1/device/code" \
-H "Content-Type: application/json" \
-d '{"client_name":"Claude Code on kevins-mac","client_kind":"claude-code"}'
Responses#
200
The device code, the user code and where the human approves it.
{
"device_code": "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS",
"user_code": "WDJB-MJHT",
"verification_uri": "https://logu.dev/connect",
"verification_uri_complete": "https://logu.dev/connect?code=WDJB-MJHT",
"expires_in": 600,
"interval": 5
}
Response fields
| Field | Type | Required | Notes |
|---|---|---|---|
device_code | string | required | |
user_code | string | required | |
verification_uri | string | required | |
verification_uri_complete | string | required | |
expires_in | integer | required | |
interval | integer | required |
Errors#
Every error is {"error":{"code","message","hint","docUrl","requestId"}}: branch on code. See Errors.
| Status | Code | Meaning |
|---|---|---|
| 400 | bad_request | The request is malformed or a field is invalid (see issues). |
| 400 | unknown_field | The body has a field the endpoint doesn't know (often a typo or snake_case). |
| 429 | rate_limited | This API key sent too many requests, or a human did too much too fast: sign-in attempts, workspaces created in a day, or a global daily cap on new accounts was reached. |
| 500 | internal_error | Something went wrong on Logu's side. |