Claude Platform Docs

OAuth endpoints and parameters

The endpoints, parameters, scopes, OAuth tokens, lifetimes, and errors of Claude Platform OAuth, in the order a request uses them.

In request order, this page lists the values that Claude Platform OAuth requests use and then the terms used on these pages.

Endpoints

EndpointURL
Authorization endpoint (the approval page)https://auth.claude.com/oauth/authorize
Pushed authorization request (PAR) endpointhttps://auth.claude.com/v1/oauth/par
Token endpointhttps://auth.claude.com/v1/oauth/token
Revocation endpointhttps://auth.claude.com/v1/oauth/revoke
Claude API (user profiles and requests that bill a customer)https://api.anthropic.com

Client authentication

auth.claude.com authenticates your app with a variation of the private_key_jwt method (RFC 7523). Your identity provider, not your app, issues and signs the client assertion. Its iss is your identity provider’s issuer. Its aud is your app’s configured audience, not your client ID or the full URL of the endpoint. auth.claude.com checks it against the keys registered for that issuer and your app’s settings.

Send these parameters in the body of every POST request to the PAR, token, and revocation endpoints.

ParameterValue
client_idYour OAuth app’s client ID, required even with a client assertion
client_assertion_typeurn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertionA JWT from your identity provider with the claims in Client assertion claims

These rules apply to each request:

  • Body: It can be JSON or form-encoded (application/x-www-form-urlencoded). Set the Content-Type header to match.
  • Query string: auth.claude.com rejects credentials in a URL query string.
  • HTTP Basic: Don’t send an HTTP Basic Authorization header. auth.claude.com doesn’t read credentials from it, and the PAR endpoint can refuse a request that has one.

Client assertion claims

A client assertion must contain these claims. The values to match are in your app’s client authentication settings.

ClaimRequirement
issYour identity provider’s issuer URL, exactly as registered through Workload Identity Federation
subYour back end’s subject. If your app’s settings have a subject pattern, the subject must match it.
audExactly one audience: the value in your app’s settings, not the full URL of the endpoint you call
iatThe time your identity provider issued the JWT
expThe expiry time, no more than your issuer’s maximum lifetime after iat (1 hour by default)

A client assertion’s header and signature must also meet these rules:

  • Algorithm: RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, or PS512, the same list as in the WIF reference. auth.claude.com rejects any other, including the HMAC algorithms (HS256, HS384, HS512) and none.
  • Key ID: The header’s kid must name a key in your JWKS. If that key declares an alg, it must be the algorithm that signed the assertion.
  • Your JWKS: Every signing key must have a kid. A key without one makes the whole set unusable.

An assertion’s payload looks like this. Its aud is your app’s own Expected audience, from the app’s Client authentication tab:

{
  "iss": "https://idp.example.com",
  "sub": "workload:prod:claude-integration-backend",
  "aud": "https://auth.claude.com",
  "iat": 1791230000,
  "exp": 1791230300
}

auth.claude.com accepts any JWT from your identity provider that matches your app’s subject pattern and claim conditions. To narrow them, see Set up client authentication.

Authorization requests

To build the approval flow that uses these values, see Send the customer to approve.

Authorization request parameters

Send these parameters and the ones in Client authentication to the PAR endpoint.

ParameterDescription
response_typeThe value code
client_idYour OAuth app’s client ID
redirect_uriA URI that exactly matches a registered redirect URI, up to 2,048 characters
scopebilling:attribution or billing:attribution offline_access. See what each scope allows.
stateA random, single-use value, up to 2,048 characters, that you check on the callback
code_challengeBASE64URL(SHA256(code_verifier)) without padding, where the code_verifier is 43 to 128 characters
code_challenge_methodThe value S256
connection_typeThe value organization_shared. An administrator approves the connection for a whole organization.
connection_auth_targetThe value platform. The connection’s requests route to the owner of the OAuth app.
user_profile_idThe ID of a user profile in your organization that represents the customer and that isn’t archived

The PAR endpoint returns HTTP 201 with request_uri and expires_in. Then, send the person’s browser to the authorization endpoint with only these two parameters:

ParameterValue
client_idYour OAuth app’s client ID
request_uriThe value that the PAR endpoint returned

After the person approves, auth.claude.com redirects the browser to your redirect_uri with these query parameters:

ParameterValue
codeThe authorization code to exchange at the token endpoint
stateThe state value that you sent. Check that it matches.
isshttps://identity.anthropic.com/users, which differs from the endpoints’ host. Check that it’s present and matches.

Scopes

ScopeDescription
billing:attributionA connection that lets you bill a customer’s Claude organization for the Claude API requests that the customer directs you to make. Send it alone or with offline_access.
offline_accessAlso gives your app a refresh token. On a billing connection, send it only together with billing:attribution.
org:billing_attributionDeprecated: use billing:attribution. See If you still use the deprecated scope.

Redirect URI rules

  • Each redirect_uri must exactly match a URI registered on your app. There’s no wildcard or prefix matching. The one exception is a local-development URI registered with an asterisk as the port, such as http://localhost:*/callback, which matches any port.
  • Every redirect URI must use HTTPS and must not contain a fragment. Local-development URIs on localhost, 127.0.0.1, or [::1] may use HTTP.
  • You can register up to 10 redirect URIs for each app.
  • auth.claude.com sends errors to your redirect URI only when the redirect_uri matches a registered URI. For any other redirect_uri, it doesn’t redirect the browser.

OAuth tokens

Token request and response

To exchange a code, send these parameters to the token endpoint:

ParameterValue
grant_typeauthorization_code
codeThe code from the callback
redirect_uriThe same redirect_uri that you sent in the authorization request
code_verifierThe PKCE code verifier
client_id, client_assertion_type, client_assertionAs in Client authentication

To refresh, send grant_type set to refresh_token, the refresh_token, and the parameters in Client authentication. Each refresh token works once, and a billing connection has rules of its own: see the next section and If a refresh fails.

OAuth tokens for a billing connection

For a billing:attribution connection, a refresh must not send a scope parameter. Both grants return these fields:

Response fieldValue
access_tokenThe connection’s access token
token_typeBearer
expires_inSeconds until the access token expires, at most 3600
scopeAlways workspace:inference, not the scope that you asked for
connection_idThe connection ID, for example ocon_01HV9Z. Only the authorization_code grant returns it.
refresh_tokenReturned only when the customer approved offline_access. A refresh returns a new one, which replaces the one you sent.
refresh_token_expires_inSeconds until refresh_token expires. Absent when there’s no refresh_token.

The access token authenticates as your app’s operator service account, in the app’s default workspace, which the API calls its connection_token_workspace_id setting. On /v1/messages and /v1/chat/completions, a request with it is billed to that connection’s customer. It works only on the endpoints listed in Call Claude with a customer’s access token, and any other endpoint refuses it. How to use, refresh, and recover these tokens is in Use a separate credential for each customer.

Each of these events revokes a billing:attribution connection’s tokens, the current access token included:

  • The customer or you unlink.
  • The customer approves a new authorization request with different scopes for the same user profile, and you exchange its code. The new connection replaces the earlier one.
  • The workspace that the tokens run in is archived.
  • A refresh token that a refresh replaced is sent again more than 30 seconds later.
  • You revoke one of the connection’s tokens at the revocation endpoint.

Lifetimes

ItemLifetime
request_uri from the PAR endpoint10 minutes, single use
Authorization code5 minutes, single use
access_tokenUp to 1 hour
refresh_tokenUp to 1 year from the code exchange. A refresh doesn’t extend it.

Where a response gives expires_in or refresh_token_expires_in, read the lifetime from it rather than from this table.

Revocation

Send revocation requests to the revocation endpoint, https://auth.claude.com/v1/oauth/revoke. Besides tokens, it accepts connection and user profile IDs. To unlink a customer or link them again, see Manage linked customers. Send the parameters in Client authentication and exactly one of these:

ParameterWhat it ends
connection_idOne of your app’s connections, given as an ocon_ ID
user_profile_idAll of your app’s connections on one user profile, given as a uprof_ ID
tokenThe connection that an access token or refresh token belongs to, and all of that connection’s tokens

An access token from a connection approved with the deprecated org:billing_attribution scope is an exception: sending it ends only that token. To end that connection, send connection_id or user_profile_id.

auth.claude.com accepts token_type_hint and ignores it.

The endpoint returns HTTP 200 and the IDs of the connections that the request ended:

{
  "revoked_connection_ids": ["ocon_01HV9Z"]
}

The list is empty in any of these cases, and the response doesn’t say which:

  • The token or ID is unknown or belongs to another app.
  • The connection has already ended.
  • The request ended a token but no connection.

After a connection ends, the Claude API refuses requests that bill that customer with user_profile_billing_not_authorized, and the connection’s tokens stop working. An access token from a connection approved with the deprecated scope might instead work until it expires.

Protocol errors

Errors on the redirect

auth.claude.com returns errors as error, error_description, state, and iss query parameters on your redirect URI. They are standard OAuth 2.0 errors (RFC 6749), except user_profile_already_linked.

ErrorWhen
access_deniedThe person declined or can’t approve this request. See access_denied.
server_errorauth.claude.com failed to process the request. Ask the person to try again.
user_profile_already_linkedThe customer’s organization is already linked to your app through a different user profile, or the user profile is already linked to your app through a different organization. See user_profile_already_linked.

If the request_uri has expired or was already used, auth.claude.com displays an error page and doesn’t redirect the browser. Start again with a new pushed authorization request.

Errors from the PAR and token endpoints

These endpoints return a JSON body with error and error_description.

ErrorWhen
invalid_requestA required parameter is missing or invalid, such as a missing state, a missing PKCE challenge, or a user_profile_id that isn’t an active user profile in your organization
invalid_clientThe client ID is unknown, or the client assertion failed a check in Client assertion claims. Your app’s Client authentication history in the Claude Console says which check failed.
invalid_scopeThe scope isn’t allowed for this app, a refresh of a billing connection sent a scope parameter, or billing:attribution was removed from your app. In the last case, a code exchange also uses up the code.
invalid_grantAt the code exchange: the code expired or was already used, the person who approved has signed out, or the code doesn’t match the redirect_uri or code_verifier. A mismatch uses up the code.
invalid_grantAt the code exchange: the customer approved again with the same scopes while their connection has a refresh token. See If a customer approves again.
invalid_grantOn a refresh: see If a refresh fails
unauthorized_clientYour app isn’t set up for this request. It uses up no code and revokes no refresh token. See unauthorized_client or, for a refresh, If a refresh fails.
user_profile_already_linkedFrom the token endpoint: between the approval and the exchange, the profile or the organization was linked another way

Some responses come in another format, which might not be JSON. That happens when auth.claude.com rate-limits a request or has an outage. It also happens for an unknown grant_type or a parameter that’s too long. Handle a response without a string error by its status, using the first row that fits:

StatusWhat to do
Any status, on a refreshFollow If a refresh fails.
501Anthropic has turned the endpoint off. Don’t retry.
429 or 5xxRetry with backoff, and wait at least as long as any retry-after header says. Send each retry from your own code: an HTTP client’s automatic retries might not run for such a response.
Any other statusTreat it as a fault in the request.

Errors from the revocation endpoint

For most refusals, the revocation endpoint returns HTTP 400 and a JSON body with error and error_description.

ErrorWhen
invalid_requestA parameter is missing or invalid: none or more than one of token, connection_id, and user_profile_id, a malformed ID, or a credential in the URL query string
invalid_requestThe user profile has too many connections for one request. It might have ended some, so end the rest with each connection_id.
invalid_clientauth.claude.com couldn’t authenticate your app. Check your client assertion against Client assertion claims. Your app’s Client authentication history doesn’t record this endpoint.
unauthorized_clientYour app isn’t set up for this request. Contact Anthropic support or your Anthropic account team if you have one.

Other refusals carry only a status, and their body might not be JSON. When such a body is JSON, its error is an object, not a string:

StatusWhenWhat to do
400A parameter is longer than its limitCorrect the request. Don’t retry.
429Too many failed requests came from your IP addressRetry with backoff.
500auth.claude.com failed to process the requestRetry with backoff. If it keeps happening, contact support or your account team.
501Anthropic has turned the endpoint offDon’t retry. Contact support or your account team.
503The request didn’t finish, and anything it ended stays endedRetry with backoff. Use the same parameters and a new client assertion.

A retry after a 503 finishes the rest, and its list leaves out connections that the earlier request ended. With connection_id, retry at any time. With user_profile_id, retry within a day. After a day, a retry still ends active connections. It doesn’t revoke what’s left of the connections that the failed request ended, such as their OAuth tokens. To revoke that, send each stored connection_id.

Billing errors

The Claude API’s errors for requests that bill a customer or that use a customer’s access token are in Linked billing errors.

Standards

StandardWhere it applies
OAuth 2.0 (RFC 6749)The authorization code flow, the token endpoint, and error responses
PKCE (RFC 7636)Required with S256 on every authorization request
Pushed authorization requests (RFC 9126)Required for Linked billing
Authorization server issuer identification (RFC 9207)The iss parameter on every redirect to your app
Token revocation (RFC 7009)The revocation endpoint, which also takes connection and user profile IDs
JWT client authentication (RFC 7523)Client authentication at the PAR, token, and revocation endpoints

Terms used on these pages

These meanings apply only to Claude Platform OAuth.

TermMeaning
Claude organizationAn organization account with Anthropic. Your company has one, and so does each customer that links its organization for billing.
AdministratorA member of a Claude organization with the Admin or Billing role
OAuth appThe registration in your Claude organization that identifies your product to auth.claude.com. It has a client ID, name, logo, homepage, and redirect URIs.
Identity providerThe service in your own infrastructure that signs short-lived JWTs for your back end and publishes its public keys as a JSON Web Key Set (JWKS). It’s never Anthropic.
Client assertionA short-lived JWT that your identity provider signs and that your back end sends to authenticate your OAuth app
Pushed authorization request (PAR)A request in which your back end sends the authorization parameters to auth.claude.com and gets a request_uri to use in the browser redirect
Workload Identity FederationThe Claude Console feature where your organization registers your identity provider so that Anthropic accepts JWTs signed with your keys
User profileA record in your own Claude organization that stands for one of your customers
ConnectionThe record that ties a customer’s Claude organization to one of your user profiles, created when the customer links your app. Its ID starts with ocon_.
Service accountA non-human account in your Claude organization. Your app’s operator service account is the one your back end authenticates as to bill a customer.
Connection’s OAuth tokensThe access token that auth.claude.com returns for a connection and the refresh token it returns with offline_access. The access token can bill only that connection’s customer.

Was this page helpful?