API Triggers
Trigger workflows programmatically via the REST API
API Triggers
API triggers allow you to start workflows programmatically via the REST API. This is useful for on-demand processing, testing, or integrating with systems that don't support webhooks.
Configuration
API triggers have the simplest configuration:
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "api" |
That's it! The workflow can now be triggered via the REST API.
Running a Workflow
Basic Request
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
input | object | No | Input data passed to the workflow |
connectionId | string | No | Specific connection to use |
idempotencyKey | string | No | Prevent duplicate runs |
Response
| Field | Description |
|---|---|
runId | Unique identifier for this run |
status | Initial status (pending) |
workflowId | The workflow being executed |
workflowVersion | Version of the workflow used |
Input Data
The input object is available throughout your workflow as {{input}}:
Request:
In workflow steps:
Input Validation
Define expected input with a JSON schema at the workflow level:
If validation fails, the API returns 400 Bad Request:
Idempotency
Prevent duplicate workflow runs with idempotency keys:
If the same idempotencyKey is used again within 24 hours:
- The API returns the existing run instead of creating a new one
- No duplicate processing occurs
Best practices:
- Use meaningful keys:
process-order-{orderId},invoice-{invoiceId} - Include relevant identifiers from your input
- Keys expire after 24 hours
Checking Run Status
After triggering a workflow, poll for completion:
Run Status Response
Specifying a Connection
If your workflow uses multiple connections for the same provider, specify which one to use:
This is useful when:
- You have separate development and production connections
- Different customers use different OAuth connections
- You need to switch between sandbox and live environments
Error Handling
Common Error Responses
Workflow not found (404):
Workflow not active (400):
Rate limited (429):
Invalid input (400):
Rate Limits
API trigger endpoints have these limits:
| Category | Limit |
|---|---|
| Execute | 500 requests/minute per API key |
See Authentication for all rate limit details.
Use Cases
On-Demand Processing
Trigger workflows from your application:
Testing Workflows
Test webhook workflows without setting up actual webhooks:
Batch Processing
Trigger multiple workflow runs for batch operations:
Scheduled via External Scheduler
If you use an external scheduler (cron job, cloud scheduler):
Complete Example
Troubleshooting
Workflow Not Starting
- Check workflow status - Must be
active - Verify API key - Needs
workflows:executescope - Check rate limits - May be rate limited
Input Not Available
- Verify input structure - Check JSON is valid
- Check template syntax - Use
{{input.field}} - Review inputSchema - May be stripping unknown fields
Run Stuck in Pending
- Check Trigger.dev - Ensure dev mode is running
- Verify connections - Required connections must be active
- Review logs - Check for execution errors