---
title: "Reference: Workflow.sleep() | Workflows"
description: Documentation for the `Workflow.sleep()` method in workflows, which pauses execution for a specified number of milliseconds.
packages:
  - "@mastra/core"
---

# Workflow.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
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
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/v1/workflows/suspend-and-resume#sleep--events)
