Skip to main content

The Postgres connector writes Novu webhook events to a table in your Postgres database. Use it when notification events need to live in an operational database or feed a reporting pipeline that already reads from Postgres.

Novu webhook delivery is powered by Svix, and this connector is one of its advanced endpoint types.

Note

Outbound webhooks are available on Team and Enterprise plans.

Prerequisites#

  • A Postgres database reachable over the public internet
  • The destination table created before you enable the endpoint. The connector does not create or alter tables.
  • A dedicated database user that can connect to the database and insert into that table
  • Network rules that allow the connection, including any cloud provider IP allowlist
Warning

Do not reuse an application owner or migration account. The connector only needs to insert into one table.

Configuration#

FieldRequiredDescription
HostYesHostname of the Postgres server.
PortYesPort the Postgres server listens on.
DatabaseYesDatabase that contains the destination table.
UsernameYesDatabase user the connector authenticates as.
PasswordYesPassword for that user.
Table nameYesTable that receives the event rows.
TransformationYesJavaScript that maps each webhook batch to rows for that table.

Create the destination table#

This schema keeps the event type available for filtering, extracts the two fields most reports need, and preserves the complete webhook body:

payload holds the full body as JSONB, so a new field in a Novu payload does not require a migration. received_at is set by the transformation rather than by the payload, which makes it a reliable sort key across every event type.

Grant least-privilege access#

Replace the database, schema, user, and table names with your own. Add SELECT only if your verification process or database policy requires the same user to read rows back.

Transformation contract#

The handler receives one delivery batch:

  • input.events, an array whose length is capped by the endpoint batch size
  • input.events[].eventType, the Novu event type, for example message.sent
  • input.events[].payload, the webhook body

The webhook body wraps the resource in an envelope. payload.object is the resource type as a string, such as "message", and the resource itself is under payload.data.object. For message events, fields such as subscriberId and channel are therefore at event.payload.data.object. Other event families use different resource shapes, so guard extracted fields with defaults.

The return shape is defined by the template the Novu Dashboard ships with this connector. Open the template and read the JSDoc comment above its handler for the exact keys, because the return shape differs between connector families. Map the values below into that template rather than pasting a handler from another connector page:

ColumnValue to map
idcrypto.randomUUID()
event_typeevent.eventType
subscriber_idevent.payload.data?.object?.subscriberId ?? null
channelevent.payload.data?.object?.channel ?? null
payloadJSON.stringify(event.payload)
received_atnew Date().toISOString()

Send an example event before you customize anything, read the transformed output in the endpoint’s Logs, then change one column at a time and re-test.

Configure in the Dashboard#

Prepare the database#

Create the table, create the restricted user, and apply the grants above. Confirm the user can connect and insert from outside your network.

Add the endpoint#

Open Webhooks in the Novu Dashboard, select Endpoints, click Add Endpoint, and choose Postgres.

Enter connection details#

Enter the host, port, database, username, password, and table name. Add a description that identifies the database and environment.

Configure the transformation#

Start from the transformation template shown in the Dashboard and map the columns using the table above.

Select event types#

Subscribe to the event types your consumer needs. All subscribed types insert into the same table, so confirm the transformation produces valid rows for each one. For delivery reporting, start with message.sent, message.delivered, and message.failed.

Test the endpoint#

Click Create, open the endpoint, go to the Testing tab, and use Send Example for each subscribed event type. Confirm success in the Logs tab.

Verify delivery#

To read a field that you did not extract into a column, query the stored body:

Troubleshooting#

SymptomWhat to check
Connection refused or timed outHostname, port, firewall rules, and any cloud provider IP allowlist.
Authentication failedThe username and password, and whether that user is allowed to connect to the selected database.
Permission denied on insertThe user needs USAGE on the schema and INSERT on the destination table.
Relation does not existThe table must exist before the endpoint is enabled, and an unqualified name resolves through the user’s search_path.
Column or type errorCompare the transformed output in Logs with the table definition. A TIMESTAMPTZ column needs a valid timestamp, and a NOT NULL column cannot receive null.
Subscriber or channel values are emptyMessage fields are under payload.data.object, not at the top level of payload. payload.object is the resource type string, such as "message".
Rows appear for some event types but not othersThe transformation assumes fields that only exist on certain event types. Guard each one with a default.
No rows after a successful deliveryConfirm the database, schema, and table you queried match the endpoint configuration.

Use the Logs tab to inspect transformed payloads and delivery attempts.

Official references#