API Reference/

POST/cli/auth/poll

No auth required

Poll the server to check whether the user has approved the device code. Keep polling at the interval returned by /cli/auth/start until you receive a token or the code expires. You can identify the session by either device_code or user_code.

Request Body

NameDescription
device_code
stringThe device code returned by /cli/auth/start. Provide this or user_code.
user_code
stringThe human-readable user code from /cli/auth/start. Alternative to device_code.

Request

bash
curl -X POST https://api.playanagrama.com/cli/auth/poll \
  -H "Content-Type: application/json" \
  -d '{"device_code":"abc123"}'

Response Fields

NameDescription
status
stringOne of "pending" (user hasn't approved yet), "approved" (token included), or "consumed" (token already retrieved).
token
stringCLI bearer token (prefixed with cli_). Only present when status is "approved". Store this securely.
user
objectUser profile with userId, username, and displayName. Only present on approval.

Response 202 — Pending

JSON
{
  "status": "pending"
}

Response 200 — Approved

JSON
{
  "status": "approved",
  "token": "cli_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456",
  "user": {
    "userId": "user_2abc123def456",
    "username": "wordmaster",
    "displayName": "wordmaster"
  }
}

Response 409 — Already consumed

JSON
{
  "status": "consumed"
}

Response 410 — Expired

JSON
{
  "error": "Device code expired"
}

Response 404 — Not found

JSON
{
  "error": "Device code not found"
}
A 202 means keep polling. A 200 includes the token — this is delivered exactly once. Subsequent polls return 409 consumed. If the code expires (15 minutes), you'll get a 410 — start a new flow from /cli/auth/start.
Was this page helpful?
Anagrama API Docs | Developer Reference