Connections are credentials a user holds for an external service (Linear, GitHub, Slack, …). Your app declares how those credentials are obtained — a connection provider — and consumes them at runtime to make authenticated calls to the third-party API. Today only OAuth 2.0 is supported. Future credential types (personal access tokens, API keys, basic auth) will plug into the same surface — apps already usingDocumentation Index
Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
Use this file to discover all available pages before exploring further.
defineConnectionProvider({ type: 'oauth', ... }) won’t need to migrate.
defineConnectionProvider
Declare how your app's connections are obtained
defineConnectionProvider
Declare how your app's connections are obtained
A connection provider describes the OAuth handshake your app needs. The user clicks “Add connection” in your app’s settings, completes the provider’s consent screen, and a Key points:
ConnectedAccount row is created in their workspace.A working setup needs two files — the connection provider, and a matching serverVariables declaration on defineApplication that holds the OAuth client credentials.src/connection-providers/linear-connection.ts
src/application.config.ts
nameis the unique identifier string used inlistConnections({ providerName })(kebab-case, must match^[a-z][a-z0-9-]*$).displayNameshows in the per-app settings tab and in the AI tool list.clientIdVariable/clientSecretVariableare names, not values — they must match keys declared indefineApplication.serverVariables. The actualclient_idandclient_secretare entered by the server admin through the app registration UI, never committed to your repo.- Use
serverVariables(notapplicationVariables) — OAuth credentials are server-wide and one OAuth app per Twenty server. - Until both
serverVariablesare filled in, the per-app settings tab shows a “needs server admin” hint and the “Add connection” button is disabled. type: 'oauth'is the only supported value today. The discriminator is forward-compatible: future types ('pat','api-key', …) will add new sub-config blocks alongsideoauth.
listConnections / getConnection
Use connections from a logic function
listConnections / getConnection
Use connections from a logic function
Inside a logic function handler, Each connection has:
Key points:
listConnections({ providerName }) returns this app’s ConnectedAccount rows for the given provider, with refreshed access tokens.src/logic-functions/handlers/create-linear-issue-handler.ts
| Field | Description |
|---|---|
id | Unique row id; pass to getConnection(id) to refetch a single one |
visibility | 'user' (private to one workspace member) or 'workspace' (shared with all members) |
scopes | OAuth permissions granted by the upstream provider (distinct from visibility — those are unrelated) |
userWorkspaceId | The owner’s userWorkspace id — useful for picking “the request user’s connection” in HTTP-route triggers |
accessToken | Fresh OAuth access token (refreshed automatically if expired) |
name / handle | The connection’s display name (auto-derived at OAuth callback, user-renameable) |
authFailedAt | Set when the most recent refresh failed; the user must reconnect |
- Pass
{ providerName }to filter by provider; omit it to get all connections this app owns across all providers. - The server transparently refreshes the access token before returning. Your handler always sees a usable token (or
authFailedAtset). getConnection(id)is the single-row equivalent.
Per-user vs workspace-shared visibility
How users choose between private and shared credentials
Per-user vs workspace-shared visibility
How users choose between private and shared credentials
One-time provider setup
Register your OAuth app with the third-party service
One-time provider setup
Register your OAuth app with the third-party service
For each connection provider, the server admin needs to register an OAuth app at the third party first.
- Go to the provider’s developer settings (e.g. https://linear.app/settings/api/applications/new).
- Set the Redirect URI to
<SERVER_URL>/apps/oauth/callback. - Copy the generated Client ID and Client Secret.
- Open the installed app in Twenty as a server admin → set the values on the corresponding
serverVariables. - Workspace members can then add connections from the per-app Connections section.