---
title: "Start browser login for the CLI"
method: POST
path: "/auth/cli/device"
tags: ["Identity"]
---

# Start browser login for the CLI

`POST /auth/cli/device`

## Request

- Base URL: `https://api.pyai.com`
- URL: `https://api.pyai.com/auth/cli/device`
- Auth: none required

Creates a ten-minute device grant bound to the CLI's S256 verifier. Open verification_uri_complete in a browser, compare its user code with the terminal, then approve. The grant is rate limited per source network; no API key is required. Responses must not be cached.

## Request body

- object
  - `code_challenge` string, required
  - `code_challenge_method` 'S256', required
  - `client_name` 'PyAI CLI', required

## Response `200`

Device grant created. Keep device_code and the verifier private; only user_code belongs in the browser URL.

- object
  - `device_code` string, required
  - `user_code` string, required
  - `verification_uri` string, uri, required
  - `verification_uri_complete` string, uri, required
  - `expires_in` unknown, required
  - `interval` unknown, required

## Other responses

- `400`: CLI login error. Branch on the final component of the problem type URI.
- `429`: CLI login error. Branch on the final component of the problem type URI.
- `503`: CLI login error. Branch on the final component of the problem type URI.

---

[API](https://skmtc.dev/pyai/apis/pyai-api.md) · [All operations](https://skmtc.dev/pyai/apis/pyai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pyai/apis/pyai-api/revisions/819d8e7c4d09?raw)
