---
search:
  tags:
    - CliDeviceAuth
    - POST
seo:
  description: >-
    Polls the device authorization grant. Every answer is a 200 whose status
    says… Reference for the POST /auth/cli/device/token endpoint in the varsafe
    API.
sidebar:
  label: Exchange a device code for a CLI credential
  badge: POST
title: Exchange a device code for a CLI credential
type: openapi-operation
---
Polls the device authorization grant. Every answer is a 200 whose `status` says where the grant stands: `pending` (keep polling; `reason: slow_down` asks for a longer interval), `failed` (expired or denied — start again), or `granted` / `granted-machine`, which carries the credential exactly once. Unlike RFC 8628 §3.5, a pending or failed grant is not an HTTP 400 error response.

`POST /auth/cli/device/token`

**Responses**

- `200` — Success.
- `400` — The request failed validation. \`field\` names the offending input.
- `401` — No credential was presented, or it is invalid or revoked.
- `403` — The credential is valid but lacks the required scope, role or team access.
- `404` — The resource does not exist, or is not visible to this credential.
- `429` — Rate limited. Retry after the interval named in the response.
- `500` — Unexpected server error. The body never carries internal detail.

Response example, 200:

```json
{
  "status": "pending",
  "reason": "authorization_pending"
}
```
