docs/management/runs/bulk-actions.mdx
Bulk actions let you cancel or replay many runs asynchronously from the SDK by selecting runs with run IDs or runs.list() filters.
A bulk action returns a handle immediately. Use the handle to retrieve progress, poll until completion, list previous actions, or abort pending work.
Use runs.bulk.replay() to replay every run that matches a filter.
import { runs } from "@trigger.dev/sdk";
const action = await runs.bulk.replay({
filter: {
status: "FAILED",
taskIdentifier: "sync-customer",
period: "24h",
},
name: "Replay failed customer syncs",
targetRegion: "eu-central-1",
});
const completed = await runs.bulk.poll(action.id);
console.log(completed.status, completed.counts);
filter accepts the same filters as runs.list(), excluding pagination fields. Provide at least one filter field; use runIds when you want to target specific runs. Relative time filters such as period are resolved when the bulk action is created, so later batches process the same fixed time range.
Use runs.bulk.cancel() to cancel every run that matches a filter, or specific run IDs.
import { runs } from "@trigger.dev/sdk";
const action = await runs.bulk.cancel({
runIds: ["run_1234", "run_5678"],
name: "Cancel selected runs",
});
console.log(action.id);
Only runs that are still cancelable when the action reaches them are canceled. Runs that have already reached a final state count as failures in the bulk action summary.
Use runs.bulk.retrieve() to read the current status and aggregate counts.
import { runs } from "@trigger.dev/sdk";
const action = await runs.bulk.retrieve("bulk_1234");
console.log(action.status);
console.log(action.counts.total, action.counts.success, action.counts.failure);
The returned bulk action object has these fields:
<ResponseField name="id" type="string"> The bulk action ID, starting with `bulk_`. </ResponseField> <ResponseField name="type" type="'CANCEL' | 'REPLAY'"> The action being performed. </ResponseField> <ResponseField name="status" type="'PENDING' | 'COMPLETED' | 'ABORTED'"> The current bulk action status. </ResponseField> <ResponseField name="counts" type="object"> Aggregate processing counts. <Expandable title="properties"> <ResponseField name="total" type="number"> The number of runs selected when the bulk action was created. </ResponseField> <ResponseField name="success" type="number"> The number of runs processed successfully. </ResponseField> <ResponseField name="failure" type="number"> The number of runs that could not be processed. </ResponseField> </Expandable> </ResponseField> <ResponseField name="createdAt" type="Date"> The date and time the bulk action was created. </ResponseField> <ResponseField name="completedAt" type="Date" optional> The date and time the bulk action completed. </ResponseField>Use runs.bulk.poll() to wait until the bulk action leaves the PENDING state.
import { runs } from "@trigger.dev/sdk";
const completed = await runs.bulk.poll("bulk_1234", {
pollIntervalMs: 2_000,
});
console.log(completed.status);
Use runs.bulk.abort() to stop future batches from being processed.
import { runs } from "@trigger.dev/sdk";
await runs.bulk.abort("bulk_1234");
Abort is best effort. Runs already being processed in the current batch may still finish.
Use runs.bulk.list() to page through previous bulk actions in the current environment.
import { runs } from "@trigger.dev/sdk";
const page = await runs.bulk.list({ limit: 25 });
for (const action of page.data) {
console.log(action.id, action.status);
}
List results support the same auto-pagination helpers as other management API list methods:
import { runs } from "@trigger.dev/sdk";
for await (const action of runs.bulk.list({ limit: 25 })) {
console.log(action.id, action.status);
}