# Workflow.sleep()
[EN] Source: https://mastra.ai/reference/workflows/workflow-methods/sleep

The `.sleep()` method pauses execution for a specified number of milliseconds. It accepts either a static number or a callback function for dynamic delays.

## Usage example

```typescript copy
workflow.sleep(5000);
```

## Parameters

<PropertiesTable
  content={[
    {
      name: "milliseconds",
      type: "number | ((context: { inputData: any }) => number | Promise<number>)",
      description:
        "The number of milliseconds to pause execution, or a callback that returns the delay",
      isOptional: false,
    },
  ]}
/>

## Returns

<PropertiesTable
  content={[
    {
      name: "workflow",
      type: "Workflow",
      description: "The workflow instance for method chaining",
    },
  ]}
/>

## Extended usage example

```typescript showLineNumbers copy
import { createWorkflow, createStep } from "@mastra/core/workflows";

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

export const testWorkflow = createWorkflow({...})
  .then(step1)
  .sleep(async ({ inputData }) => {
    const { delayInMs } = inputData;
    return delayInMs;
  })
  .then(step2)
  .commit();
```

## Related

- [Suspend & Resume](/docs/workflows/suspend-and-resume#sleep--events)


---
title: "Reference: Workflow.sleepUntil() | Workflows"
description: Documentation for the `Workflow.sleepUntil()` method in workflows, which pauses execution until a specified date.
---