> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Search it with GET https://upstash.com/docs/search?q=<query>.
> Use these to discover all available pages before exploring further.

# context.waitForEvent

`context.waitForEvent` pauses workflow execution until a given event occurs or a timeout is reached.

Default timeout value is 7 days.

## Arguments

<ParamField body="stepId" type="string" required>
    A unique identifier for the step.
</ParamField>

<ParamField body="eventId" type="string" required>
    A unique identifier for the event to wait on.
</ParamField>

<ParamField body="options" type="object">
    <Expandable defaultOpen>
        <ParamField body="timeout" type="number|string">
            The maximum time to wait before continuing execution.

            - **String format**: Human‑readable duration (e.g., `"10s"`, `"2h"`, `"1d"`).
            - **Number format**: Duration in seconds (e.g., `60`, `3600`).

            Defaults to `7d` (7 days).
        </ParamField>
    </Expandable>
</ParamField>

## Response

<ResponseField name="eventData" type="TEventData">
    The data passed in when the event is triggered via `notify()`.
    Its type can be set with the generic parameter, e.g. `context.waitForEvent<{ approved: boolean }>(...)`. Defaults to `unknown`.
</ResponseField>

<ResponseField name="timeout" type="boolean">
    `true` if execution resumed because the timeout elapsed,
    `false` if resumed due to the event being received.
</ResponseField>

## Usage

```javascript highlight={6-11}
import { serve } from "@upstash/workflow/nextjs";

export const { POST } = serve<{ topic: string }>(async (context) => {
  const request = context.requestPayload;

  const {
    eventData,
    timeout,
  } = await context.waitForEvent("wait for some event", "my-event-id", {
    timeout: "1000s", // 1000 second timeout
  });
});

```
