Skip to Content
APITriggers API

Triggers API

Triggers enable event-driven task execution. Connect external services like GitHub, Slack, or custom webhooks to automatically run agents when events occur.

The Trigger Object

{ "id": "trig_abc123", "userId": "user_xxx", "name": "Deploy on Push", "environmentId": "env_xxx", "agentId": "agent_xxx", "source": "github", "event": "push", "filters": { "repo": "org/my-repo", "branch": "main" }, "action": { "type": "send_message", "message": "A push was received. Review the changes." }, "enabled": true, "webhookSecret": "a1b2c3...", "webhookUrl": "https://api.computer-agents.com/webhooks/triggers/trig_abc123", "lastTriggeredAt": "2025-01-15T14:00:00Z", "createdAt": "2025-01-01T10:00:00Z", "updatedAt": "2025-01-15T14:00:00Z" }

Attributes

AttributeTypeDescription
idstringUnique identifier (trig_*)
userIdstringOwner user ID
namestringTrigger name
environmentIdstringEnvironment for execution
agentIdstring | nullOptional agent to use
sourcestringEvent source: github, slack, email, webhook, cron, custom
eventstringEvent type (e.g., push, pull_request, message)
filtersobject | nullFilter criteria for matching events
actionobjectWhat to do when triggered
enabledbooleanWhether trigger is active
webhookSecretstringHMAC secret for signature verification
webhookUrlstringURL to configure in your external service
lastTriggeredAtstring | nullLast time the trigger fired

Action Object

FieldTypeDescription
typestringAlways send_message
messagestringStatic message to send to the agent
templatestringTemplate with {{payload}} placeholder for webhook data

Use template with {"{"}{"{"}payload{"}"}{"}"} to inject the full webhook payload into the agent’s prompt. This lets the agent see commit details, PR descriptions, etc.


Create Trigger

POST /v1/triggers

Request Body

ParameterTypeRequiredDescription
namestringYesTrigger name
environmentIdstringYesEnvironment for execution
sourcestringYesgithub, slack, webhook, email, cron, custom
eventstringYesEvent type to match
actionobjectYesAction to perform
agentIdstringNoAgent to use
filtersobjectNoFilter criteria
enabledbooleanNoEnable immediately (default: true)

Example

curl -X POST https://api.computer-agents.com/v1/triggers \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Review PRs", "environmentId": "env_xxx", "source": "github", "event": "push", "filters": { "repo": "org/my-repo", "branch": "main" }, "action": { "type": "send_message", "template": "Review this push:\n\n{{payload}}" } }'

Response

{ "trigger": { "id": "trig_abc123", "name": "Review PRs", "source": "github", "event": "push", "enabled": true, "webhookSecret": "a1b2c3d4e5f6...", "webhookUrl": "https://api.computer-agents.com/webhooks/triggers/trig_abc123", "createdAt": "2025-01-15T10:00:00Z" } }

Webhook Setup

After creating a trigger, configure the external service to send webhooks to your trigger’s URL.

GitHub

  1. Go to your repo Settings → Webhooks → Add webhook
  2. Payload URL: Use the webhookUrl from the trigger response
  3. Content type: application/json
  4. Secret: Use the webhookSecret from the trigger response
  5. Events: Select the event that matches your trigger (e.g., “Just the push event”)

The webhookSecret is only returned when the trigger is created. Store it securely — you’ll need it to configure the webhook in GitHub.

Slack

  1. Go to your Slack app settings → Event Subscriptions
  2. Set the Request URL to your trigger’s webhookUrl
  3. Use the webhookSecret as your Signing Secret
  4. Subscribe to the events you want to trigger on

Custom / Generic Webhooks

For any service that supports webhooks, send a POST request to the trigger’s webhookUrl with:

# Compute HMAC-SHA256 signature PAYLOAD='{"event": "deploy", "version": "2.0"}' SIG=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/.*= //') curl -X POST "$WEBHOOK_URL" \ -H "X-Webhook-Signature: sha256=$SIG" \ -H "Content-Type: application/json" \ -d "$PAYLOAD"

Webhook Ingestion Endpoint

POST /webhooks/triggers/:triggerId

This is the public endpoint that external services call. No API key required — authentication is via HMAC signature verification.

Signature Verification

SourceHeaderFormat
GitHubX-Hub-Signature-256sha256=<HMAC-SHA256 hex>
SlackX-Slack-Signaturev0=<HMAC-SHA256 hex>
GenericX-Webhook-Signaturesha256=<HMAC-SHA256 hex>

Event Matching

For GitHub webhooks, the event type is read from the X-GitHub-Event header and matched against the trigger’s event field. If the event doesn’t match, the webhook is acknowledged (200) but skipped.

Filter Matching

FilterPayload FieldDescription
reporepository.full_nameGitHub repository (e.g., org/repo)
branchrefBranch name (strips refs/heads/ prefix)

Response

{ "acknowledged": true, "executionId": "texec_abc123", "threadId": "thread_xxx" }

Skipped Response

When the event or filters don’t match:

{ "acknowledged": true, "skipped": true, "reason": "Event 'issues' does not match trigger event 'push'" }

List Triggers

GET /v1/triggers

Query Parameters

ParameterTypeDescription
environmentIdstringFilter by environment
sourcestringFilter by source
enabledbooleanFilter by enabled status
limitnumberMax results
offsetnumberPagination offset

Example

curl "https://api.computer-agents.com/v1/triggers?source=github" \ -H "Authorization: Bearer $API_KEY"

Response

{ "object": "list", "data": [ { "id": "trig_abc123", "name": "Review PRs", "source": "github", "event": "push", "enabled": true, "webhookUrl": "https://api.computer-agents.com/webhooks/triggers/trig_abc123" } ], "has_more": false, "total_count": 3 }

Get Trigger

GET /v1/triggers/:id

Example

curl https://api.computer-agents.com/v1/triggers/trig_abc123 \ -H "Authorization: Bearer $API_KEY"

Update Trigger

PATCH /v1/triggers/:id

Request Body

ParameterTypeDescription
namestringNew name
agentIdstring | nullNew agent
eventstringNew event type
filtersobject | nullNew filters
actionobjectNew action
enabledbooleanEnable/disable

Example

curl -X PATCH https://api.computer-agents.com/v1/triggers/trig_abc123 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"event": "pull_request"}'

Delete Trigger

DELETE /v1/triggers/:id

Example

curl -X DELETE https://api.computer-agents.com/v1/triggers/trig_abc123 \ -H "Authorization: Bearer $API_KEY"

Enable/Disable Trigger

Enable

PATCH /v1/triggers/:id/enable

Disable

PATCH /v1/triggers/:id/disable

Example

# Enable curl -X PATCH https://api.computer-agents.com/v1/triggers/trig_abc123/enable \ -H "Authorization: Bearer $API_KEY" # Disable curl -X PATCH https://api.computer-agents.com/v1/triggers/trig_abc123/disable \ -H "Authorization: Bearer $API_KEY"

Test Fire Trigger

Manually fire a trigger with an optional test payload.

POST /v1/triggers/:id/test

Request Body

ParameterTypeDescription
payloadobjectOptional test payload

Example

curl -X POST https://api.computer-agents.com/v1/triggers/trig_abc123/test \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"payload": {"ref": "refs/heads/main", "commits": [{"message": "test"}]}}'

Response

{ "execution": { "id": "texec_abc123", "triggerId": "trig_abc123", "threadId": "thread_xxx", "status": "running", "createdAt": "2025-01-15T14:00:00Z" } }

List Trigger Executions

GET /v1/triggers/:id/executions

Query Parameters

ParameterTypeDescription
limitnumberMax results
offsetnumberPagination offset

Example

curl "https://api.computer-agents.com/v1/triggers/trig_abc123/executions" \ -H "Authorization: Bearer $API_KEY"

Response

{ "object": "list", "data": [ { "id": "texec_abc123", "triggerId": "trig_abc123", "threadId": "thread_xxx", "status": "completed", "eventPayload": { "ref": "refs/heads/main" }, "createdAt": "2025-01-15T14:00:00Z" } ], "has_more": false, "total_count": 10 }

Errors

StatusErrorDescription
400Bad RequestMissing required fields
401UnauthorizedWebhook signature verification failed
402Payment RequiredMonthly usage allowance exhausted
404Not FoundTrigger not found
409ConflictTrigger is disabled

Last updated on