Skip to Content

Create batch

Required accessBatches: batch triggerbatchTrigger:batchAny key with this access, from API keys
POST
/api/v3/batches

Phase 1 of 2-phase batch API. Creates a batch record and optionally blocks the parent run for batchTriggerAndWait. After creating a batch, stream items via POST /api/v3/batches/{batchId}/items.

Authorization

BearerAuth
headerAuthorizationBearer <JWT>

Request Body

application/json
  1. body
runCount*integer

Expected number of items in the batch. Must be a positive integer, up to the server's maximum batch size (1,000 by default; self-hosted instances can configure it). Requests above the maximum return a 400.

Range1 <= value
taskIdentifiers?array<string>

Distinct task identifiers of the items in the batch. Used to authorize tokens scoped to specific tasks. If omitted, only credentials with broad task access are accepted.

Items1 <= items
parentRunId?string

Parent run ID (friendly ID) for batchTriggerAndWait.

resumeParentOnCompletion?boolean

Whether to resume parent on completion. Set to true for batchTriggerAndWait.

idempotencyKey?string

Idempotency key for the batch. If provided and a batch with this key already exists, the existing batch will be returned.

Response Body

Batch successfully created

application/json
  1. response
id*string

The batch ID (friendly ID). Use this to stream items via POST /api/v3/batches/{batchId}/items.

runCount*integer

The expected run count.

isCached*boolean

Whether this response came from a cached/idempotent batch.

idempotencyKey?string

The idempotency key if provided.

Example Request
curl -X POST 'https://api.trigger.dev/api/v3/batches' \  -H 'Content-Type: application/json' \  -d '{  "runCount": 1}'
Example Response
{  "id": "string",  "runCount": 0,  "isCached": true,  "idempotencyKey": "string"}

Was this page helpful?

Last updated

Edit on GitHub