---
title: "Device Token"
method: POST
path: "/oauth/device/token"
tags: ["oauth"]
---

# Device Token

`POST /oauth/device/token`

## Request

- Base URL: `https://api.ranch.bot`
- URL: `https://api.ranch.bot/oauth/device/token`
- Auth: none required

Current oauth HTTP operation. No resource-scope middleware on this operation. Access is resolved for the authenticated user or by the endpoint-specific OAuth checks. Production rate limit: 240 requests per 15-minute window, per client IP. RateLimit headers report the current window; respect Retry-After on 429. Poll with the returned device_code and original client_id. Pending authorization returns an OAuth 400 body. Malformed request bodies return the standard validation 400 envelope. Invalid, consumed, expired, mismatched-client, or disallowed-permission device codes return the standard 401 envelope.

## Request body

- object
  - `grant_type` 'urn:ietf:params:oauth:grant-type:device_code', required
  - `device_code` string, required
  - `client_id` string, required

## Response `200`

Success

- object
  - `scope` string, required
  - `access_token` string, required
  - `token_type` 'Bearer', required
  - `expires_in` number, required
  - `refresh_token` string: Returned for normal registered clients. The observer client (ranchbot-pi-observer-v1) omits this field; observer sessions cannot be refreshed.

## Other responses

- `400`: Pending authorization returns an OAuth error object; malformed request bodies return the standard validation error envelope.
- `401`: Invalid, consumed, expired, mismatched-client, or disallowed-permission device code; returns the standard error envelope.
- `403`: Missing required scope or credential type is disallowed.
- `404`: Resource or active farm membership not found.
- `429`: Rate limit exceeded. Retry after the indicated delay.
- `500`: Unexpected server failure.

---

[API](https://skmtc.dev/ranch/apis/ranch-bot-http-api.md) · [All operations](https://skmtc.dev/ranch/apis/ranch-bot-http-api/llms.txt) · [OpenAPI document](https://skmtc.dev/ranch/apis/ranch-bot-http-api/revisions/24109d33fa02?raw)
