> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mixlayer.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mixlayer.com/_mcp/server.

# Poll a CLI device login

POST https://api.mixlayer.com/v1/cli/device_authorizations/token
Content-Type: application/json

Unauthenticated. `status` is `pending`, `slow_down`, `denied`, `expired`, or `approved` with a one-time `api_key`.

Reference: https://docs.mixlayer.com/api-reference/platform-api/cli/poll-device-authorization

## Request

### Body (application/json)

This endpoint expects a PollDeviceAuthorizationRequest.

- `device_code` (string, required) — Device code from the start response.

## Response

### 200

Poll result

- `data` (ApiDataResponseDevicePollData, required) — Poll result returned to the CLI.

## Errors

### 400 Bad Request Error

The request body contains malformed JSON or invalid values.

- `error` (ApiErrorBody, required) — Structured error details.

### 401 Unauthorized Error

Authentication is missing or invalid.

- `error` (ApiErrorBody, required) — Structured error details.

### 403 Forbidden Error

The authenticated principal cannot perform this operation.

- `error` (ApiErrorBody, required) — Structured error details.

### 413 Content Too Large Error

The request body exceeds the configured size limit.

- `error` (ApiErrorBody, required) — Structured error details.

### 415 Unsupported Media Type Error

The request does not have a JSON content type.

- `error` (ApiErrorBody, required) — Structured error details.

### 422 Unprocessable Entity Error

The JSON body does not match the request schema or contains a rejected field value.

- `error` (ApiErrorBody, required) — Structured error details.

### 500 Internal Server Error

An unexpected server or database error occurred.

- `error` (ApiErrorBody, required) — Structured error details.

### 503 Service Unavailable Error

Authentication or the required IP policy could not be refreshed.

- `error` (ApiErrorBody, required) — Structured error details.

## Types

### ApiDataResponseDevicePollData

Poll result returned to the CLI.

- ApiDataResponseDevicePollData0
- ApiDataResponseDevicePollData1
- ApiDataResponseDevicePollData2
- ApiDataResponseDevicePollData3
- ApiDataResponseDevicePollData4

### ApiErrorBody

Structured error details returned by the platform API.

- `message` (string, required) — Human-readable error message.
- `code` (string, optional, nullable) — Stable machine-readable error code, when available.
- `details` (any, optional) — Error-specific structured context, when available.

### ApiDataResponseDevicePollData0

- `status` (enum, required) — Discriminator that selects the `pending` variant.
  - Allowed values: `pending`

### ApiDataResponseDevicePollData1

- `status` (enum, required) — Discriminator that selects the `slow_down` variant.
  - Allowed values: `slow_down`

### ApiDataResponseDevicePollData2

- `status` (enum, required) — Discriminator that selects the `denied` variant.
  - Allowed values: `denied`

### ApiDataResponseDevicePollData3

- `status` (enum, required) — Discriminator that selects the `expired` variant.
  - Allowed values: `expired`

### ApiDataResponseDevicePollData4

Approved; carries the one-time API key secret.

- `api_key` (string, required) — API key secret returned exactly once after approval.
- `organization_id` (string, required) — Organization the new API key belongs to.
- `status` (enum, required) — Discriminator that selects the `approved` variant.
  - Allowed values: `approved`

## Examples

**Request**

```json
{
  "device_code": "string"
}
```

**Response**

```json
{
  "data": {
    "status": "pending"
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.mixlayer.com/v1/cli/device_authorizations/token"

payload = { "device_code": "string" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.mixlayer.com/v1/cli/device_authorizations/token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"device_code":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.mixlayer.com/v1/cli/device_authorizations/token"

	payload := strings.NewReader("{\n  \"device_code\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.mixlayer.com/v1/cli/device_authorizations/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"device_code\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.mixlayer.com/v1/cli/device_authorizations/token")
  .header("Content-Type", "application/json")
  .body("{\n  \"device_code\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.mixlayer.com/v1/cli/device_authorizations/token', [
  'body' => '{
  "device_code": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```