When to Use OAuth
Register a Client
Twenty supports dynamic client registration per RFC 7591. No manual setup needed — register programmatically:Escopos
| Scope | Acesso |
|---|---|
api | Full read/write access to the Core and Metadata APIs |
perfil | Read the authenticated user’s profile information |
scope=api profile
Authorization Code Flow
Use this flow when your app acts on behalf of a Twenty user.1. Redirect the user to authorize
| Parâmetro | Obrigatório | Descrição |
|---|---|---|
client_id | Sim | Your registered client ID |
response_type | Sim | Must be code |
redirect_uri | Sim | Must match a registered redirect URI |
scope | Não | Space-separated scopes (defaults to api) |
estado | Recomendado | Random string to prevent CSRF attacks |
code_challenge | Recomendado | PKCE challenge (SHA-256 hash of verifier, base64url-encoded) |
code_challenge_method | Recomendado | Must be S256 when using PKCE |
2. Handle the callback
After authorization, Twenty redirects back to yourredirect_uri:
state matches what you sent.
3. Exchange the code for tokens
4. Use the access token
5. Refresh when expired
Client Credentials Flow
For server-to-server integrations with no user interaction:Server Discovery
Twenty publishes its OAuth configuration at a standard discovery endpoint:API Endpoints Summary
| Endpoint | Finalidade |
|---|---|
/.well-known/oauth-authorization-server | Server metadata discovery |
/oauth/register | Dynamic client registration |
/oauth/authorize | User authorization |
/oauth/token | Token exchange and refresh |
| Ambiente | URL base |
|---|---|
| Nuvem | https://api.twenty.com |
| Auto-hospedado | https://{your-domain} |
OAuth vs API Keys
| Chaves API | OAuth | |
|---|---|---|
| Configuração | Generate in Settings | Register a client, implement flow |
| User context | None (workspace-level) | Specific user’s permissions |
| Melhor para | Scripts, internal tools | External apps, multi-user integrations |
| Token rotation | Manual | Automatic via refresh tokens |
| Scoped access | Full API access | Granular via scopes |