Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 46 additions & 19 deletions docs/bulk-actions.mdx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
---
title: "Bulk actions"
description: "Perform actions like replay and cancel on multiple runs at once."
description: "Replay or cancel multiple runs from the dashboard using filters or selected run IDs."
---

Bulk actions allow you to perform replaying and canceling on multiple runs at once. This is especially useful when you need to retry a batch of failed runs with a new version of your code, or when you need to cancel multiple in-progress runs.
**Bulk actions let you replay or cancel multiple runs asynchronously from the dashboard.**

Use bulk actions when you need to retry failed runs after deploying a fix, or stop a group of queued or executing runs.

<Note>
For backend code, see [Bulk actions with the SDK](/runs/bulk-actions).
</Note>

<video
src="https://content.trigger.dev/bulk-actions.mp4"
Expand All @@ -16,34 +22,55 @@ Bulk actions allow you to perform replaying and canceling on multiple runs at on
height="100%"
/>

## How to create a new bulk action
## Create a bulk action in the dashboard

<Icon icon="circle-1" iconType="solid" color="#FF2D6B" size="20" /> Open the bulk action panel from the top right of the runs page
<Steps>
<Step title="Open the bulk action panel">
Open the runs page and click **Bulk action** in the top right.

![Access bulk actions](/images/bulk-action-open-panel.png)
![Open the bulk action panel from the runs page](/images/bulk-action-open-panel.png)
</Step>

<Step title="Choose the runs">
Filter the runs table to target a group of runs, or select individual runs from the table.
</Step>

<Icon icon="circle-2" iconType="solid" color="#FF2D6B" size="20" /> Filter the runs table to show the runs you want to bulk action
<Step title="Configure the action">
Choose **Replay** or **Cancel**, add an optional name, then confirm the action.

<Icon icon="circle-3" iconType="solid" color="#FF2D6B" size="20" /> Alternatively, you can select individual runs
![Configure and create a bulk action](/images/bulk-action-create.png)
</Step>

<Icon icon="circle-4" iconType="solid" color="#FF2D6B" size="20" /> Choose the runs you want to bulk action
<Step title="Track progress">
Open the bulk action page to see progress, view affected runs, or replay the action.

<Icon icon="circle-5" iconType="solid" color="#FF2D6B" size="20" /> Name your bulk action (optional)
![View bulk action progress](/images/bulk-action-page.png)
</Step>
</Steps>

<Icon icon="circle-6" iconType="solid" color="#FF2D6B" size="20" /> Choose the action you want to perform, replay or cancel
<Note>
You can only cancel runs that are still cancelable, such as queued or executing runs. Runs that have already reached a final state cannot be canceled.
</Note>

<Icon icon="circle-7" iconType="solid" color="#FF2D6B" size="20" /> Click the "Replay" or "Cancel" button and confirm in the dialog

![Access bulk actions](/images/bulk-action-create.png)
## Create a bulk action from the SDK

<Icon icon="circle-8" iconType="solid" color="#FF2D6B" size="20" /> You'll now view the bulk action processing from the bulk action page
Use `runs.bulk.replay()` or `runs.bulk.cancel()` when you want to create a bulk action from your backend code.

<Icon icon="circle-9" iconType="solid" color="#FF2D6B" size="20" /> You can replay or view the runs from this page
```ts Your backend code
import { runs } from "@trigger.dev/sdk";

![Access bulk actions](/images/bulk-action-page.png)
const action = await runs.bulk.replay({
filter: {
status: "FAILED",
taskIdentifier: "sync-customer",
period: "24h",
},
name: "Replay failed customer syncs",
});

<Note>
You can only cancel runs that are in states that allow cancellation (like QUEUED or EXECUTING).
Runs that are already completed, failed, or in other final states by the time the bulk action process gets to them, cannot be canceled.
</Note>
const completed = await runs.bulk.poll(action.id);
console.log(completed.status, completed.counts);
```

See [Bulk actions with the SDK](/runs/bulk-actions) for canceling, listing, polling, and aborting bulk actions from your backend code.
17 changes: 15 additions & 2 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"run-usage",
"context",
"runs/priority",
"hidden-tasks"
"hidden-tasks",
"runs/bulk-actions"
Comment thread
carderne marked this conversation as resolved.
]
},
{
Expand Down Expand Up @@ -339,7 +340,6 @@
"management/runs/retrieve",
"management/runs/replay",
"management/runs/cancel",
"management/runs/bulk-actions",
"management/runs/reschedule",
"management/runs/update-metadata",
"management/runs/add-tags",
Expand All @@ -348,6 +348,15 @@
"management/runs/retrieve-result"
]
},
{
"group": "Bulk actions API",
"pages": [
"management/bulk-actions/create",
"management/bulk-actions/list",
"management/bulk-actions/retrieve",
"management/bulk-actions/abort"
]
},
{
"group": "Errors API",
"pages": [
Expand Down Expand Up @@ -751,6 +760,10 @@
"source": "/reattempting-replaying",
"destination": "/replaying"
},
{
"source": "/management/runs/bulk-actions",
"destination": "/runs/bulk-actions"
},
{
"source": "/tasks-overview",
"destination": "/tasks/overview"
Expand Down
4 changes: 4 additions & 0 deletions docs/errors-retrying.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,7 @@ export const openaiTask = task({
},
});
```

## Replay failed runs in bulk

After you deploy a fix, use [bulk actions](/bulk-actions) to replay multiple failed runs from the dashboard, or [bulk actions with the SDK](/runs/bulk-actions) to replay them from backend code. Bulk replay creates an asynchronous action that targets selected run IDs or a `runs.list()` filter, so you can retry a known failure set without replaying each run individually.
4 changes: 4 additions & 0 deletions docs/management/bulk-actions/abort.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "Abort bulk action"
openapi: "v3-openapi POST /api/v1/bulk-actions/{bulkActionId}/abort"
---
4 changes: 4 additions & 0 deletions docs/management/bulk-actions/create.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "Create bulk action"
openapi: "v3-openapi POST /api/v1/bulk-actions"
---
4 changes: 4 additions & 0 deletions docs/management/bulk-actions/list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "List bulk actions"
openapi: "v3-openapi GET /api/v1/bulk-actions"
---
4 changes: 4 additions & 0 deletions docs/management/bulk-actions/retrieve.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "Retrieve bulk action"
openapi: "v3-openapi GET /api/v1/bulk-actions/{bulkActionId}"
---
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
title: "Bulk actions"
description: "Cancel or replay many runs from the SDK using run IDs or the same filters as runs.list()."
description: "Cancel or replay many runs from the SDK using run IDs or SDK run-list filters."
---

**Bulk actions let you cancel or replay many runs asynchronously from the SDK by selecting runs with run IDs or `runs.list()` filters.**
**Bulk actions let you cancel or replay many runs asynchronously from the SDK by selecting runs with run IDs or SDK run-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.

Expand All @@ -28,18 +28,14 @@ const completed = await runs.bulk.poll(action.id);
console.log(completed.status, completed.counts);
```

`filter` accepts the same filters as [`runs.list()`](/management/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.
`filter` accepts the SDK run-list filter fields, excluding pagination fields such as `limit`, `after`, and `before`. This is the TypeScript SDK shape used by `runs.list()` (`from`, `to`, and `period` are top-level fields), not the nested `filter[createdAt]` query shape shown in the raw HTTP list-runs endpoint. 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.

<Warning>
Filters inherit the same time semantics as `runs.list()`: when you don't pass `from`, `to`, or `period`, the action defaults to the **last 7 days** and won't target older matching runs. To cover a wider range, pass an explicit `period` (such as `"30d"`), a `from` timestamp, or a `from`/`to` pair. This default only applies to `filter` selections; `runIds` selections are never time-bounded.
</Warning>

<Note>
Each environment can only run a limited number of bulk replays at the same time. If you start a replay while too many are still in progress, the call fails and returns an error. Wait for an in-progress replay to finish (or [abort](#abort-a-bulk-action) one) before starting another. Bulk cancels are not subject to this limit.
</Note>

<ParamField body="filter" type="BulkActionFilter">
Selects runs using the same filter shape as `runs.list()`, excluding `limit`, `after`, and `before`.
Selects runs using the SDK run-list filter shape, excluding `limit`, `after`, and `before`. In raw HTTP requests these fields are sent as JSON body properties, so time fields are top-level (`from`, `to`, `period`) instead of nested under `createdAt`.
</ParamField>

<ParamField body="runIds" type="string[]">
Expand Down Expand Up @@ -148,6 +144,10 @@ await runs.bulk.abort("bulk_1234");

Abort is best effort. Runs already being processed in the current batch may still finish.

<Note>
Each environment can only run a limited number of bulk replays at the same time. If you start a replay while too many are still in progress, the call fails and returns an error. Wait for an in-progress replay to finish or abort one before starting another. Bulk cancels are not subject to this limit.
</Note>

## List bulk actions

Use `runs.bulk.list()` to page through previous bulk actions in the current environment.
Expand All @@ -171,3 +171,12 @@ for await (const action of runs.bulk.list({ limit: 25 })) {
console.log(action.id, action.status);
}
```

## API reference

The SDK methods use the bulk actions HTTP API:

- [Create bulk action](/management/bulk-actions/create)
- [List bulk actions](/management/bulk-actions/list)
- [Retrieve bulk action](/management/bulk-actions/retrieve)
- [Abort bulk action](/management/bulk-actions/abort)
Loading