Triggers

@composio/core


@composio/core / models/Triggers / Triggers

Class: Triggers<TProvider>

Defined in: ts/packages/core/src/models/Triggers.ts:56

Trigger (Instance) class /api/v3/trigger_instances

Type Parameters

TProvider

TProvider extends BaseComposioProvider<unknown, unknown, unknown>

Constructors

Constructor

new Triggers<TProvider>(client, config?): Triggers<TProvider>

Defined in: ts/packages/core/src/models/Triggers.ts:61

Parameters

client

Composio

config?

ComposioConfig<TProvider>

Returns

Triggers<TProvider>

Methods

create()

create(userId, slug, body?): Promise<{ }>

Defined in: ts/packages/core/src/models/Triggers.ts:123

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

Parameters

userId

string

The user id of the trigger instance

slug

string

The slug of the trigger instance

body?

The parameters to create the trigger instance

Returns

Promise<{ }>

The created trigger instance


delete()

delete(triggerId): Promise<{ }>

Defined in: ts/packages/core/src/models/Triggers.ts:245

Delete a trigger instance

Parameters

triggerId

string

The slug of the trigger instance

Returns

Promise<{ }>


disable()

disable(triggerId): Promise<ManageUpdateResponse>

Defined in: ts/packages/core/src/models/Triggers.ts:258

Disable a trigger instance

Parameters

triggerId

string

The id of the trigger instance

Returns

Promise<ManageUpdateResponse>

The updated trigger instance


enable()

enable(triggerId): Promise<ManageUpdateResponse>

Defined in: ts/packages/core/src/models/Triggers.ts:270

Enable a trigger instance

Parameters

triggerId

string

The id of the trigger instance

Returns

Promise<ManageUpdateResponse>

The updated trigger instance


getType()

getType(slug): Promise<{ }>

Defined in: ts/packages/core/src/models/Triggers.ts:308

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

Parameters

slug

string

The slug of the trigger type

Returns

Promise<{ }>

The trigger type object


listActive()

listActive(query?): Promise<{ }>

Defined in: ts/packages/core/src/models/Triggers.ts:85

Fetch list of all the active triggers

Parameters

query?

The query parameters to filter the trigger instances

Returns

Promise<{ }>

List of trigger instances

Throws

If the parameters are invalid

Throws

If the client is not authenticated

Example

1const triggers = await triggers.listActive({
2 authConfigIds: ['123'],
3 connectedAccountIds: ['456'],
4});

listEnum()

listEnum(): Promise<TriggersTypeRetrieveEnumResponse>

Defined in: ts/packages/core/src/models/Triggers.ts:322

Fetches the list of all the available trigger enums

This method is used by the CLI where filters are not required.

Returns

Promise<TriggersTypeRetrieveEnumResponse>


listTypes()

listTypes(query?): Promise<{ }>

Defined in: ts/packages/core/src/models/Triggers.ts:286

List all the trigger types

Parameters

query?

The query parameters to filter the trigger types

Returns

Promise<{ }>

The list of trigger types


subscribe()

subscribe(fn, filters): Promise<void>

Defined in: ts/packages/core/src/models/Triggers.ts:418

Subscribe to all the triggers

Parameters

fn

(_data) => void

The function to call when a trigger is received

filters

The filters to apply to the triggers

Returns

Promise<void>

Example

1triggers.subscribe((data) => {
2 console.log(data);
3}, );

unsubscribe()

unsubscribe(): Promise<void>

Defined in: ts/packages/core/src/models/Triggers.ts:466

Unsubscribe from all the triggers

Returns

Promise<void>

Example

1composio.trigger.subscribe((data) => {
2 console.log(data);
3});
4
5await triggers.unsubscribe();

update()

update(triggerId, body): Promise<{ }>

Defined in: ts/packages/core/src/models/Triggers.ts:232

Update an existing trigger instance

Parameters

triggerId

string

The Id of the trigger instance

body

The parameters to update the trigger instance

Returns

Promise<{ }>

The updated trigger instance response


verifyWebhook()

verifyWebhook(params): VerifyWebhookResult

Defined in: ts/packages/core/src/models/Triggers.ts:517

Verify an incoming webhook payload and signature.

This method validates that the webhook request is authentic by:

  1. Verifying the HMAC-SHA256 signature matches the payload using the correct signing format
  2. 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

Parameters

params

The verification parameters

Returns

VerifyWebhookResult

The verified and parsed webhook payload with version information

Throws

If the parameters are invalid

Throws

If the signature verification fails

Throws

If the payload cannot be parsed or is invalid

Example

1// In an Express.js webhook handler
2app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
3 try {
4 const result = composio.triggers.verifyWebhook({
5 payload: req.body.toString(),
6 signature: req.headers['webhook-signature'] as string,
7 webhookId: req.headers['webhook-id'] as string,
8 webhookTimestamp: req.headers['webhook-timestamp'] as string,
9 secret: process.env.COMPOSIO_WEBHOOK_SECRET!,
10 });
11
12 // Process the verified payload
13 console.log('Webhook version:', result.version);
14 console.log('Received trigger:', result.payload.triggerSlug);
15 res.status(200).send('OK');
16 } catch (error) {
17 console.error('Webhook verification failed:', error);
18 res.status(401).send('Unauthorized');
19 }
20});