Skip to main content
The triggers API manages webhook triggers that notify your application when events occur in connected services. Triggers enable real-time integrations without polling.

Methods

listActive()

List all active trigger instances.
async listActive(
  query?: TriggerInstanceListActiveParams
): Promise<TriggerInstanceListActiveResponse>
query
TriggerInstanceListActiveParams
Example:
const triggers = await composio.triggers.listActive({
  connectedAccountIds: ['conn_abc123'],
  limit: 20
});

triggers.items.forEach(trigger => {
  console.log(trigger.triggerId, trigger.triggerSlug);
});

create()

Create a new trigger instance for a user.
async create(
  userId: string,
  slug: string,
  body?: TriggerInstanceUpsertParams
): Promise<TriggerInstanceUpsertResponse>
userId
string
required
User ID to create trigger for
slug
string
required
Trigger slug (e.g., GITHUB_PULL_REQUEST_EVENT)
body
TriggerInstanceUpsertParams
const trigger = await composio.triggers.create(
  'user_123',
  'GITHUB_PULL_REQUEST_EVENT'
);

console.log('Trigger created:', trigger.triggerId);

update()

Update an existing trigger instance.
async update(
  triggerId: string,
  body: TriggerInstanceManageUpdateParams
): Promise<TriggerInstanceManageUpdateResponse>
Example:
await composio.triggers.update('trigger_abc123', {
  status: 'enable'
});

delete()

Delete a trigger instance.
async delete(triggerId: string): Promise<TriggerInstanceManageDeleteResponse>
Example:
await composio.triggers.delete('trigger_abc123');
console.log('Trigger deleted');

enable() / disable()

Enable or disable a trigger instance.
async enable(triggerId: string): Promise<TriggerInstanceUpsertResponse>
async disable(triggerId: string): Promise<TriggerInstanceUpsertResponse>
Example:
// Temporarily disable a trigger
await composio.triggers.disable('trigger_abc123');

// Re-enable it later
await composio.triggers.enable('trigger_abc123');

listTypes()

List all available trigger types.
async listTypes(query?: TriggersTypeListParams): Promise<TriggersTypeListResponse>
query
TriggersTypeListParams
Example:
const triggerTypes = await composio.triggers.listTypes({
  toolkits: ['github', 'slack']
});

triggerTypes.items.forEach(type => {
  console.log(type.slug, type.description);
});

getType()

Retrieve a specific trigger type.
async getType(slug: string): Promise<TriggersTypeRetrieveResponse>
Example:
const triggerType = await composio.triggers.getType('GITHUB_PULL_REQUEST_EVENT');

console.log(triggerType.name); // "Pull Request Event"
console.log(triggerType.description); // "Triggered when..."
console.log(triggerType.inputSchema); // Configuration schema

subscribe()

Subscribe to trigger events via Pusher.
async subscribe(
  fn: (data: IncomingTriggerPayload) => void,
  filters?: TriggerSubscribeParams
): Promise<void>
fn
function
required
Callback function to handle trigger events
filters
TriggerSubscribeParams
await composio.triggers.subscribe((data) => {
  console.log('Trigger received:', data.triggerSlug);
  console.log('Payload:', data.payload);
});

unsubscribe()

Unsubscribe from trigger events.
async unsubscribe(): Promise<void>
Example:
// Subscribe to triggers
await composio.triggers.subscribe((data) => {
  console.log('Trigger:', data);
});

// Later, unsubscribe
await composio.triggers.unsubscribe();

verifyWebhook()

Verify an incoming webhook payload and signature.
async verifyWebhook(params: VerifyWebhookParams): Promise<VerifyWebhookResult>
params
VerifyWebhookParams
required
import express from 'express';

const app = express();

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,
        id: req.headers['webhook-id'] as string,
        timestamp: req.headers['webhook-timestamp'] as string,
        secret: process.env.COMPOSIO_WEBHOOK_SECRET!
      });

      console.log('Webhook version:', result.version);
      console.log('Trigger:', result.payload.triggerSlug);
      console.log('Data:', result.payload.payload);

      res.status(200).send('OK');
    } catch (error) {
      console.error('Webhook verification failed:', error);
      res.status(401).send('Unauthorized');
    }
  }
);

Types

IncomingTriggerPayload

interface IncomingTriggerPayload {
  id: string; // Trigger instance ID
  uuid: string; // Unique event ID
  triggerSlug: string; // Trigger type (e.g., GITHUB_PULL_REQUEST_EVENT)
  toolkitSlug: string; // Toolkit that fired the trigger
  userId: string; // User ID
  payload: Record<string, unknown>; // Event data
  originalPayload: Record<string, unknown>; // Raw event from service
  metadata: {
    id: string;
    uuid: string;
    triggerSlug: string;
    toolkitSlug: string;
    triggerConfig: Record<string, unknown>;
    connectedAccount: {
      id: string;
      uuid: string;
      authConfigId: string;
      userId: string;
      status: string;
    };
  };
}

VerifyWebhookResult

interface VerifyWebhookResult {
  version: 'V1' | 'V2' | 'V3'; // Webhook format version
  payload: IncomingTriggerPayload; // Parsed trigger data
  rawPayload: WebhookPayload; // Original webhook payload
}

Common Triggers

GitHub

  • GITHUB_PULL_REQUEST_EVENT - PR opened, closed, or updated
  • GITHUB_COMMIT_EVENT - New commits pushed
  • GITHUB_ISSUE_EVENT - Issues created or updated
  • GITHUB_STAR_ADDED - Repository starred

Slack

  • SLACK_RECEIVE_MESSAGE - Message posted to channel
  • SLACK_RECEIVE_REACTION - Reaction added to message
  • SLACK_CHANNEL_CREATED - New channel created

Gmail

  • GMAIL_NEW_EMAIL_RECEIVED - New email received
  • GMAIL_NEW_LABELED_EMAIL - Email labeled

Best Practices

  1. Webhook Verification: Always verify webhooks in production
  2. Error Handling: Handle trigger failures gracefully
  3. Idempotency: Use uuid to prevent duplicate processing
  4. Filtering: Use filters to reduce unnecessary events
  5. Unsubscribe: Clean up subscriptions when done

Next Steps

Connected Accounts

Set up user authentication

Tools API

Execute tools from triggers

Toolkits

Browse available toolkits

Auth Configs

Configure authentication