Skip to main content
context.notify() notifies workflows that are waiting for a specific event, passing along an optional payload. It is typically used in combination with context.waitForEvent.

Arguments

stepName
string
A unique identifier for the step.
eventId
string
The identifier of the event to notify. Must match the eventId used in context.waitForEvent.
eventData
any
Data to deliver to the waiting workflow(s). This value will be returned in eventData from the corresponding waitForEvent call.

Response

context.notify() returns a list of waiters describing the workflows that were notified.
notifyResponse
NotifyResponse[]
A list of NotifyResponse objects describing each workflow that was waiting on the event.

Usage

import { serve } from "@upstash/workflow/nextjs";

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

  const {
    notifyResponse, // result of notify, which is a list of notified waiters
  } = await context.notify("notify step", "my-event-Id", payload);
});