# Wait for event
Source: https://www.inngest.com/docs/reference/functions/step-wait-for-event

description = `Wait for a particular event to be received before continuing with step.waitForEvent()`;

## `step.waitForEvent(id, options): Promise<null | EventPayload>`

<Row>
  <Col>
    <Properties>
      <Property name="id" type="string" required>
        The ID of the step. This will be what appears in your function's logs and is used to memoize step state across function versions.
      </Property>
      <Property name="options" type="object" required>
        Options for configuring how to wait for the event.
        <Properties nested={true}>
          <Property name="event" type="string" required>
            The name of a given event to wait for.
          </Property>
          <Property name="timeout" type="string" required>
            The amount of time to wait to receive the event. A time string compatible with the [ms](https://npm.im/ms) package, e.g. `"30m"`, `"3 hours"`, or `"2.5d"`
          </Property>
          <Property name="match" type="string">
            The property to match the event trigger and the wait event, using dot-notation, e.g. `data.userId`. Cannot be combined with `if`.
          </Property>
          <Property name="if" type="string">
            An expression on which to conditionally match the original event trigger (`event`) and the wait event (`async`). Cannot be combined with `match`.**

            Expressions are defined using the Common Expression Language (CEL) with the events accessible using dot-notation. Read [our guide to writing expressions](/docs/guides/writing-expressions) for more info. Examples:

            * `event.data.userId == async.data.userId && async.data.billing_plan == 'pro'`
          </Property>
        </Properties>
      </Property>
    </Properties>
  </Col>
  <Col>
  <CodeGroup>
  ```ts {{ title: "v3" }}
  // Wait 7 days for an approval and match invoice IDs
  await step.waitForEvent("wait-for-approval", {
    event: "app/invoice.approved",
    timeout: "7d",
    match: "data.invoiceId",
  });

  // Wait 30 days for a user to start a subscription
  // on the pro plan
  await step.waitForEvent("wait-for-subscription", {
    event: "app/subscription.created",
    timeout: "30d",
    if: "event.data.userId == async.data.userId && async.data.billing_plan == 'pro'",
  });
  ```
  ```ts {{ title: "v2" }}
  // Wait 7 days for an approval and match invoice IDs
  await step.waitForEvent("app/invoice.approved", {
    timeout: "7d",
    match: "data.invoiceId",
  });

  // Wait 30 days for a user to start a subscription
  // on the pro plan
  await step.waitForEvent("app/subscription.created", {
    timeout: "30d",
    if: "event.data.userId == async.data.userId && async.data.billing_plan == 'pro'",
  });
  ```
  </CodeGroup>
  </Col>
</Row>

<Callout>
  `step.waitForEvent()` must be called using `await` or some other Promise handler to ensure your function sleeps correctly.
</Callout>