README — POST /api/oauth/token
Exchange a code, or refresh#
POST /api/oauth/token · Operation ID: oauthTokenPurpose and app behavior#
Exchange a single-use code with its original PKCE verifier and exact redirect URI, or refresh once with the latest refresh token. Serialize refreshes and atomically persist the replacement; reusing a spent token revokes the whole authorization. Confidential clients authenticate using Basic or a form secret, never your Handwrite API key.RFC 6749 form body. Confidential clients authenticate with HTTP Basic or client_secret in the form; public clients send client_id and rely on PKCE. Every refresh returns a new refresh token; reusing an old one revokes the whole authorization.Authentication#
Registered OAuth client authentication (confidential) or client_id with PKCE (public); not a personal bearer API key.Example request#
Replace all REPLACE_* placeholders and environment values with data for your authorized test account. Use a new UUID in IDEMPOTENCY_KEY for each logical action where shown; use the actual latest revision for If-Match. Examples of writes change real data if run.curl --fail-with-body -X POST 'https://handwrites.io/api/oauth/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode "client_id=$HANDWRITE_CLIENT_ID" \
--data-urlencode "code=$HANDWRITE_CODE" \
--data-urlencode "redirect_uri=$HANDWRITE_REDIRECT_URI" \
--data-urlencode "code_verifier=$HANDWRITE_PKCE_VERIFIER"
This example is for a public client. A confidential client must additionally authenticate using its client ID and secret (HTTP Basic or client_secret in the form).Request body#
application/x-www-form-urlencoded (required).The paired API reference defines the complete schema and alternatives.Responses#
| Status | Meaning | Body format |
|---|
| 200 | Tokens (Cache-Control: no-store). | application/json |
| 400 | invalid_request, invalid_grant, invalid_scope, unsupported_grant_type. | application/json |
| 401 | invalid_client. | application/json |
| 429 | slow_down. | application/json |
| 500 | server_error. | application/json |
Use the paired API reference for complete request/response schemas. See API specification notes for rate limits, error handling, safe retries and additional policy/plan failures. For binary or empty responses, do not call a JSON parser.Modified at 2026-10-26 13:02:15