Skip to main content
You can notify all the workflow runs waitingi for a specific event ID. There are two ways to send a notify request.

Notify within Workflow

Notifies other workflows waiting for a specific event from within a workflow.
import { serve } from "@upstash/workflow/nextjs";

export const { POST } = serve<string>(async (context) => {
  const { orderId, processingResult } = context.requestPayload;

  await context.run("process-order", async () => {
    // ...
  })

  const { notifyResponse } = await context.notify(
    "notify-processing-complete",
    `order-${orderId}`,
    {
      orderId,
      status: "completed",
      result: processingResult,
      completedAt: new Date().toISOString()
    }
  );

});

External Notification

You can also notify workflows from external systems using the Workflow Client:
import { Client } from "@upstash/workflow";

const client = new Client({ token: "<WORKFLOW_TOKEN>" });

await client.notify({
  eventId: "order-completed-123",
  eventData: {
    orderId: "123",
    status: "completed",
    deliveryTime: "2 days",
    trackingNumber: "TRK123456"
  }
});