Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 20:45 UTC
Add composio link docs (#1913)
Musthaq Ahamad committed
Sep 10, 2025 at 15:35 UTC
ab42809b4f7c0ea6c9c911c40a085ac5215acd2b
1 file changed
+50
-1
ts/docs/api/connected-accounts.md
+50
-1
@@ -31,9 +31,49 @@ const githubAccounts = await composio.connectedAccounts.list({
31
32
**Throws:** ValidationError if the query fails validation against the expected schema
33
34
+
35
+### link(userId, authConfigId, options?)
36
+
37
+Creates a Composio Connect Link for a user to connect their account to a given auth config. This method returns an external link which you can use for the user to connect their account through Composio's hosted authentication flow.
38
+
39
+```typescript
40
+// Create a connection request and redirect the user to the redirect URL
41
+const connectionRequest = await composio.connectedAccounts.link('user_123', 'auth_config_123');
42
+const redirectUrl = connectionRequest.redirectUrl;
43
+console.log(`Visit: ${redirectUrl} to authenticate your account`);
44
+
45
+// Wait for the connection to be established
46
+const connectedAccount = await connectionRequest.waitForConnection();
47
+```
48
+
49
+```typescript
50
+// Create a connection request with callback URL
51
+const connectionRequest = await composio.connectedAccounts.link('user_123', 'auth_config_123', {
52
+ callbackUrl: 'https://your-app.com/callback'
53
+});
54
+const redirectUrl = connectionRequest.redirectUrl;
55
+console.log(`Visit: ${redirectUrl} to authenticate your account`);
56
+
57
+// Wait for the connection to be established
58
+const connectedAccount = await composio.connectedAccounts.waitForConnection(connectionRequest.id);
59
+```
60
+
61
+**Parameters:**
62
+
63
+- `userId` (string): The external user ID to create the connected account for
64
+- `authConfigId` (string): The auth config ID to create the connected account for
65
+- `options` (CreateConnectedAccountLinkOptions): Optional configuration for the link
66
+ - `callbackUrl` (string): The URL to redirect the user to after connecting their account
67
+
68
+**Returns:** Promise<ConnectionRequest> - Connection request object with redirect URL
69
+
70
+**Throws:**
71
+- `ValidationError`: If the options fail validation
72
+- `ComposioFailedToCreateConnectedAccountLink`: If the link creation fails
73
+
74
### initiate(userId, authConfigId, options?)
75
36
-Creates a new connected account and returns a connection request. Users can then wait for the connection to be established using the `waitForConnection` method.
76
+Creates a new connected account by accepting the parameters manually and returns a connection request. Users can then wait for the connection to be established using the `waitForConnection` method.
77
78
```typescript
79
// For OAuth based auth configs (no additional parameters needed)
@@ -84,6 +124,7 @@ const connectedAccount = await oauthConnection.waitForConnection();
124
125
**Returns:** Promise<ConnectionRequest> - Connection request object
126
127
+
128
### waitForConnection(connectedAccountId, timeout?)
129
130
Waits for a connection request to complete and become active.
@@ -275,6 +316,14 @@ interface CreateConnectedAccountOptions {
316
}
317
```
318
319
+### CreateConnectedAccountLinkOptions
320
+
321
+```typescript
322
+interface CreateConnectedAccountLinkOptions {
323
+ callbackUrl?: string; // URL to redirect the user to after connecting their account
324
+}
325
+```
326
+
327
### ConnectedAccountUpdateStatusParams
328
329
```typescript