ComposioHQ/composio · error · ComposioMultipleConnectedAccountsError
Multiple connected accounts found for user ${userId} in auth
Error message
Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts. What it means
Thrown by ConnectedAccounts.initiate when the user already has at least one ACTIVE connected account for the given auth config. The SDK blocks creating another connection by default to prevent duplicate accounts; pass allowMultiple: true to opt in.
Source
Thrown at ts/packages/core/src/models/ConnectedAccounts.ts:224
* @link https://docs.composio.dev/reference/connected-accounts/create-connected-account
*/
async initiate(
userId: string,
authConfigId: string,
options?: CreateConnectedAccountOptions,
requestOptions?: ComposioRequestOptions
): Promise<ConnectionRequest> {
// Check if there are multiple connected accounts for the authConfig of the user
const connectedAccount = await this.list(
{
userIds: [userId],
authConfigIds: [authConfigId],
statuses: [ConnectedAccountStatuses.ACTIVE],
},
requestOptions
);
if (connectedAccount.items.length > 0 && !options?.allowMultiple) {
throw new ComposioMultipleConnectedAccountsError(
`Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`
);
} else if (connectedAccount.items.length > 0) {
logger.warn(
`[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`
);
}
const state: ConnectionData | undefined = options?.config ?? undefined;
// @TODO: Commenting this out. This is a temporary fix to allow api_key to be optional, in future ideally we should fix this from API side
// if (options?.config) {
// const connectionDataParsed = ConnectionDataSchema.safeParse(options.config);
// if (!connectionDataParsed.success) {
// throw new ValidationError('Failed to parse connection data', {
// cause: connectionDataParsed.error,
// });
// }View on GitHub (pinned to 64b1b85502)
Solutions
- Pass allowMultiple: true in initiate options if multiple connections are intended
- List existing accounts first (get({authConfigIds:[id], statuses:[ACTIVE]})) and reuse the active connection instead of initiating a new one
- Use a unique per-connection userId if you truly want separate identities
Example fix
// before
await composio.connectedAccounts.initiate('GITHUB', { user: 'me' });
// after
const existing = await composio.connectedAccounts.get({ authConfigIds:['GITHUB'], user:'me' });
if (existing.items.length) return existing.items[0];
await composio.connectedAccounts.initiate('GITHUB', { user: 'me' }); Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await composio.connectedAccounts.get({ authConfigIds:[authConfigId], user: userId, statuses:[ConnectedAccountStatuses.ACTIVE] });
if (existing.items.length && !allowMultiple) return existing.items[0]; Type guard
const isMultipleAccountsError = (e: unknown): boolean => e instanceof ComposioMultipleConnectedAccountsError;
Try / catch
try { return await ca.initiate(authConfigId, { user: userId }); } catch (e) { if (e instanceof ComposioMultipleConnectedAccountsError) return (await ca.get({authConfigIds:[authConfigId], user: userId})).items[0]; throw e; } Prevention
- Query for an active connection before initiating
- Pass allowMultiple only when the product truly supports multiple accounts
When it happens
Trigger: Calling composio.connectedAccounts.initiate({authConfigId, userId}) (or connectionRequest) when a prior active connection for the same user+authConfig already exists and options.allowMultiple is not set.
Common situations: Re-running an OAuth flow after a successful connection, dev environments reusing the same userId, or reconnect flows that don't check existing connections first.
Related errors
- Failed to create connected account link
- module {__name__!r} has no attribute {name!r}
- Failed to upload to S3. Status: {response.status_code}. This
- Request timed out fetching URL: {_sanitize_url_for_logging(u
- Failed to parse connected account list query
AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28).
Data as JSON: /api/errors/90a8f0e1710adcea.
Report an issue: GitHub.