OAuth token endpoint
const url = 'https://api-dev.mindflow.io/v1/oauth/token';const options = { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: new URLSearchParams({ grant_type: 'authorization_code', code: 'f9SpG6WosBK5KY3RStV4QRWLZADu1XR4TuCS3BnNQAo', code_verifier: 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk', client_id: 'UJu3PB7RPORHyi0mXo8frl-NSQ58Tfh2mjjSj4xHlrY', redirect_uri: 'myapp://oauth/callback' })};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api-dev.mindflow.io/v1/oauth/token \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=authorization_code \ --data code=f9SpG6WosBK5KY3RStV4QRWLZADu1XR4TuCS3BnNQAo \ --data code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk \ --data client_id=UJu3PB7RPORHyi0mXo8frl-NSQ58Tfh2mjjSj4xHlrY \ --data redirect_uri=myapp://oauth/callbackExchanges an authorization code, or refreshes an access token. Send application/x-www-form-urlencoded. No bearer token.
For grant_type=authorization_code, send code, code_verifier, client_id, and redirect_uri. Do this within 60 seconds of configure. redirect_uri must match the authorize call.
For grant_type=refresh_token, send refresh_token and client_id. The response includes a new refresh token. Use that value next time. A token that was already replaced is rejected.
resource is optional on both grant types. When sent, it must be this tenant’s Platform API URL or MCP resource URL; any other value is 400 invalid_target. It must be the resource stored on the grant; a mismatch is 400 invalid_grant. Omit it to keep that stored audience. Every access token carries it as aud.
When client_id is a Client ID Metadata Document URL, the cached document is used and fetched again once it expires. 401 invalid_client when it can no longer be loaded or validated.
Request Bodyrequired
Section titled “Request Bodyrequired”Form fields for one token call. Send the fields required by grant_type. Extra fields are ignored.
Form fields for one token call. Send the fields required by grant_type. Extra fields are ignored.
object
Which grant to run. Use authorization_code to redeem a code. Use refresh_token to rotate an access token.
Authorization code from the configure redirect. Required when grant_type is authorization_code. It expires 60 seconds after configure.
PKCE verifier that produced code_challenge. 43 to 128 unreserved characters. Required for authorization_code.
Refresh token from the previous token response. Required when grant_type is refresh_token.
Client id from registration, or the HTTPS URL of the client’s Client ID Metadata Document. Required for both grant types.
Same redirect URI sent to authorize. Required for authorization_code.
Optional RFC 8707 resource indicator. When sent, it must be this tenant’s Platform API URL (https://api-{tenant}.mindflow.io/v1) or MCP resource URL (https://mcp-{tenant}.mindflow.io/mcp), and the resource stored on the grant. Omit it to keep that audience.
Examples
Redeem an authorization code
grant_type=authorization_code&code=f9SpG6WosBK5KY3RStV4QRWLZADu1XR4TuCS3BnNQAo&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk&client_id=UJu3PB7RPORHyi0mXo8frl-NSQ58Tfh2mjjSj4xHlrY&redirect_uri=myapp%3A%2F%2Foauth%2FcallbackRotate an access token
grant_type=refresh_token&refresh_token=UJu3PB7RPORHyi0mXo8frl-NSQ58Tfh2mjjSj4xHlrY&client_id=UJu3PB7RPORHyi0mXo8frl-NSQ58Tfh2mjjSj4xHlrYResponses
Section titled “Responses”Issued OAuth tokens (access_token, token_type, expires_in, optional refresh_token).
New access token and a refresh token to store for the next refresh.
object
Opaque OAuth access token (Bearer) for Platform REST routes that accept user tokens and for GET /oauth/whoami. It is not the identity JWT.
Always Bearer (OAuth token type). Send the access token as Authorization: Bearer <token>.
Seconds until access_token stops working. The value is 3600.
Opaque token for the next refresh. It replaces any previous refresh token for this approval. It lasts 14 days.
Example
{ "access_token": "f9SpG6WosBK5KY3RStV4QRWLZADu1XR4TuCS3BnNQAo", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "UJu3PB7RPORHyi0mXo8frl-NSQ58Tfh2mjjSj4xHlrY"}Headers
Section titled “Headers”Example
1000Maximum number of requests allowed in the current window. Present when this response is rate limited.
Example
42Number of requests still allowed in the current window. 0 means the next call can return 429 until the window resets.
Example
2026-03-20T15:31:00.000ZTime when the current window resets, as ISO 8601 UTC. After this time, X-RateLimit-Remaining starts over.
Example
30HTTP Retry-After value in seconds. Wait at least this long before retrying a 429 response.
Example
*CORS Access-Control-Allow-Origin value. Origin allowed to read this response from a browser. * means any origin may read it.
The request was invalid. Common causes include:
- Invalid timestamp format.
- Using
cursorwithbeforeorafter. - Missing
limitwhen usingbeforeorafter. - Invalid field names in the
fieldsparameter.
See the error response for specific details about what went wrong.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Always BAD_REQUEST on this response. Read detail for which value to change, then send a corrected request.
Example
{ "type": "about:blank", "title": "Bad Request", "status": 400, "detail": "The request body or query is invalid.", "code": "BAD_REQUEST"}Headers
Section titled “Headers”Example
1000Maximum number of requests allowed in the current window. Present when this response is rate limited.
Example
42Number of requests still allowed in the current window. 0 means the next call can return 429 until the window resets.
Example
2026-03-20T15:31:00.000ZTime when the current window resets, as ISO 8601 UTC. After this time, X-RateLimit-Remaining starts over.
Example
30HTTP Retry-After value in seconds. Wait at least this long before retrying a 429 response.
Example
*CORS Access-Control-Allow-Origin value. Origin allowed to read this response from a browser. * means any origin may read it.
Authentication failed. The request lacks valid credentials or the provided credentials are invalid.
Ensure you have:
- A valid API key or token.
- Proper authentication headers.
- Required permissions.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Always MISSING_OR_INVALID_TOKEN on this response. Branch on this value, not on detail.
Example
{ "type": "about:blank", "title": "Unauthorized", "status": 401, "detail": "The bearer token is missing or invalid.", "code": "MISSING_OR_INVALID_TOKEN"}Headers
Section titled “Headers”Example
1000Maximum number of requests allowed in the current window. Present when this response is rate limited.
Example
42Number of requests still allowed in the current window. 0 means the next call can return 429 until the window resets.
Example
2026-03-20T15:31:00.000ZTime when the current window resets, as ISO 8601 UTC. After this time, X-RateLimit-Remaining starts over.
Example
30HTTP Retry-After value in seconds. Wait at least this long before retrying a 429 response.
Example
*CORS Access-Control-Allow-Origin value. Origin allowed to read this response from a browser. * means any origin may read it.
Too many requests. The request rate limit has been exceeded.
Please wait until the rate limit window resets before making additional requests.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Always RATE_LIMIT_EXCEEDED on this response. Wait Retry-After seconds before retrying.
Example
{ "type": "about:blank", "title": "Too Many Requests", "status": 429, "detail": "The request rate limit has been exceeded.", "code": "RATE_LIMIT_EXCEEDED"}Headers
Section titled “Headers”Example
1000Maximum number of requests allowed in the current window. Present when this response is rate limited.
Example
42Number of requests still allowed in the current window. 0 means the next call can return 429 until the window resets.
Example
2026-03-20T15:31:00.000ZTime when the current window resets, as ISO 8601 UTC. After this time, X-RateLimit-Remaining starts over.
Example
30HTTP Retry-After value in seconds. Wait at least this long before retrying a 429 response.
Example
*CORS Access-Control-Allow-Origin value. Origin allowed to read this response from a browser. * means any origin may read it.
Internal server error. The server encountered an unexpected condition that prevented it from fulfilling the request.
Please try again later or contact support if the problem persists.
object
URI reference identifying the problem type. When absent, “about:blank” per RFC 9457 Section 3.1.1.
Short, human-readable summary of the problem type (RFC 9457 Section 3.1.3).
HTTP status code for this occurrence (advisory; same as response status) (RFC 9457 Section 3.1.2).
Human-readable explanation specific to this occurrence (RFC 9457 Section 3.1.4).
URI reference identifying the specific occurrence (RFC 9457 Section 3.1.5).
Always INTERNAL_ERROR on this response. Retry later. Do not retry a create in a tight loop.
Example
{ "type": "about:blank", "title": "Internal Server Error", "status": 500, "detail": "The request could not be completed.", "code": "INTERNAL_ERROR"}Headers
Section titled “Headers”Example
1000Maximum number of requests allowed in the current window. Present when this response is rate limited.
Example
42Number of requests still allowed in the current window. 0 means the next call can return 429 until the window resets.
Example
2026-03-20T15:31:00.000ZTime when the current window resets, as ISO 8601 UTC. After this time, X-RateLimit-Remaining starts over.
Example
30HTTP Retry-After value in seconds. Wait at least this long before retrying a 429 response.
Example
*CORS Access-Control-Allow-Origin value. Origin allowed to read this response from a browser. * means any origin may read it.