Skip to main content
The notifications system is event-driven. Emitting an event causes the notification engine to evaluate registered rules and deliver notifications through the appropriate channels (in-app, email, WhatsApp).

Emit a notification event

POST /api/notifications/emit
string
Emits a named notification event with an optional context payload. The notification engine expands the event into one or more delivery effects based on registered rules.

Authentication

This endpoint accepts two modes:
  • Signed requests — the request body must be signed with the shared REQUEST_SIGNING_SECRET. The signature is verified before processing.
  • Unsigned requests — available when the REQUEST_SIGNING_DISABLED=1 environment variable is set (development/testing only).
Do not disable request signing in production. Unsigned requests bypass the signature verification that prevents unauthorized event injection.

Workflow mode

When Inngest workflows are enabled (WORKFLOWS_DISABLED is not 1, or WORKFLOWS_ENABLED=1), the event is queued for asynchronous processing and the endpoint returns immediately. Otherwise, effects are evaluated synchronously and in-app notifications are inserted directly.

Request body

type
string
required
The event type identifier. Must match a registered notification rule. Examples: obra.completed, flujo.action.triggered, pendiente.due.
ctx
object
Context object passed to the notification rules. Shape depends on the event type.

Response — workflow mode

ok
boolean
required
Always true.
workflow
string
required
Always "queued" in workflow mode.

Response — direct delivery mode

ok
boolean
required
Always true.
delivered
boolean
required
Always true when effects were processed.
inserted
number
required
Number of notifications rows inserted.

Error responses

StatusDescription
400Validation error — type is missing or the body is malformed.
401Request signature is invalid or missing.
500Internal error during event processing.
curl -X POST 'https://<domain>/api/notifications/emit' \
  --header 'Content-Type: application/json' \
  --header 'x-signature: <hmac-signature>' \
  --data '{
    "type": "obra.completed",
    "ctx": {
      "tenantId": "tenant-uuid-...",
      "actorId": "user-uuid-...",
      "obra": {
        "id": "obra-uuid-...",
        "name": "Escuela N° 42",
        "percentage": 100
      }
    }
  }'

Notification schema

Notifications are stored in the notifications table and governed by per-user Row Level Security — users can only read and modify their own notifications.
ColumnTypeDescription
iduuidPrimary key.
user_iduuidRecipient user.
tenant_iduuid | nullTenant scope.
titletextNotification title.
bodytext | nullNotification body text.
typetextNotification type (info, warning, error, etc.).
action_urltext | nullDeep link for the notification action.
datajsonbArbitrary metadata payload.
read_attimestamptz | nullTimestamp when the user read the notification; null if unread.
created_attimestamptzCreation timestamp.

Build docs developers (and LLMs) love