Skip to content

Commit 93975a0

Browse files
committed
split docs, fix openapi and schema stuff
1 parent abd4478 commit 93975a0

5 files changed

Lines changed: 196 additions & 166 deletions

File tree

docs/bulk-actions.mdx

Lines changed: 7 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: "Bulk actions"
3-
description: "Replay or cancel multiple runs from the dashboard or SDK using filters or selected run IDs."
3+
description: "Replay or cancel multiple runs from the dashboard using filters or selected run IDs."
44
---
55

6-
**Bulk actions let you replay or cancel multiple runs asynchronously using the dashboard or SDK.**
6+
**Bulk actions let you replay or cancel multiple runs asynchronously from the dashboard.**
77

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

1010
<Note>
11-
The dashboard workflow is shown first. For backend code, see [Create a bulk replay from the SDK](#create-a-bulk-replay-from-the-sdk).
11+
For backend code, see [Bulk actions with the SDK](/runs/bulk-actions).
1212
</Note>
1313

1414
<video
@@ -52,9 +52,10 @@ Use bulk actions when you need to retry failed runs after deploying a fix, or st
5252
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.
5353
</Note>
5454

55-
## Create a bulk replay from the SDK
5655

57-
Use `runs.bulk.replay()` to replay every run that matches a filter.
56+
## Create a bulk action from the SDK
57+
58+
Use `runs.bulk.replay()` or `runs.bulk.cancel()` when you want to create a bulk action from your backend code.
5859

5960
```ts Your backend code
6061
import { runs } from "@trigger.dev/sdk";
@@ -66,162 +67,10 @@ const action = await runs.bulk.replay({
6667
period: "24h",
6768
},
6869
name: "Replay failed customer syncs",
69-
targetRegion: "eu-central-1",
7070
});
7171

7272
const completed = await runs.bulk.poll(action.id);
7373
console.log(completed.status, completed.counts);
7474
```
7575

76-
`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.
77-
78-
<Warning>
79-
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.
80-
</Warning>
81-
82-
<ParamField body="filter" type="BulkActionFilter">
83-
Selects runs using the same filter shape as `runs.list()`, excluding `limit`, `after`, and `before`.
84-
</ParamField>
85-
86-
<ParamField body="runIds" type="string[]">
87-
Selects specific run IDs. Provide either `filter` or `runIds`, not both.
88-
</ParamField>
89-
90-
<ParamField body="name" type="string" optional>
91-
A name for the bulk action.
92-
</ParamField>
93-
94-
<ParamField body="targetRegion" type="string" optional>
95-
Replays matching runs in a specific region. When omitted, each replay keeps the original run's region. This option is only available for `runs.bulk.replay()`.
96-
</ParamField>
97-
98-
## Create a bulk cancel from the SDK
99-
100-
Use `runs.bulk.cancel()` to cancel every run that matches a filter, or specific run IDs.
101-
102-
```ts Your backend code
103-
import { runs } from "@trigger.dev/sdk";
104-
105-
const action = await runs.bulk.cancel({
106-
runIds: ["run_1234", "run_5678"],
107-
name: "Cancel selected runs",
108-
});
109-
110-
console.log(action.id);
111-
```
112-
113-
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.
114-
115-
## Retrieve progress from the SDK
116-
117-
Use `runs.bulk.retrieve()` to read the current status and aggregate counts.
118-
119-
```ts Your backend code
120-
import { runs } from "@trigger.dev/sdk";
121-
122-
const action = await runs.bulk.retrieve("bulk_1234");
123-
124-
console.log(action.status);
125-
console.log(action.counts.total, action.counts.success, action.counts.failure);
126-
```
127-
128-
The returned bulk action object has these fields:
129-
130-
<ResponseField name="id" type="string">
131-
The bulk action ID, starting with `bulk_`.
132-
</ResponseField>
133-
134-
<ResponseField name="type" type="'CANCEL' | 'REPLAY'">
135-
The action being performed.
136-
</ResponseField>
137-
138-
<ResponseField name="status" type="'PENDING' | 'COMPLETED' | 'ABORTED'">
139-
The current bulk action status.
140-
</ResponseField>
141-
142-
<ResponseField name="counts" type="object">
143-
Aggregate processing counts.
144-
145-
<Expandable title="properties">
146-
<ResponseField name="total" type="number">
147-
The number of runs selected when the bulk action was created.
148-
</ResponseField>
149-
<ResponseField name="success" type="number">
150-
The number of runs processed successfully.
151-
</ResponseField>
152-
<ResponseField name="failure" type="number">
153-
The number of runs that could not be processed.
154-
</ResponseField>
155-
</Expandable>
156-
</ResponseField>
157-
158-
<ResponseField name="createdAt" type="Date">
159-
The date and time the bulk action was created.
160-
</ResponseField>
161-
162-
<ResponseField name="completedAt" type="Date" optional>
163-
The date and time the bulk action completed.
164-
</ResponseField>
165-
166-
## Poll for completion
167-
168-
Use `runs.bulk.poll()` to wait until the bulk action leaves the `PENDING` state.
169-
170-
```ts Your backend code
171-
import { runs } from "@trigger.dev/sdk";
172-
173-
const completed = await runs.bulk.poll("bulk_1234", {
174-
pollIntervalMs: 2_000,
175-
});
176-
177-
console.log(completed.status);
178-
```
179-
180-
## Abort a bulk action from the SDK
181-
182-
Use `runs.bulk.abort()` to stop future batches from being processed.
183-
184-
```ts Your backend code
185-
import { runs } from "@trigger.dev/sdk";
186-
187-
await runs.bulk.abort("bulk_1234");
188-
```
189-
190-
Abort is best effort. Runs already being processed in the current batch may still finish.
191-
192-
<Note>
193-
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.
194-
</Note>
195-
196-
## List bulk actions from the SDK
197-
198-
Use `runs.bulk.list()` to page through previous bulk actions in the current environment.
199-
200-
```ts Your backend code
201-
import { runs } from "@trigger.dev/sdk";
202-
203-
const page = await runs.bulk.list({ limit: 25 });
204-
205-
for (const action of page.data) {
206-
console.log(action.id, action.status);
207-
}
208-
```
209-
210-
List results support the same auto-pagination helpers as other management API list methods:
211-
212-
```ts Your backend code
213-
import { runs } from "@trigger.dev/sdk";
214-
215-
for await (const action of runs.bulk.list({ limit: 25 })) {
216-
console.log(action.id, action.status);
217-
}
218-
```
219-
220-
## API reference
221-
222-
The SDK methods use the bulk actions HTTP API:
223-
224-
- [Create bulk action](/management/bulk-actions/create)
225-
- [List bulk actions](/management/bulk-actions/list)
226-
- [Retrieve bulk action](/management/bulk-actions/retrieve)
227-
- [Abort bulk action](/management/bulk-actions/abort)
76+
See [Bulk actions with the SDK](/runs/bulk-actions) for canceling, listing, polling, and aborting bulk actions from your backend code.

docs/docs.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
"run-usage",
7878
"context",
7979
"runs/priority",
80-
"hidden-tasks"
80+
"hidden-tasks",
81+
"runs/bulk-actions"
8182
]
8283
},
8384
{
@@ -761,11 +762,7 @@
761762
},
762763
{
763764
"source": "/management/runs/bulk-actions",
764-
"destination": "/bulk-actions"
765-
},
766-
{
767-
"source": "/runs/bulk-actions",
768-
"destination": "/bulk-actions"
765+
"destination": "/runs/bulk-actions"
769766
},
770767
{
771768
"source": "/tasks-overview",

docs/errors-retrying.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,4 @@ export const openaiTask = task({
380380

381381
## Replay failed runs in bulk
382382

383-
After you deploy a fix, use [bulk actions](/bulk-actions) to replay multiple failed runs from the dashboard or SDK. 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.
383+
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.

0 commit comments

Comments
 (0)