Skip to main content

Overview

Trigger up to 1,000 task runs in one request. Two endpoints are available:
EndpointUse case
POST /api/v1/tasks/{taskIdentifier}/batchAll items run the same task
POST /api/v1/tasks/batchItems 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

taskIdentifier
string
required
The id of the task to run for every item in the batch.

Request body

items
object[]
required
Array of up to 1,000 trigger request objects. Each item has the same shape as the single trigger request body:

Response

batchId
string
The ID of the created batch, prefixed with batch_.
runs
string[]
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

items
object[]
required
Array of up to 1,000 items. Each item must include a task field in addition to the standard trigger properties.

Response

batchId
string
The ID of the created batch.
runs
string[]
An array of run IDs, one per item.

Example

cURL
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"]
}

Build docs developers (and LLMs) love