OAuth 2.1 (Connect)
Connect Claude, ChatGPT, Zapier, Make, n8n, and Pipedream to Perpetuus with OAuth 2.1 and PKCE, choosing the organization at consent.
Perpetuus is an OAuth 2.1 authorization server. Instead of pasting an API key, the user clicks Connect in the third-party app, signs in to Perpetuus, chooses one organization, reviews the permissions, and approves. The app receives a short-lived access token and a refresh token, which it can revoke at any time.
For scripts and first-party integrations, the API key (ppt_…) remains
the simplest path. Use OAuth when a third-party app acts on behalf of multiple
users.
Endpoints
Issuer: https://api.perpetuus.com.br/oauth
| Endpoint | URL |
|---|---|
| Metadata (RFC 8414) | https://api.perpetuus.com.br/.well-known/oauth-authorization-server/oauth |
| Metadata (OpenID Discovery) | https://api.perpetuus.com.br/oauth/.well-known/openid-configuration |
| Authorization | https://api.perpetuus.com.br/oauth/auth |
| Token | https://api.perpetuus.com.br/oauth/token |
| Dynamic registration (RFC 7591) | https://api.perpetuus.com.br/oauth/reg |
| Revocation (RFC 7009) | https://api.perpetuus.com.br/oauth/token/revocation |
| JWKS | https://api.perpetuus.com.br/oauth/jwks |
Metadata is also served at https://api.perpetuus.com.br/oauth/.well-known/oauth-authorization-server
and https://api.perpetuus.com.br/.well-known/openid-configuration/oauth, the paths that the
MCP specification requires testing when the issuer has a path.
Scopes
Consent applies to one organization. The screen only grants what the user's role in that
organization allows (for example, an operator cannot grant campaign:read), and every API call
still goes through the user's permissions.
| Scope | Grants access to |
|---|---|
crm:read | Read boards, cards, contacts, tasks, and calendar |
crm:write | Create and change CRM data (includes crm:read) |
chat:read | Read conversations and channels |
chat:write | Send messages and operate channels (includes chat:read) |
ai:control | Pause, resume, and take over AI in conversations |
campaign:read | Read campaigns |
offline_access | Accepted for compatibility. The refresh token is issued to every client registered with refresh_token |
The scope × route matrix is the same as for the API key: see Authentication.
Flow (Authorization Code + PKCE)
PKCE with S256 is required for all clients, including confidential ones. The
state parameter is also required: without it, 400 invalid_request.
- Generate a random
code_verifier(43 to 128 characters) andcode_challenge = BASE64URL(SHA256(code_verifier)). - Send the browser to the authorization endpoint:
https://api.perpetuus.com.br/oauth/auth
?response_type=code
&client_id=SEU_CLIENT_ID
&redirect_uri=https%3A%2F%2Fseu-app.com%2Fcallback
&scope=crm%3Aread%20crm%3Awrite
&state=VALOR_ALEATORIO
&code_challenge=CHALLENGE
&code_challenge_method=S256
&resource=https%3A%2F%2Fapi.perpetuus.com.br%2Fapi- The user signs in to the Perpetuus app, chooses the organization, and approves. The return goes to the
redirect_uriwithcode,state, andiss(RFC 9207). If they deny,error=access_denied. - Exchange the code (valid for 60 s and single-use):
curl -X POST "https://api.perpetuus.com.br/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d grant_type=authorization_code \
-d code=CODE_RECEBIDO \
-d redirect_uri=https://seu-app.com/callback \
-d client_id=SEU_CLIENT_ID \
-d code_verifier=SEU_CODE_VERIFIER{
"access_token": "Zk3…",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "crm:read crm:write",
"refresh_token": "q8N…"
}- Call the API with the access token. The organization comes from the token:
x-tenant-idis optional and, if it comes with a different organization, the response is 403.
curl "https://api.perpetuus.com.br/api/auth/token-info" \
-H "Authorization: Bearer ACCESS_TOKEN"GET /auth/token-info returns credential.type = "oauth", the connected
app (client), the scopes, the audience, and the token expiration.
resource parameter (RFC 8707)
Accepted resources: https://api.perpetuus.com.br/api (the default when the client does not send resource)
and the Perpetuus MCP server URL. The value becomes the token aud. Unknown resource:
invalid_target.
redirect_uri
The comparison is exact (no extra trailing slash or different query). The only exception is native-app
loopback (http://localhost:* and http://127.0.0.1:*), where the port is free, as required by
RFC 8252. A URI that differs from the registered one: 400 with no redirect.
Refresh token
Each refresh returns a new refresh token and invalidates the previous one (rotation). If a refresh token that was already used is presented again, Perpetuus treats it as a leak and revokes the entire connection: access tokens and refresh tokens for that connection stop working, and the user needs to connect again.
curl -X POST "https://api.perpetuus.com.br/oauth/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d grant_type=refresh_token \
-d refresh_token=REFRESH_TOKEN \
-d client_id=SEU_CLIENT_ID| Item | Lifetime |
|---|---|
| Code | 60 s, single use |
| Access token | 1 h |
| Refresh token | 30 days without use (renewed on each rotation) |
| Connection | 365 days; after that, a new consent is required |
Errors follow RFC 6749: invalid_grant (invalid, expired, or reused code or refresh token),
invalid_client, invalid_scope, invalid_target, invalid_request.
Client registration
Dynamic registration (RFC 7591)
AI clients (Claude, ChatGPT, MCP Inspector) register themselves:
curl -X POST "https://api.perpetuus.com.br/oauth/reg" \
-H "Content-Type: application/json" \
-d '{
"client_name": "Meu app",
"redirect_uris": ["https://seu-app.com/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "none"
}'redirect_uris:https://, loopbackhttp://localhost/http://127.0.0.1, or a native-app custom scheme.http://on any other host is rejected.- There is a per-IP registration limit per minute (429 with
Retry-After). Clients unused for 30 days are deleted.
Client ID Metadata Document
If client_id is an https:// URL with a JSON metadata document (as with Claude Code
and ChatGPT), Perpetuus fetches the document and no prior registration is needed. The metadata
advertises client_id_metadata_document_supported: true.
Pre-registered clients
Zapier, Make, n8n, and Pipedream use confidential clients registered by Perpetuus, with the exact
redirect_uris of each platform. Token-endpoint authentication uses client_secret_basic or
client_secret_post.
Revocation (RFC 7009)
curl -X POST "https://api.perpetuus.com.br/oauth/token/revocation" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d token=REFRESH_TOKEN \
-d client_id=SEU_CLIENT_IDRevoking the refresh token ends the entire connection. Revoking only the access token invalidates just that token. The user can also revoke from the app, in Configurações → Apps conectados. The next call already fails.
CORS
Metadata, JWKS, token, revocation, and registration accept browser calls, without cookies or
credentials. Token and revocation only accept the origin of a public client's redirect_uri.