Upstash Documentation

context.notify

2 min read

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#

stepNamestring#

A unique identifier for the step.

eventIdstring#

The identifier of the event to notify. Must match the eventId used in context.waitForEvent.

eventDataany#

Data to deliver to the waiting workflow(s). This value will be returned in eventData from the corresponding waitForEvent call.

workflowRunIdstring#

The workflow run ID to notify. When provided, enables lookback functionality - the notification will be stored and delivered even if notify is called before waitForEvent.

This solves race conditions where notifications might be sent before a workflow reaches its wait step.

Response#

context.notify() returns a list of waiters describing the workflows that were notified.

notifyResponseNotifyResponse[]#

A list of NotifyResponse objects describing each workflow that was waiting on the event.

Show properties
messageIdstring#

The ID of the notification message delivered to the workflow. This is unique to every notification.

workflowRunIdstring#

The unique identifier of the workflow run that was notified.

workflowCreatedAtnumber#

Unix timestamp (in milliseconds) representing when the workflow was created.

Waiterobject#
Show properties
urlstringrequired#

URL to call upon notify

deadlinenumberrequired#

Unix timestamp for when the wait will time out

headersRecord<string, string[]>required#

Headers sent in case of notify

timeoutUrlstring#

URL to call upon timeout

timeoutBodyunknown#

Body used in timeout request

timeoutHeadersRecord<string, string[]>#

Headers sent in case of time out

Usage#

Basic Notification#

Notification with Lookback#

To prevent race conditions, you can provide a workflowRunId. This enables lookback - the notification will be stored and delivered even if sent before the target workflow reaches waitForEvent: