Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

Workflow.sleepUntil()

The .sleepUntil() method pauses execution until a specified date.

Usage exampleDirect link to Usage example

workflow.sleepUntil(new Date(Date.now() + 5000));

ParametersDirect link to Parameters

dateOrCallback:

Date | ((params: ExecuteFunctionParams) => Promise<Date>)
Either a Date object or a callback function that returns a Date. The callback receives execution context and can compute the target time dynamically based on input data.

ReturnsDirect link to Returns

workflow:

Workflow
The workflow instance for method chaining

Extended usage exampleDirect link to Extended usage example

import { createWorkflow, createStep } from "@mastra/core/workflows";

const step1 = createStep({...});
const step2 = createStep({...});

export const testWorkflow = createWorkflow({...})
.then(step1)
.sleepUntil(async ({ inputData }) => {
const { delayInMs } = inputData;
return new Date(Date.now() + delayInMs);
})
.then(step2)
.commit();

On this page