Webhook Triggers
Webhook triggers let external systems start runs via HTTP POST. Three types:
Same work every time → task webhook. Different message per trigger → agent webhook. Connected app fires it → app trigger.
Task Webhooks
Attach a webhook trigger to a task, then POST to the generated URL to run it:
from m8tes import M8tes
client = M8tes()
task = client.tasks.create(agent_id=1, instructions="Generate the weekly sales report")
trigger = client.tasks.triggers.create(task_id=task.id, type="webhook")
print(trigger.url) # https://api.m8tes.ai/api/v1/webhooks/tasks/{id}/{token}Any system can now trigger it. The body is optional; the task already has its instructions:
import requests
requests.post(trigger.url) # simple trigger
requests.post(trigger.url, json={"context": "Include data from last 7 days"})Disable the webhook when you no longer need it; if the URL leaked, re-enabling rotates it (fresh token, old URL dead):
client.tasks.disable_webhook(task_id=1)
hook = client.tasks.enable_webhook(task_id=1) # new URLAgent Webhooks
Enable a webhook directly on an agent. Each POST creates a new run with the message you provide:
webhook = client.agents.enable_webhook(1)
print(webhook.url) # https://api.m8tes.ai/api/v1/webhooks/mates/1/tok_...
client.agents.disable_webhook(1) # turn it off againImportant: The webhook URL contains a secret token and is only shown once. Store it securely.
POST a JSON body with a message field; the agent processes it with its configured instructions and tools:
import requests
requests.post(webhook.url, json={"message": "New support ticket: User cannot reset password"})App Triggers
App triggers start task runs when events occur in your connected apps (GitHub, Slack, ...). No webhook URL management: connect the app, pick an event, and Composio delivers it.
# 1. Discover the events a connected app supports
for t in client.apps.list_triggers("github"):
print(t.slug, t.description)
# GITHUB_COMMIT_EVENT On new commit pushed
# 2. Attach one to a task
trigger = client.tasks.triggers.create(
task_id=task.id,
type="app",
app="github",
trigger_name="GITHUB_COMMIT_EVENT",
trigger_config={"owner": "acme", "repo": "app"},
# user_id="end_user_123", # optional: use this end-user's connection
)When the event fires, the task runs with the event data injected into its instructions. If the app is disconnected or the connection expires, its triggers are disabled automatically.
Prerequisite: The app must be connected first via
client.apps.connect()or the dashboard.
Managing Triggers
for t in client.tasks.triggers.list(task_id=1):
print(t.id, t.type, t.url)
client.tasks.triggers.delete(task_id=1, trigger_id="schedule_10")When to use which: example scenarios
Deduplication: retried deliveries
Include an X-M8tes-Event-Id header so a retried delivery doesn't start a duplicate run:
requests.post(
webhook.url,
json={"message": "Process this event"},
headers={"X-M8tes-Event-Id": "evt_unique_123"},
)Next: Scheduling · Email Inbox · Webhook Events