docs/replaying.mdx

</Step>
</Steps>
You can check if a run is a replay using the context object:
export const myTask = task({
id: "my-task",
run: async (payload, { ctx }) => {
if (ctx.run.isReplay) {
// This run is a replay of a previous run
}
},
});
You can replay a run using the SDK:
const replayedRun = await runs.replay(run.id);
When you call trigger() or batchTrigger() on a task you receive back a run handle which has an id property. You can use that id to replay the run.
You can also access the run id from inside a run. You could write this to your database and then replay it later.
export const simpleChildTask = task({
id: "simple-child-task",
run: async (payload, { ctx }) => {
// the run ID (and other useful info) is in ctx
const runId = ctx.run.id;
},
});
See Bulk actions for more information.