API reference

Authorize and token

The authorization code flow with PKCE, the consent hand-off, refresh, and token exchange for the MCP gateway.

An MCP client sends the user to authorize. Scute checks the request and redirects the browser to a consent page. The page signs the user in, reads the request, and records the user's decision. The client then swaps the code for tokens at token.

The consent page is the app's hosted page at /oauth/authorize on its tenant domain (its custom domain when one is active), or the app's own page when login_url is set in the server settings. Scute adds request=<handle> to the URL.

Start authorization#

GET/v1/oauth/:app_id/authorizeNone
response_typestringrequired
code.
client_idstringrequired
The client's id. An https URL is read as a client ID metadata document when the app allows them.
redirect_uristringrequired
Must match one of the client's redirect URIs exactly. A loopback http URI may use any port.
code_challengestringrequired
The PKCE challenge: 43 characters, base64url of the SHA-256 of the verifier.
code_challenge_methodstringrequired
S256.
resourcestringrequired
URL of one of the app's active MCP servers.
scopestring
Space-separated scopes. Each must be offered by the resource. Left out means every scope of the resource.
statestring
Returned to the client unchanged. Up to 1000 characters are kept.

On success Scute redirects to the consent page. The sign-in request it opens is valid for 10 minutes.

Errors:

CaseResponse
Unknown or disabled client, or a metadata document that can't be used400 JSON, error invalid_client
redirect_uri not registered for the client400 JSON, error invalid_request
response_type is not codeRedirect to redirect_uri with error=unsupported_response_type
Missing PKCE or a method other than S256Redirect with error=invalid_request
resource missing or not one of the app's MCP serversRedirect with error=invalid_target
A scope the resource doesn't offerRedirect with error=invalid_scope

Errors sent to the client's redirect_uri carry error, error_description, state and iss. Errors before the client and redirect URI are checked are never sent to the redirect URI.

Read a sign-in request#

GET/v1/oauth/:app_id/requests/:handleNone

What the consent page shows. :handle is the request value from the consent page URL. With the signed-in user's access token in X-Authorization, the response also has already_granted: true when an active grant already covers this client, resource and scopes.

Response 200json
{  "client": {    "name": "Claude",    "client_id": "https://claude.ai/oauth/client.json",    "kind": "metadata_document",    "host": "claude.ai",    "client_uri": "https://claude.ai",    "logo_uri": null  },  "resource": { "url": "https://mcp.acme.example", "name": "Acme MCP" },  "scopes": ["mcp"],  "expires_at": "2026-11-18T10:10:00.000Z",  "already_granted": false}

An expired or used request returns 404 with error_code request_not_found.

Record the user's decision#

POST/v1/oauth/:app_id/requests/:handle/decisionAccess token

Called by the consent page with the signed-in user's access token in X-Authorization.

decisionstringrequired
approve or deny.
Response 200json
{  "redirect_to": "https://client.example/callback?code=oac_...&state=xyz&iss=https%3A%2F%2Fapi.scute.io%2Fv1%2Foauth%2Fapp_3mxZRrzWxhPZ08dXvqq6"}

Send the browser to redirect_to. On deny it carries error=access_denied. On approve Scute creates or extends the user's grant and adds a code (oac_...) valid for 60 seconds.

Statuserror_codeWhen
401authentication_requiredNo valid access token for this app.
422invaliddecision is not approve or deny.
404request_not_foundThe request expired or was already used.

Exchange a code for tokens#

POST/v1/oauth/:app_id/tokenNone
grant_typestringrequired
authorization_code.
client_idstringrequired
The client's id.
codestringrequired
The code from the redirect.
redirect_uristringrequired
The same redirect_uri sent to authorize.
code_verifierstringrequired
The PKCE verifier: 43 to 128 characters.
resourcestring
If sent, must match the resource of the grant.
cURLbash
curl -X POST https://api.scute.io/v1/oauth/app_3mxZRrzWxhPZ08dXvqq6/token \  -d grant_type=authorization_code \  -d client_id=cli_xxxxxxxxxxxxxxxxxxxxxxxx \  -d code=oac_xxx \  -d redirect_uri=https://client.example/callback \  -d code_verifier=$CODE_VERIFIER
Response 200json
{  "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6Ii4uLiIsInR5cCI6ImF0K2p3dCJ9...",  "token_type": "Bearer",  "expires_in": 3600,  "refresh_token": "ort_xxx",  "scope": "mcp"}

Token responses carry Cache-Control: no-store. A code can be used once: a second use returns invalid_grant and revokes the grant.

Refresh tokens#

POST/v1/oauth/:app_id/tokenNone
grant_typestringrequired
refresh_token.
client_idstringrequired
The client's id.
refresh_tokenstringrequired
The current refresh token.
scopestring
A subset of the granted scopes. Left out means the same scopes. Asking for more returns invalid_scope.
resourcestring
If sent, must match the resource of the grant.

Returns a new access token and a new refresh token. The old refresh token stops working. Reusing a used refresh token returns invalid_grant and revokes the grant. Refresh tokens last the app's refresh_ttl, default 30 days.

Token errors#

Errors from token are JSON with error and error_description:

StatuserrorWhen
401invalid_clientUnknown or disabled client.
400invalid_grantUnknown, expired or used code or refresh token, revoked grant, redirect_uri mismatch, failed PKCE check, or a user who may not sign in (banned or suspended).
400invalid_targetresource doesn't match the grant.
400invalid_scopeA refresh asked for scopes beyond the grant.
400unsupported_grant_typeAny other grant_type.

Exchange an access token for a task token#

POST/v1/oauth/:app_id/tokenApp key

For the MCP gateway in front of the app's MCP server (RFC 8693). It trades a user's access token for an agent task token, so each tool call is checked against the agent, the user and the task. Needs the app key in Authorization: Bearer.

grant_typestringrequired
urn:ietf:params:oauth:grant-type:token-exchange.
subject_tokenstringrequired
The user's access token from this app.
subject_token_typestringrequired
urn:ietf:params:oauth:token-type:access_token.
resourcestring
If sent, must match the access token's aud.
Response 200json
{  "access_token": "...",  "issued_token_type": "urn:scute:params:oauth:token-type:task",  "token_type": "N_A",  "expires_in": 3412,  "scope": "mcp",  "task_id": "0193f960-1111-7222-8333-444444444444",  "agent": "claude-desktop"}

The task lasts as long as the access token, and at least 60 seconds. The agent is the one linked to the client, else the app's default_agent. When the resource maps scopes to permissions, scope_actions is included and the task may use only the permissions of the granted scopes.

StatuserrorWhen
401invalid_clientNo valid app key.
400invalid_requestWrong subject_token_type, or no agent linked to the client and no default agent.
400invalid_grantThe subject token is not a live access token of this app, the agent is suspended, or the user may not sign in.
400invalid_targetresource doesn't match the token's audience.