Triggers
Usage
Access this class through the composio.triggers property:
const composio = new Composio({ apiKey: 'your-api-key' });
const result = await composio.triggers.list();Methods
create()
Create a new trigger instance for a user If the connected account id is not provided, the first connected account for the user and toolkit will be used
async create(userId: string, slug: string, body?: { connectedAccountId?: string; triggerConfig?: Record<string, unknown> }): Promise<{ triggerId: string }>Parameters
| Name | Type | Description |
|---|---|---|
userId | string | The user id of the trigger instance |
slug | string | The slug of the trigger instance |
body? | object | The parameters to create the trigger instance |
Returns
Promise<...> — The created trigger instance
delete()
Delete a trigger instance
async delete(triggerId: string): Promise<{ triggerId: string }>Parameters
| Name | Type | Description |
|---|---|---|
triggerId | string | The slug of the trigger instance |
Returns
Promise<...>
disable()
Disable a trigger instance
async disable(triggerId: string): Promise<ManageUpdateResponse>Parameters
| Name | Type | Description |
|---|---|---|
triggerId | string | The id of the trigger instance |
Returns
Promise<ManageUpdateResponse> — The updated trigger instance
enable()
Enable a trigger instance
async enable(triggerId: string): Promise<ManageUpdateResponse>Parameters
| Name | Type | Description |
|---|---|---|
triggerId | string | The id of the trigger instance |
Returns
Promise<ManageUpdateResponse> — The updated trigger instance
getType()
Retrieve a trigger type by its slug for the provided version of the app Use the global toolkit versions param when initializing composio to pass a toolkitversion
async getType(slug: string): Promise<...>Parameters
| Name | Type | Description |
|---|---|---|
slug | string | The slug of the trigger type |
Returns
Promise<...> — The trigger type object
listActive()
Fetch list of all the active triggers
async listActive(query?: object): Promise<...>Parameters
| Name | Type | Description |
|---|---|---|
query? | object | The query parameters to filter the trigger instances |
Returns
Promise<...> — List of trigger instances
Example
const triggers = await triggers.listActive({
authConfigIds: ['123'],
connectedAccountIds: ['456'],
});listEnum()
Fetches the list of all the available trigger enums
This method is used by the CLI where filters are not required.
async listEnum(): Promise<TriggersTypeRetrieveEnumResponse>Returns
Promise<TriggersTypeRetrieveEnumResponse>
listTypes()
List all the trigger types
async listTypes(query?: { cursor?: string; limit?: number | null; toolkits?: string[] | null }): Promise<...>Parameters
| Name | Type | Description |
|---|---|---|
query? | object | The query parameters to filter the trigger types |
Returns
Promise<...> — The list of trigger types
subscribe()
Subscribe to all the triggers
async subscribe(fn: object, filters: object): Promise<void>Parameters
| Name | Type | Description |
|---|---|---|
fn | object | The function to call when a trigger is received |
filters | object | The filters to apply to the triggers |
Returns
Promise<void>
Example
triggers.subscribe((data) => {
console.log(data);
}, );unsubscribe()
Unsubscribe from all the triggers
async unsubscribe(): Promise<void>Returns
Promise<void>
Example
composio.trigger.subscribe((data) => {
console.log(data);
});
await triggers.unsubscribe();update()
Update an existing trigger instance
async update(triggerId: string, body: { status: 'enable' | 'disable' }): Promise<{ status: 'success' }>Parameters
| Name | Type | Description |
|---|---|---|
triggerId | string | The Id of the trigger instance |
body | object | The parameters to update the trigger instance |
Returns
Promise<...> — The updated trigger instance response
verifyWebhook()
Verify an incoming webhook payload and signature.
This method validates that the webhook request is authentic by:
- Verifying the HMAC-SHA256 signature matches the payload using the correct signing format
- Optionally checking that the webhook timestamp is within the tolerance window
The signature is computed as: HMAC-SHA256(${webhookId}.${webhookTimestamp}.${payload}, secret)
and is expected in the format: v1,base64EncodedSignature
async verifyWebhook(params: object): Promise<VerifyWebhookResult>Parameters
| Name | Type | Description |
|---|---|---|
params | object | The verification parameters |
Returns
Promise<VerifyWebhookResult> — The verified and parsed webhook payload with version information
Example
// In an Express.js webhook handler
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
try {
const result = await composio.triggers.verifyWebhook({
payload: req.body.toString(),
signature: req.headers['webhook-signature'] as string,
webhookId: req.headers['webhook-id'] as string,
webhookTimestamp: req.headers['webhook-timestamp'] as string,
secret: process.env.COMPOSIO_WEBHOOK_SECRET!,
});
// Process the verified payload
console.log('Webhook version:', result.version);
console.log('Received trigger:', result.payload.triggerSlug);
res.status(200).send('OK');
} catch (error) {
console.error('Webhook verification failed:', error);
res.status(401).send('Unauthorized');
}
});