{"record":{"id":"90a8f0e1710adcea","repo":"ComposioHQ/composio","slug":"multiple-connected-accounts-found-for-user-useri","errorCode":null,"errorMessage":"Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.","messagePattern":"Multiple connected accounts found for user (.+?) in auth config (.+?)\\. Please use the allowMultiple option to allow multiple connected accounts\\.","errorType":"exception","errorClass":"ComposioMultipleConnectedAccountsError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/ConnectedAccounts.ts","lineNumber":224,"sourceCode":"   * @link https://docs.composio.dev/reference/connected-accounts/create-connected-account\n   */\n  async initiate(\n    userId: string,\n    authConfigId: string,\n    options?: CreateConnectedAccountOptions,\n    requestOptions?: ComposioRequestOptions\n  ): Promise<ConnectionRequest> {\n    // Check if there are multiple connected accounts for the authConfig of the user\n    const connectedAccount = await this.list(\n      {\n        userIds: [userId],\n        authConfigIds: [authConfigId],\n        statuses: [ConnectedAccountStatuses.ACTIVE],\n      },\n      requestOptions\n    );\n    if (connectedAccount.items.length > 0 && !options?.allowMultiple) {\n      throw new ComposioMultipleConnectedAccountsError(\n        `Multiple connected accounts found for user ${userId} in auth config ${authConfigId}. Please use the allowMultiple option to allow multiple connected accounts.`\n      );\n    } else if (connectedAccount.items.length > 0) {\n      logger.warn(\n        `[Warn:AllowMultiple] Multiple connected accounts found for user ${userId} in auth config ${authConfigId}`\n      );\n    }\n\n    const state: ConnectionData | undefined = options?.config ?? undefined;\n    // @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\n\n    // if (options?.config) {\n    //   const connectionDataParsed = ConnectionDataSchema.safeParse(options.config);\n    //   if (!connectionDataParsed.success) {\n    //     throw new ValidationError('Failed to parse connection data', {\n    //       cause: connectionDataParsed.error,\n    //     });\n    //   }","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/ConnectedAccounts.ts#L206-L242","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nawait composio.connectedAccounts.initiate('GITHUB', { user: 'me' });\n// after\nconst existing = await composio.connectedAccounts.get({ authConfigIds:['GITHUB'], user:'me' });\nif (existing.items.length) return existing.items[0];\nawait composio.connectedAccounts.initiate('GITHUB', { user: 'me' });","handlingStrategy":"try-catch","validationCode":"const existing = await composio.connectedAccounts.get({ authConfigIds:[authConfigId], user: userId, statuses:[ConnectedAccountStatuses.ACTIVE] });\nif (existing.items.length && !allowMultiple) return existing.items[0];","typeGuard":"const isMultipleAccountsError = (e: unknown): boolean => e instanceof ComposioMultipleConnectedAccountsError;","tryCatchPattern":"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; }","preventionTips":["Query for an active connection before initiating","Pass allowMultiple only when the product truly supports multiple accounts"],"tags":["connected-accounts","auth","oauth","duplicate"],"backgroundTag":"duplicate-connected-account","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}