Overview
Trigger up to 1,000 task runs in one request. Two endpoints are available:
| Endpoint | Use case |
|---|
POST /api/v1/tasks/{taskIdentifier}/batch | All items run the same task |
POST /api/v1/tasks/batch | Items can run different tasks |
Authentication with a secret key is required. This endpoint is not available with a Personal
Access Token.
Batch trigger a single task
POST https://api.trigger.dev/api/v1/tasks/{taskIdentifier}/batch
All items in the request run the task identified by taskIdentifier.
Path parameters
The id of the task to run for every item in the batch.
Request body
Array of up to 1,000 trigger request objects. Each item has the same shape as the single trigger request body:
The payload for this specific run.
Optional JSON context available inside the run.
Per-run options: queue, concurrencyKey, idempotencyKey, ttl, delay, tags, machine.
Response
The ID of the created batch, prefixed with batch_.
An array of run IDs created by this batch, one per item.
Examples
import { myTask } from "./trigger/my-task";
const result = await myTask.batchTrigger([
{ payload: { message: "Hello, world!" } },
{ payload: { message: "Hello again!" } },
{
payload: { message: "With options" },
options: { tags: ["user:123"] },
},
]);
console.log(result.batchId); // batch_1234
console.log(result.runs); // ["run_aaa", "run_bbb", "run_ccc"]
Batch trigger multiple tasks
POST https://api.trigger.dev/api/v1/tasks/batch
Each item can target a different task. Useful for fan-out workflows.
Request body
Array of up to 1,000 items. Each item must include a task field in addition to the standard trigger properties.
The task identifier to run for this item.
The payload for this specific run.
Per-run options: queue, concurrencyKey, idempotencyKey, ttl, delay, tags, machine.
Response
The ID of the created batch.
An array of run IDs, one per item.
Example
curl -X POST "https://api.trigger.dev/api/v1/tasks/batch" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer tr_dev_1234" \
-d '{
"items": [
{ "task": "send-email", "payload": { "to": "[email protected]" } },
{ "task": "send-slack", "payload": { "channel": "#general", "message": "Done!" } }
]
}'
{
"batchId": "batch_1234",
"runs": ["run_aaa", "run_bbb"]
}