Connected Accounts
Connected accounts represent authenticated user connections to third-party services. They store credentials and authentication state, enabling users to execute tools on external platforms like GitHub, Slack, or Gmail.Overview
TheConnectedAccounts class manages user authentication and connections to external services in the Composio SDK. Each connected account links a user to a specific toolkit through an authentication configuration.
Source: ts/packages/core/src/models/ConnectedAccounts.ts
Creating Connected Accounts
Initiate a Connection
Theinitiate method creates a new connected account and returns a connection request:
By default,
initiate prevents creating multiple connected accounts for the same user and auth config. Set allowMultiple: true in options to override this behavior.Create a Composio Connect Link
Generate an external link for users to authenticate:Wait for Connection
Poll for connection completion:The
waitForConnection method continuously polls the API until the connection becomes active, fails, or times out. Terminal states include: ACTIVE, FAILED, EXPIRED, and DELETED.Listing Connected Accounts
List All Connected Accounts
Filter by User
Filter by Toolkit
Filter by Status
Combine Filters
Pagination
Retrieving a Connected Account
Get detailed information about a specific connected account:Managing Connected Accounts
Refresh Credentials
Refresh OAuth tokens or other credentials:Enable/Disable Accounts
Update Account Status
Update with additional context:Delete a Connected Account
Deleting a connected account is permanent and cannot be undone. It will revoke any access tokens associated with the account.
Connected Account Properties
Every connected account object contains:id- Unique identifier for the connected accountuserId- The external user IDstatus- Current status (INITIATED, ACTIVE, FAILED, EXPIRED, DELETED)toolkit- Information about the connected toolkitauthConfig- Authentication configuration detailsstate- Authentication state and credentials (encrypted)isDisabled- Whether the account is disabledcreatedAt- When the account was createdupdatedAt- When the account was last updated
Connection Status
Possible status values:INITIATED- Connection process started, waiting for user authenticationACTIVE- Successfully connected and authenticatedFAILED- Authentication failedEXPIRED- Connection expired (credentials no longer valid)DELETED- Connection was deleted
Complete Connection Flow Example
Multiple Accounts Per User
Allow users to connect multiple accounts for the same service:When
allowMultiple is true, the SDK will allow creating multiple connected accounts for the same user and auth config combination. This is useful when users need to manage multiple GitHub organizations or Slack workspaces.Error Handling
Common errors when working with connected accounts:ComposioConnectedAccountNotFoundError- Connected account doesn’t existComposioMultipleConnectedAccountsError- Multiple accounts exist andallowMultipleis falseComposioFailedToCreateConnectedAccountLink- Failed to create connection linkConnectionRequestFailedError- Connection entered a failed stateConnectionRequestTimeoutError- Connection didn’t complete within timeoutValidationError- Invalid parameters passed to methods
Example Error Handling
Related Resources
- Authentication - Configure authentication methods
- Toolkits - Services that connected accounts authenticate with
- Tools - Execute tools using connected accounts
- Providers - Use connected accounts with AI frameworks