@composio/core 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CustomTool-CB5vm1Jc.d.mts → CustomTool-B3m-188G.d.mts} +1 -1
- package/dist/{CustomTool-BMlZfJVz.mjs → CustomTool-fYEFjSLM.mjs} +1 -1
- package/dist/{FileModifierErrors-BqFmpRsm.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{SsrfErrors-C91YhASE.mjs → SsrfErrors-DiQldIdC.mjs} +18 -7
- package/dist/{Telemetry-HlftxMx6.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-CXpfmiVo.mjs → cancellation-Dwa9lGHA.mjs} +2 -2
- package/dist/{composio-DLGaeN70.d.mts → composio-B36OXii1.d.mts} +2691 -119
- package/dist/{customTool.types-BAmEh3MB.d.mts → customTool.types-C436M_D0.d.mts} +431 -98
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +5 -2
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +7 -0
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
- package/dist/docs/reference/sdk-reference/typescript/meta.json +8 -1
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +77 -27
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -10
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +149 -12
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -18
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +25 -25
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
- package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
- package/dist/{errors-BuEKehbI.mjs → errors-D_A4b2c2.mjs} +123 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-L7XD8UPr.mjs → fileUtils.node-DNLhLg0W.mjs} +4 -4
- package/dist/index.d.mts +264 -51
- package/dist/index.mjs +2338 -168
- package/dist/models/Files.node.mjs +2 -2
- package/dist/{sensitiveFileUploadPaths-B6pBt9lO.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +1 -1
- package/dist/{ssrfGuard.node-B9xQB4za.mjs → ssrfGuard.node-BZ270bcu.mjs} +1 -1
- package/dist/{types-CxLPO0Xq.d.mts → types-Br3GBya5.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +5 -5
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.mjs +1 -1
- package/package.json +2 -2
- package/src/composio.ts +207 -10
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/errors/SDKErrors.ts +52 -0
- package/src/errors/ToolRouterErrors.ts +57 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +11 -0
- package/src/lib/toolRouterMcp.ts +132 -0
- package/src/lib/toolRouterParams.ts +116 -29
- package/src/models/ConnectedAccounts.ts +118 -2
- package/src/models/CustomToolkits.ts +169 -0
- package/src/models/Experimental.ts +27 -0
- package/src/models/Keyring.ts +65 -0
- package/src/models/Logs.ts +101 -0
- package/src/models/ToolRouter.ts +42 -14
- package/src/models/ToolRouterSession.ts +120 -9
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +3 -1
- package/src/models/Triggers.ts +3 -88
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/services/pusher/Pusher.ts +17 -6
- package/src/types/authConfigs.types.ts +2 -0
- package/src/types/connectedAccounts.types.ts +54 -0
- package/src/types/customToolkits.types.ts +102 -0
- package/src/types/keyring.types.ts +32 -0
- package/src/types/logs.types.ts +108 -0
- package/src/types/toolRouter.types.ts +205 -11
- package/src/types/toolkit.types.ts +144 -0
- package/src/types/usage.types.ts +81 -0
- package/src/types/webhooks.types.ts +143 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/logger.ts +39 -7
- package/src/utils/sdk.ts +385 -22
- package/src/utils/transformers/connectedAccounts.ts +37 -2
- package/src/utils/transformers/customToolkits.ts +98 -0
- package/src/utils/transformers/keyring.ts +24 -0
- package/src/utils/transformers/logs.ts +85 -0
- package/src/utils/transformers/toolkits.ts +106 -3
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
|
@@ -20,7 +20,7 @@ Create a new trigger instance for a user
|
|
|
20
20
|
If the connected account id is not provided, the first connected account for the user and toolkit will be used
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
async create(userId: string, slug: string, body?:
|
|
23
|
+
async create(userId: string, slug: string, body?: { connectedAccountId?: string; triggerConfig?: Record<string, unknown> }, requestOptions?: ComposioRequestOptions): Promise<{ triggerId: string }>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
**Parameters**
|
|
@@ -29,12 +29,12 @@ async create(userId: string, slug: string, body?: TriggerInstanceUpsertParams, r
|
|
|
29
29
|
|------|------|-------------|
|
|
30
30
|
| `userId` | `string` | The user id of the trigger instance |
|
|
31
31
|
| `slug` | `string` | The slug of the trigger instance |
|
|
32
|
-
| `body?` | `
|
|
32
|
+
| `body?` | `\{ connectedAccountId?: string; triggerConfig?: Record<string, unknown> \}` | The parameters to create the trigger instance |
|
|
33
33
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
34
34
|
|
|
35
35
|
**Returns**
|
|
36
36
|
|
|
37
|
-
`Promise
|
|
37
|
+
`Promise<\{ triggerId: string \}>` — The created trigger instance
|
|
38
38
|
|
|
39
39
|
---
|
|
40
40
|
|
|
@@ -43,7 +43,7 @@ async create(userId: string, slug: string, body?: TriggerInstanceUpsertParams, r
|
|
|
43
43
|
Delete a trigger instance
|
|
44
44
|
|
|
45
45
|
```typescript
|
|
46
|
-
async delete(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<
|
|
46
|
+
async delete(triggerId: string, requestOptions?: ComposioRequestOptions): Promise<{ triggerId: string }>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
**Parameters**
|
|
@@ -55,7 +55,7 @@ async delete(triggerId: string, requestOptions?: ComposioRequestOptions): Promis
|
|
|
55
55
|
|
|
56
56
|
**Returns**
|
|
57
57
|
|
|
58
|
-
`Promise
|
|
58
|
+
`Promise<\{ triggerId: string \}>`
|
|
59
59
|
|
|
60
60
|
---
|
|
61
61
|
|
|
@@ -107,7 +107,7 @@ Retrieve a trigger type by its slug for the provided version of the app
|
|
|
107
107
|
Use the global toolkit versions param when initializing composio to pass a toolkitversion
|
|
108
108
|
|
|
109
109
|
```typescript
|
|
110
|
-
async getType(slug: string, requestOptions?: ComposioRequestOptions): Promise<
|
|
110
|
+
async getType(slug: string, requestOptions?: ComposioRequestOptions): Promise<{ config: Record<string, unknown>; description: string; instructions?: string; name: string; payload: Record<string, unknown>; slug: string; toolkit: { logo: string; name: string; slug: string }; version?: string }>
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
**Parameters**
|
|
@@ -119,7 +119,7 @@ async getType(slug: string, requestOptions?: ComposioRequestOptions): Promise<Tr
|
|
|
119
119
|
|
|
120
120
|
**Returns**
|
|
121
121
|
|
|
122
|
-
`Promise<
|
|
122
|
+
`Promise<\{ config: Record<string, unknown>; description: string; instructions?: string; name: string; payload: Record<string, unknown>; slug: string; toolkit: \{ logo: string; name: string; slug: string \}; version?: string \}>` — The trigger type object
|
|
123
123
|
|
|
124
124
|
---
|
|
125
125
|
|
|
@@ -128,19 +128,19 @@ async getType(slug: string, requestOptions?: ComposioRequestOptions): Promise<Tr
|
|
|
128
128
|
Fetch list of all the active triggers
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
|
-
async listActive(query?:
|
|
131
|
+
async listActive(query?: { authConfigIds?: string[] | null; connectedAccountIds?: string[] | null; cursor?: string; limit?: number; showDisabled?: boolean | null; triggerIds?: string[] | null; triggerNames?: string[] | null }, requestOptions?: ComposioRequestOptions): Promise<{ items: { connectedAccountId: string; disabledAt: string | null; id: string; state: Record<string, unknown>; triggerConfig: Record<string, unknown>; triggerData?: string; triggerName: string; updatedAt: string; uuid?: string }[]; nextCursor: string | null; totalPages: number }>
|
|
132
132
|
```
|
|
133
133
|
|
|
134
134
|
**Parameters**
|
|
135
135
|
|
|
136
136
|
| Name | Type | Description |
|
|
137
137
|
|------|------|-------------|
|
|
138
|
-
| `query?` | `
|
|
138
|
+
| `query?` | `\{ authConfigIds?: string[] \| null; connectedAccountIds?: string[] \| null; cursor?: string; limit?: number; showDisabled?: boolean \| null; triggerIds?: string[] \| null; triggerNames?: string[] \| null \}` | The query parameters to filter the trigger instances |
|
|
139
139
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
140
140
|
|
|
141
141
|
**Returns**
|
|
142
142
|
|
|
143
|
-
`Promise<
|
|
143
|
+
`Promise<\{ items: \{ connectedAccountId: string; disabledAt: string \| null; id: string; state: Record<string, unknown>; triggerConfig: Record<string, unknown>; triggerData?: string; triggerName: string; updatedAt: string; uuid?: string \}[]; nextCursor: string \| null; totalPages: number \}>` — List of trigger instances
|
|
144
144
|
|
|
145
145
|
**Example**
|
|
146
146
|
|
|
@@ -160,7 +160,7 @@ Fetches the list of all the available trigger enums
|
|
|
160
160
|
This method is used by the CLI where filters are not required.
|
|
161
161
|
|
|
162
162
|
```typescript
|
|
163
|
-
async listEnum(requestOptions?: ComposioRequestOptions): Promise<
|
|
163
|
+
async listEnum(requestOptions?: ComposioRequestOptions): Promise<string[]>
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
**Parameters**
|
|
@@ -171,7 +171,7 @@ async listEnum(requestOptions?: ComposioRequestOptions): Promise<TriggersTypeRet
|
|
|
171
171
|
|
|
172
172
|
**Returns**
|
|
173
173
|
|
|
174
|
-
`Promise<
|
|
174
|
+
`Promise<string[]>`
|
|
175
175
|
|
|
176
176
|
---
|
|
177
177
|
|
|
@@ -180,19 +180,19 @@ async listEnum(requestOptions?: ComposioRequestOptions): Promise<TriggersTypeRet
|
|
|
180
180
|
List all the trigger types
|
|
181
181
|
|
|
182
182
|
```typescript
|
|
183
|
-
async listTypes(query?:
|
|
183
|
+
async listTypes(query?: { cursor?: string; limit?: number | null; toolkits?: string[] | null }, requestOptions?: ComposioRequestOptions): Promise<{ items: { config: Record<string, unknown>; description: string; instructions?: string; name: string; payload: Record<string, unknown>; slug: string; toolkit: { logo: string; name: string; slug: string }; version?: string }[]; nextCursor?: string | null; totalPages: number }>
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
**Parameters**
|
|
187
187
|
|
|
188
188
|
| Name | Type | Description |
|
|
189
189
|
|------|------|-------------|
|
|
190
|
-
| `query?` | `
|
|
190
|
+
| `query?` | `\{ cursor?: string; limit?: number \| null; toolkits?: string[] \| null \}` | The query parameters to filter the trigger types |
|
|
191
191
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
192
192
|
|
|
193
193
|
**Returns**
|
|
194
194
|
|
|
195
|
-
`Promise<
|
|
195
|
+
`Promise<\{ items: \{ config: Record<string, unknown>; description: string; instructions?: string; name: string; payload: Record<string, unknown>; slug: string; toolkit: \{ logo: string; name: string; slug: string \}; version?: string \}[]; nextCursor?: string \| null; totalPages: number \}>` — The list of trigger types
|
|
196
196
|
|
|
197
197
|
---
|
|
198
198
|
|
|
@@ -283,14 +283,14 @@ If a subscription already exists, the first subscription is updated. Otherwise a
|
|
|
283
283
|
subscription is created. By default this subscribes to V3 trigger message events.
|
|
284
284
|
|
|
285
285
|
```typescript
|
|
286
|
-
async setWebhookSubscription(params:
|
|
286
|
+
async setWebhookSubscription(params: { enabledEvents?: string[]; version?: 'V1' | 'V2' | 'V3'; webhookUrl: string }): Promise<WebhookSubscription>
|
|
287
287
|
```
|
|
288
288
|
|
|
289
289
|
**Parameters**
|
|
290
290
|
|
|
291
291
|
| Name | Type |
|
|
292
292
|
|------|------|
|
|
293
|
-
| `params` | `
|
|
293
|
+
| `params` | `\{ enabledEvents?: string[]; version?: 'V1' \| 'V2' \| 'V3'; webhookUrl: string \}` |
|
|
294
294
|
|
|
295
295
|
**Returns**
|
|
296
296
|
|
|
@@ -311,15 +311,15 @@ await composio.triggers.setWebhookSubscription({
|
|
|
311
311
|
Subscribe to all the triggers
|
|
312
312
|
|
|
313
313
|
```typescript
|
|
314
|
-
async subscribe(fn: (_data:
|
|
314
|
+
async subscribe(fn: (_data: { id: string; metadata: { connectedAccount: { authConfigId: string; authConfigUUID: string; id: string; status: 'ACTIVE' | 'INACTIVE'; userId: string; uuid: string }; id: string; toolkitSlug: string; triggerConfig: Record<string, unknown>; triggerData?: string; triggerSlug: string; uuid: string }; originalPayload?: Record<string, unknown>; payload?: Record<string, unknown>; toolkitSlug: string; triggerSlug: string; userId: string; uuid: string }) => void, filters?: { authConfigId?: string; connectedAccountId?: string; toolkits?: string[]; triggerData?: string; triggerId?: string; triggerSlug?: string[]; userId?: string }, onSubscriptionError?: (data: Record<string, unknown>) => void): Promise<void>
|
|
315
315
|
```
|
|
316
316
|
|
|
317
317
|
**Parameters**
|
|
318
318
|
|
|
319
319
|
| Name | Type | Description |
|
|
320
320
|
|------|------|-------------|
|
|
321
|
-
| `fn` | `(_data:
|
|
322
|
-
| `filters?` | `
|
|
321
|
+
| `fn` | `(_data: \{ id: string; metadata: \{ connectedAccount: \{ authConfigId: string; authConfigUUID: string; id: string; status: 'ACTIVE' \| 'INACTIVE'; userId: string; uuid: string \}; id: string; toolkitSlug: string; triggerConfig: Record<string, unknown>; triggerData?: string; triggerSlug: string; uuid: string \}; originalPayload?: Record<string, unknown>; payload?: Record<string, unknown>; toolkitSlug: string; triggerSlug: string; userId: string; uuid: string \}) => void` | The function to call when a trigger is received |
|
|
322
|
+
| `filters?` | `\{ authConfigId?: string; connectedAccountId?: string; toolkits?: string[]; triggerData?: string; triggerId?: string; triggerSlug?: string[]; userId?: string \}` | The filters to apply to the triggers |
|
|
323
323
|
| `onSubscriptionError?` | `(data: Record<string, unknown>) => void` | Optional callback invoked with the raw Pusher payload when the underlying subscription fails (for example on auth or permission rejection). The subscribe promise still resolves; this is the only programmatic signal of the failure. Errors thrown from — or promises rejected by — the callback are contained and logged. |
|
|
324
324
|
|
|
325
325
|
**Returns**
|
|
@@ -365,7 +365,7 @@ await triggers.unsubscribe();
|
|
|
365
365
|
Update an existing trigger instance
|
|
366
366
|
|
|
367
367
|
```typescript
|
|
368
|
-
async update(triggerId: string, body:
|
|
368
|
+
async update(triggerId: string, body: { status: 'enable' | 'disable' }, requestOptions?: ComposioRequestOptions): Promise<{ status: 'success' }>
|
|
369
369
|
```
|
|
370
370
|
|
|
371
371
|
**Parameters**
|
|
@@ -373,12 +373,12 @@ async update(triggerId: string, body: TriggerInstanceManageUpdateParams, request
|
|
|
373
373
|
| Name | Type | Description |
|
|
374
374
|
|------|------|-------------|
|
|
375
375
|
| `triggerId` | `string` | The Id of the trigger instance |
|
|
376
|
-
| `body` | `
|
|
376
|
+
| `body` | `\{ status: 'enable' \| 'disable' \}` | The parameters to update the trigger instance |
|
|
377
377
|
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
378
378
|
|
|
379
379
|
**Returns**
|
|
380
380
|
|
|
381
|
-
`Promise
|
|
381
|
+
`Promise<\{ status: 'success' \}>` — The updated trigger instance response
|
|
382
382
|
|
|
383
383
|
---
|
|
384
384
|
|
|
@@ -394,14 +394,14 @@ The signature is computed as: `HMAC-SHA256(${webhookId}.${webhookTimestamp}.${pa
|
|
|
394
394
|
and is expected in the format: `v1,base64EncodedSignature`
|
|
395
395
|
|
|
396
396
|
```typescript
|
|
397
|
-
async verifyWebhook(params:
|
|
397
|
+
async verifyWebhook(params: { id: string; payload: string; secret: string; signature: string; timestamp: string; tolerance?: number }): Promise<VerifyWebhookResult>
|
|
398
398
|
```
|
|
399
399
|
|
|
400
400
|
**Parameters**
|
|
401
401
|
|
|
402
402
|
| Name | Type | Description |
|
|
403
403
|
|------|------|-------------|
|
|
404
|
-
| `params` | `
|
|
404
|
+
| `params` | `\{ id: string; payload: string; secret: string; signature: string; timestamp: string; tolerance?: number \}` | The verification parameters |
|
|
405
405
|
|
|
406
406
|
**Returns**
|
|
407
407
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Usage"
|
|
3
|
+
description: "`composio.experimental.usage` — metering for the project the API key belongs to. **Experimental — shape may change in future releases.**"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.usage` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
+
const result = await composio.usage.list();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### breakdown()
|
|
18
|
+
|
|
19
|
+
Usage for one metering entity type, grouped by a dimension.
|
|
20
|
+
**Experimental — shape may change in future releases.**
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
async breakdown(entityType: string, params?: { filters?: { sessionId?: string[] | null; userId?: string[] | null }; from?: number; groupBy?: string; limit?: number; orderBy?: 'key' | 'total_quantity' | 'event_count'; orderDirection?: 'asc' | 'desc'; to?: number }, requestOptions?: ComposioRequestOptions): Promise<{ entityType: string; eventCount: number; groups: { eventCount: number; key: string; totalQuantity: string }[]; totalQuantity: string; unit: string }>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Parameters**
|
|
27
|
+
|
|
28
|
+
| Name | Type | Description |
|
|
29
|
+
|------|------|-------------|
|
|
30
|
+
| `entityType` | `string` | Entity type to break down (e.g. `tool_calls`, `sessions`) |
|
|
31
|
+
| `params?` | `\{ filters?: \{ sessionId?: string[] \| null; userId?: string[] \| null \}; from?: number; groupBy?: string; limit?: number; orderBy?: 'key' \| 'total_quantity' \| 'event_count'; orderDirection?: 'asc' \| 'desc'; to?: number \}` | Optional range, `groupBy`, ordering, `limit` and filters |
|
|
32
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
33
|
+
|
|
34
|
+
**Returns**
|
|
35
|
+
|
|
36
|
+
`Promise<\{ entityType: string; eventCount: number; groups: \{ eventCount: number; key: string; totalQuantity: string \}[]; totalQuantity: string; unit: string \}>` — Totals plus per-group rows
|
|
37
|
+
|
|
38
|
+
**Example**
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const byUser = await composio.experimental.usage.breakdown('sessions', {
|
|
42
|
+
groupBy: 'user_id',
|
|
43
|
+
orderBy: 'event_count',
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### summary()
|
|
50
|
+
|
|
51
|
+
Usage totals per metering entity type for a time range.
|
|
52
|
+
**Experimental — shape may change in future releases.**
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
async summary(params?: { entityTypes?: string[]; filters?: { sessionId?: string[] | null; userId?: string[] | null }; from?: number; to?: number }, requestOptions?: ComposioRequestOptions): Promise<{ entities: Record<string, { eventCount: number; totalQuantity: string; unit: string }> }>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Parameters**
|
|
59
|
+
|
|
60
|
+
| Name | Type | Description |
|
|
61
|
+
|------|------|-------------|
|
|
62
|
+
| `params?` | `\{ entityTypes?: string[]; filters?: \{ sessionId?: string[] \| null; userId?: string[] \| null \}; from?: number; to?: number \}` | Optional range, `entityTypes` and filters |
|
|
63
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
64
|
+
|
|
65
|
+
**Returns**
|
|
66
|
+
|
|
67
|
+
`Promise<...>` — Totals keyed by entity type
|
|
68
|
+
|
|
69
|
+
**Example**
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const summary = await composio.experimental.usage.summary({
|
|
73
|
+
from: Date.now() - 7 * 24 * 60 * 60 * 1000,
|
|
74
|
+
filters: { userId: ['user_123'] },
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "WebhookEndpoints"
|
|
3
|
+
description: "`composio.webhooks.endpoints` — inbound webhook endpoints. Each endpoint is the ingress URL Composio exposes for one toolkit + OAuth app pair, which you register with the third-party provider so it can push events to Composio."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.webhookEndpoints` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
+
const result = await composio.webhookEndpoints.list();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### create()
|
|
18
|
+
|
|
19
|
+
Create a webhook endpoint for a toolkit + OAuth app pair. Returns the
|
|
20
|
+
existing endpoint when one already exists for that pair.
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
async create(params: { clientId: string; toolkitSlug: string }, requestOptions?: ComposioRequestOptions): Promise<...>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Parameters**
|
|
27
|
+
|
|
28
|
+
| Name | Type | Description |
|
|
29
|
+
|------|------|-------------|
|
|
30
|
+
| `params` | `\{ clientId: string; toolkitSlug: string \}` | `toolkitSlug` and `clientId` |
|
|
31
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
32
|
+
|
|
33
|
+
**Returns**
|
|
34
|
+
|
|
35
|
+
`Promise<...>` — The endpoint; register `webhookUrl` with the provider
|
|
36
|
+
|
|
37
|
+
**Example**
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const endpoint = await composio.webhooks.endpoints.create({
|
|
41
|
+
toolkitSlug: 'slack',
|
|
42
|
+
clientId: 'my-slack-app-client-id',
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
### get()
|
|
49
|
+
|
|
50
|
+
Retrieve a webhook endpoint by its nano id.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
async get(nanoId: string, requestOptions?: ComposioRequestOptions): Promise<...>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Parameters**
|
|
57
|
+
|
|
58
|
+
| Name | Type | Description |
|
|
59
|
+
|------|------|-------------|
|
|
60
|
+
| `nanoId` | `string` | The endpoint nano id (e.g. `we_abc123`) |
|
|
61
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
62
|
+
|
|
63
|
+
**Returns**
|
|
64
|
+
|
|
65
|
+
`Promise<...>` — The endpoint, with secret setup values masked
|
|
66
|
+
|
|
67
|
+
**Example**
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const endpoint = await composio.webhooks.endpoints.get('we_abc123');
|
|
71
|
+
console.log(endpoint.webhookUrl);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### list()
|
|
77
|
+
|
|
78
|
+
List webhook endpoints, optionally filtered by toolkit.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
async list(query?: { toolkitSlug?: string }, requestOptions?: ComposioRequestOptions): Promise<{ items: { clientId: string | null; id: string; toolkitSlug: string }[] }>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Parameters**
|
|
85
|
+
|
|
86
|
+
| Name | Type | Description |
|
|
87
|
+
|------|------|-------------|
|
|
88
|
+
| `query?` | `\{ toolkitSlug?: string \}` | Optional `toolkitSlug` filter |
|
|
89
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
90
|
+
|
|
91
|
+
**Returns**
|
|
92
|
+
|
|
93
|
+
`Promise<\{ items: \{ clientId: string \| null; id: string; toolkitSlug: string \}[] \}>` — The endpoints
|
|
94
|
+
|
|
95
|
+
**Example**
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const { items } = await composio.webhooks.endpoints.list({ toolkitSlug: 'slack' });
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### replace()
|
|
104
|
+
|
|
105
|
+
Replace the setup fields of a webhook endpoint. All required setup fields
|
|
106
|
+
for the toolkit must be provided — this is the initial configuration.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
async replace(nanoId: string, params: { data: Record<string, string> }, requestOptions?: ComposioRequestOptions): Promise<...>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Parameters**
|
|
113
|
+
|
|
114
|
+
| Name | Type | Description |
|
|
115
|
+
|------|------|-------------|
|
|
116
|
+
| `nanoId` | `string` | The endpoint nano id |
|
|
117
|
+
| `params` | `\{ data: Record<string, string> \}` | `data` with every required setup field |
|
|
118
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
119
|
+
|
|
120
|
+
**Returns**
|
|
121
|
+
|
|
122
|
+
`Promise<...>` — The configured endpoint
|
|
123
|
+
|
|
124
|
+
**Example**
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
await composio.webhooks.endpoints.replace('we_abc123', {
|
|
128
|
+
data: { signing_secret: process.env.SLACK_SIGNING_SECRET! },
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### update()
|
|
135
|
+
|
|
136
|
+
Merge setup fields into a webhook endpoint. Omitted fields are preserved.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
async update(nanoId: string, params: { data: Record<string, string> }, requestOptions?: ComposioRequestOptions): Promise<...>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Parameters**
|
|
143
|
+
|
|
144
|
+
| Name | Type | Description |
|
|
145
|
+
|------|------|-------------|
|
|
146
|
+
| `nanoId` | `string` | The endpoint nano id |
|
|
147
|
+
| `params` | `\{ data: Record<string, string> \}` | `data` with the fields to change |
|
|
148
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
149
|
+
|
|
150
|
+
**Returns**
|
|
151
|
+
|
|
152
|
+
`Promise<...>` — The updated endpoint
|
|
153
|
+
|
|
154
|
+
**Example**
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
await composio.webhooks.endpoints.update('we_abc123', {
|
|
158
|
+
data: { signing_secret: 'rotated-secret' },
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "WebhookSubscriptions"
|
|
3
|
+
description: "`composio.webhooks.subscriptions` — the project's outbound webhook subscription. The API allows one subscription per project; every response includes the signing `secret` used to verify deliveries with `composio.triggers.verifyWebhook()` / `composio.triggers.parse()`."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.webhookSubscriptions` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
+
const result = await composio.webhookSubscriptions.list();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### delete()
|
|
18
|
+
|
|
19
|
+
Delete a webhook subscription. Deliveries stop immediately.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
async delete(id: string, requestOptions?: ComposioRequestOptions): Promise<{ success: boolean }>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Parameters**
|
|
26
|
+
|
|
27
|
+
| Name | Type | Description |
|
|
28
|
+
|------|------|-------------|
|
|
29
|
+
| `id` | `string` | The subscription id |
|
|
30
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
31
|
+
|
|
32
|
+
**Returns**
|
|
33
|
+
|
|
34
|
+
`Promise<\{ success: boolean \}>` — `\{ success \}`
|
|
35
|
+
|
|
36
|
+
**Example**
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
await composio.webhooks.subscriptions.delete('whs_abc123');
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### get()
|
|
45
|
+
|
|
46
|
+
Retrieve a webhook subscription by id.
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
async get(id: string, requestOptions?: ComposioRequestOptions): Promise<WebhookSubscription>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Parameters**
|
|
53
|
+
|
|
54
|
+
| Name | Type | Description |
|
|
55
|
+
|------|------|-------------|
|
|
56
|
+
| `id` | `string` | The subscription id |
|
|
57
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
58
|
+
|
|
59
|
+
**Returns**
|
|
60
|
+
|
|
61
|
+
`Promise<WebhookSubscription>` — The subscription, including its signing secret
|
|
62
|
+
|
|
63
|
+
**Example**
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const subscription = await composio.webhooks.subscriptions.get('whs_abc123');
|
|
67
|
+
console.log(subscription.enabledEvents);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### list()
|
|
73
|
+
|
|
74
|
+
List the project's webhook subscriptions.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
async list(query?: { cursor?: string; limit?: number }, requestOptions?: ComposioRequestOptions): Promise<{ currentPage: number; items: { createdAt?: string; enabledEvents: string[]; id: string; secret?: string; updatedAt?: string; version: 'V1' | 'V2' | 'V3'; webhookUrl: string }[]; nextCursor: string | null; totalItems: number; totalPages: number }>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Parameters**
|
|
81
|
+
|
|
82
|
+
| Name | Type | Description |
|
|
83
|
+
|------|------|-------------|
|
|
84
|
+
| `query?` | `\{ cursor?: string; limit?: number \}` | Pagination options |
|
|
85
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
86
|
+
|
|
87
|
+
**Returns**
|
|
88
|
+
|
|
89
|
+
`Promise<\{ currentPage: number; items: \{ createdAt?: string; enabledEvents: string[]; id: string; secret?: string; updatedAt?: string; version: 'V1' \| 'V2' \| 'V3'; webhookUrl: string \}[]; nextCursor: string \| null; totalItems: number; totalPages: number \}>` — Paginated subscriptions
|
|
90
|
+
|
|
91
|
+
**Example**
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const { items } = await composio.webhooks.subscriptions.list();
|
|
95
|
+
console.log(items[0]?.webhookUrl);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### listEventTypes()
|
|
101
|
+
|
|
102
|
+
List the event types a subscription can enable, with the payload
|
|
103
|
+
versions each one supports.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
async listEventTypes(requestOptions?: ComposioRequestOptions): Promise<{ items: { description: string; eventType: string; supportedVersions: ... | ... | ...[] }[] }>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Parameters**
|
|
110
|
+
|
|
111
|
+
| Name | Type |
|
|
112
|
+
|------|------|
|
|
113
|
+
| `requestOptions?` | `ComposioRequestOptions` |
|
|
114
|
+
|
|
115
|
+
**Returns**
|
|
116
|
+
|
|
117
|
+
`Promise<\{ items: \{ description: string; eventType: string; supportedVersions: ... \| ... \| ...[] \}[] \}>` — The available event types
|
|
118
|
+
|
|
119
|
+
**Example**
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
const { items } = await composio.webhooks.subscriptions.listEventTypes();
|
|
123
|
+
console.log(items.map(item => item.eventType));
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### rotateSecret()
|
|
129
|
+
|
|
130
|
+
Rotate the signing secret of a webhook subscription. The previous secret
|
|
131
|
+
stops validating, so update your verifier with the returned `secret`.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
async rotateSecret(id: string, requestOptions?: ComposioRequestOptions): Promise<{ id: string; secret: string }>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Parameters**
|
|
138
|
+
|
|
139
|
+
| Name | Type | Description |
|
|
140
|
+
|------|------|-------------|
|
|
141
|
+
| `id` | `string` | The subscription id |
|
|
142
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
143
|
+
|
|
144
|
+
**Returns**
|
|
145
|
+
|
|
146
|
+
`Promise<\{ id: string; secret: string \}>` — `\{ id, secret \}`
|
|
147
|
+
|
|
148
|
+
**Example**
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const { secret } = await composio.webhooks.subscriptions.rotateSecret('whs_abc123');
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### set()
|
|
157
|
+
|
|
158
|
+
Create or update the project webhook subscription.
|
|
159
|
+
|
|
160
|
+
If a subscription already exists it is updated in place, otherwise a new
|
|
161
|
+
one is created. By default this subscribes to V3 trigger message events.
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
async set(params: { enabledEvents?: string[]; version?: 'V1' | 'V2' | 'V3'; webhookUrl: string }, requestOptions?: ComposioRequestOptions): Promise<WebhookSubscription>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Parameters**
|
|
168
|
+
|
|
169
|
+
| Name | Type | Description |
|
|
170
|
+
|------|------|-------------|
|
|
171
|
+
| `params` | `\{ enabledEvents?: string[]; version?: 'V1' \| 'V2' \| 'V3'; webhookUrl: string \}` | `webhookUrl`, optional `enabledEvents` and `version` |
|
|
172
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
173
|
+
|
|
174
|
+
**Returns**
|
|
175
|
+
|
|
176
|
+
`Promise<WebhookSubscription>` — The resulting subscription
|
|
177
|
+
|
|
178
|
+
**Example**
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
const subscription = await composio.webhooks.subscriptions.set({
|
|
182
|
+
webhookUrl: `${APP_URL}/webhooks/composio`,
|
|
183
|
+
enabledEvents: ['composio.trigger.message', 'composio.connected_account.expired'],
|
|
184
|
+
});
|
|
185
|
+
process.env.COMPOSIO_WEBHOOK_SECRET = subscription.secret;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
### update()
|
|
191
|
+
|
|
192
|
+
Update an existing webhook subscription. Only the provided fields change.
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
async update(id: string, params: { enabledEvents?: string[]; version?: 'V1' | 'V2' | 'V3'; webhookUrl?: string }, requestOptions?: ComposioRequestOptions): Promise<WebhookSubscription>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Parameters**
|
|
199
|
+
|
|
200
|
+
| Name | Type | Description |
|
|
201
|
+
|------|------|-------------|
|
|
202
|
+
| `id` | `string` | The subscription id |
|
|
203
|
+
| `params` | `\{ enabledEvents?: string[]; version?: 'V1' \| 'V2' \| 'V3'; webhookUrl?: string \}` | Fields to update |
|
|
204
|
+
| `requestOptions?` | `ComposioRequestOptions` | |
|
|
205
|
+
|
|
206
|
+
**Returns**
|
|
207
|
+
|
|
208
|
+
`Promise<WebhookSubscription>` — The updated subscription
|
|
209
|
+
|
|
210
|
+
**Example**
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
await composio.webhooks.subscriptions.update('whs_abc123', {
|
|
214
|
+
enabledEvents: ['composio.trigger.message'],
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Webhooks"
|
|
3
|
+
description: "`composio.webhooks` namespace. - `subscriptions`: the project's outbound webhook subscription (where Composio delivers trigger and lifecycle events). - `endpoints`: inbound ingress URLs for third-party providers, one per toolkit + OAuth app pair."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
Access this class through the `composio.webhooks` property:
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
const composio = new Composio({ apiKey: 'your-api-key' });
|
|
12
|
+
const result = await composio.webhooks.list();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
| Name | Type | Description |
|
|
18
|
+
|------|------|-------------|
|
|
19
|
+
| `endpoints` | `WebhookEndpoints` | Manage inbound webhook endpoints per toolkit + OAuth app. |
|
|
20
|
+
| `subscriptions` | `WebhookSubscriptions` | Manage the project's outbound webhook subscription. |
|