{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codai-ro/json-schema/codai-ro-token-request-schema.json",
  "title": "Token request",
  "description": "Form-encoded body. Fields depend on `grant_type`; client credentials depend on the client's authentication method.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codai-ro-auth-openapi.yml#/components/schemas/TokenRequest",
  "type": "object",
  "required": [
    "grant_type"
  ],
  "properties": {
    "grant_type": {
      "type": "string",
      "enum": [
        "authorization_code",
        "refresh_token",
        "urn:ietf:params:oauth:grant-type:device_code"
      ]
    },
    "code": {
      "type": "string",
      "description": "`authorization_code` — the code from the redirect."
    },
    "redirect_uri": {
      "type": "string",
      "format": "uri",
      "description": "`authorization_code` — must equal the value used at `/auth`."
    },
    "code_verifier": {
      "type": "string",
      "description": "`authorization_code` — PKCE verifier (43–128 chars) whose S256 hash was sent as `code_challenge`."
    },
    "refresh_token": {
      "type": "string",
      "description": "`refresh_token` grant."
    },
    "device_code": {
      "type": "string",
      "description": "`device_code` grant — from `/device/auth`."
    },
    "scope": {
      "type": "string",
      "description": "Optional down-scoping on refresh."
    },
    "resource": {
      "type": "string",
      "format": "uri",
      "description": "RFC 8707 resource indicator."
    },
    "client_id": {
      "type": "string",
      "description": "Public clients (`none`) and `client_secret_post`."
    },
    "client_secret": {
      "type": "string",
      "description": "`client_secret_post` only."
    },
    "client_assertion_type": {
      "type": "string",
      "const": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
      "description": "`private_key_jwt` only."
    },
    "client_assertion": {
      "type": "string",
      "description": "`private_key_jwt` — JWT signed with a key from the client's registered `jwks` / `jwks_uri`."
    }
  }
}