User Management
What are User IDs?
User IDs determine whose connected accounts and data you’re accessing in Composio. Every tool execution, connection authorization, and account operation
requires a userId
parameter that identifies which context to use.
User IDs act as containers that group connected accounts together across toolkits. Depending on your application, you can use User IDs to represent an individual user, a team, or an entire organization.
Quick Decision Guide
How do users access connected accounts in your app?
-
Each user connects their own personal accounts?
Use User IDs
Use your database UUID or primary key (e.g.,user.id
)
Example: Users connect their personal Gmail, GitHub -
Teams share the same connected accounts?
Use Organization IDs
Use your organization UUID or primary key (e.g.,organization.id
)
Example: Company Slack workspace
Patterns
User IDs (Individual Accounts)
In production applications with multiple users, where each user connects and manages their own accounts.
Choosing User IDs:
- Recommended: Database UUID or primary key (
user.id
) - Acceptable: Unique username (
user.username
) - Avoid: Email addresses (emails can change)
Never use ‘default’ as an User ID in production with users. This could expose other users’ data
Organization IDs (Team Accounts)
For applications where teams share connections - one admin connects accounts, all team members use them.
When to use:
- Team tools: Slack, Microsoft Teams, Jira
- Shared accounts: support(at)company.com, company GitHub org
- Enterprise apps: IT manages connections for all employees
Multiple Connected Accounts
A single User ID can have multiple connected accounts for the same toolkit. For example, a user might connect both their personal and work Gmail accounts.
Key concepts:
- Each connected account gets a unique Connected Account ID
- Multiple accounts can exist under the same User ID for any toolkit
- You can specify which account to use when executing tools
Account selection:
- Explicit: Specify the Connected Account ID to target a specific account
- Default: If no Connected Account ID is provided, the most recently connected account is used
Examples
Organization-Based Application
In B2B applications, typically an admin connects accounts once and all team members share access. Here’s a complete implementation:
Key concepts:
- Admin performs the OAuth connection using organization ID
- All team members execute tools using the same organization ID
- Permission checks ensure users can only access their organization’s connections
Multi-User Application
In B2C applications, each user connects and manages their own accounts. Every user goes through their own OAuth flow and their data remains completely isolated.
Key concepts:
- Each user authorizes their own accounts using their unique user ID
- Connections are isolated - users can only access their own connected accounts
- No permission checks needed since users only access their own data
Data isolation: Composio ensures each userId’s connections and data are completely separate. User A can never access User B’s repositories.
Hybrid Pattern
Many applications need both personal and team resources. Users might connect their personal Gmail while sharing the company Slack workspace.
Common scenarios:
- Personal calendars + shared project management
- Individual GitHub accounts + organization repositories
Remember: The userId must match how the account was connected. If admin connected Slack with org ID, all members must use org ID to access it.
Best Practices
Your responsibilities:
- Pass the correct User ID for each user
- Verify user permissions before executing organization tools
- Never use ‘default’ in production with multiple users
- Keep User IDs consistent across your application and Composio
- Use stable identifiers that won’t change over time
Data isolation: Composio ensures complete isolation between User IDs. Users cannot access another ID’s connections or data.