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

# Token

`POST /oauth/token`

## Request

- Base URL: `https://api.ranch.bot`
- URL: `https://api.ranch.bot/oauth/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. Authorization-code exchange requires code and redirect_uri. A refresh-token grant requires refresh_token. Use the configured client and its directed setup; do not infer a working public client from endpoint existence.

## Request body

- object
  - `grant_type` 'authorization_code' | 'refresh_token', required
  - `code` string
  - `redirect_uri` string
  - `refresh_token` string
  - `client_id` string, required
  - `client_secret` string
  - `code_verifier` string

## Response `200`

Success

- union
  - object
    - `access_token` string, required
    - `token_type` string, required
    - `expires_in` number, required
    - `refresh_token` string, required
    - `scope` string, required
  - object
    - `refresh_token` string, required
    - `scope` string, required
    - `access_token` string, required
    - `token_type` 'Bearer', required
    - `expires_in` number, required
  - object
    - `access_token` string, required
    - `token_type` string, required
    - `expires_in` number, required
    - `refresh_token` string, required

## Other responses

- `400`: Request validation failed.
- `401`: Missing/invalid authentication or insufficient farm role.
- `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)
