SDK ReferenceTypeScript SDK

Triggers

Markdown

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

NameTypeDescription
userIdstringThe user id of the trigger instance
slugstringThe slug of the trigger instance
body?objectThe 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

NameTypeDescription
triggerIdstringThe slug of the trigger instance

Returns

Promise<...>


disable()

Disable a trigger instance

async disable(triggerId: string): Promise<ManageUpdateResponse>

Parameters

NameTypeDescription
triggerIdstringThe id of the trigger instance

Returns

Promise<ManageUpdateResponse> — The updated trigger instance


enable()

Enable a trigger instance

async enable(triggerId: string): Promise<ManageUpdateResponse>

Parameters

NameTypeDescription
triggerIdstringThe 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

NameTypeDescription
slugstringThe 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

NameTypeDescription
query?objectThe 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

NameTypeDescription
query?objectThe 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

NameTypeDescription
fnobjectThe function to call when a trigger is received
filtersobjectThe 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

NameTypeDescription
triggerIdstringThe Id of the trigger instance
bodyobjectThe 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:

  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

async verifyWebhook(params: object): Promise<VerifyWebhookResult>

Parameters

NameTypeDescription
paramsobjectThe 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');
  }
});