> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nelkap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pause a run

> Sleep for a while, or wait for an event, for as long as it takes.

## Sleep

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
await nelkap.step.sleep('3 days');
```

A duration is a count and a unit: second, minute, hour, day, week, month, or year. It can go up to a year. Months and years follow the calendar.

## Wait for an event

A run can hold until someone answers, however long it takes:

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
export async function refundOrder(orderId: string) {
  await nelkap.step.run('approval request', () => askManager(orderId));

  const review = await nelkap.step.wait<{ approved: boolean }>(`refund_${orderId}`);

  if (review.approved) {
    await nelkap.step.run('refund', () => refund(orderId));
  }
}
```

When the manager answers, emit an event with the same key:

```ts theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
await nelkap.emit({ event: 'refund.reviewed', payload: { approved: true }, wakeOn: `refund_${orderId}` });
```

* Pick a key that names what you wait for, like the order it belongs to.
* `step.wait` returns the payload of the event that woke it.
* A run can wait up to a year.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.