Agents · pollDeviceToken
Poll for the connected agent's API key
POST /v1/device/token
No credentials. While the human hasn't decided: 400 authorization_pending (poll again after interval seconds) or slow_down (polled too soon: add 5 seconds to the interval). 403 access_denied when the human cancelled; 400 expired_token when the code expired or its API key was already delivered. On approval: the new agent's API key, returned exactly once.
- Who may call it
- Anyone (no credentials)
- Server
- https://api.logu.dev
Request body#
Content type application/json (required).
| Field | Type | Required | Notes |
|---|---|---|---|
device_code | string | required | 1–200 chars |
{
"device_code": "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS"
}
Example#
curl -s -X POST "https://api.logu.dev/v1/device/token" \
-H "Content-Type: application/json" \
-d '{"device_code":"GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS"}'
Responses#
200
The API key (lg_…), its agent and workspace. Shown this once.
{
"api_key": "lg_8fK2xQp3R7vT9wY1zA4cD6eG8hJ0kL2m",
"agent": {
"id": "agt_01K7D8F2H4K6M8P0R2T4V6X8Z0",
"name": "Claude Code on kevins-mac"
},
"workspace": {
"id": "wsp_Xq3bY7tLmN2pR8sV",
"name": "Ana"
}
}
Response fields
| Field | Type | Required | Notes |
|---|---|---|---|
api_key | string | required | |
agent | AgentRef | required | |
agent.id | string | required | |
agent.name | string | required | |
workspace | object | required | |
workspace.id | string | required | |
workspace.name | string | 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). |
| 400 | authorization_pending | The device code is waiting for a human to approve it in the app (POST /v1/device/token). |
| 400 | slow_down | The device code was polled faster than its interval. |
| 400 | expired_token | The device code expired (10 minutes) or was already used to get its API key. |
| 403 | access_denied | The human denied the device code in the app. |
| 500 | internal_error | Something went wrong on Logu's side. |