PostgreSQL
Start agents from PostgreSQL NOTIFY messages that a trigger or your application code sends.
On this page
| Modes | Inbound |
| YAML type | postgres |
| Credentials | A Connection of type postgres with the database address and login |
| Bridge | On the Connection, to reach a database in a private network |
| Custom domain | Not supported |
| Linked agents | One or more. A notification starts every linked agent. |
| While paused | connic stops listening. PostgreSQL doesn't keep notifications for a listener that isn't connected, so notifications sent during the pause are lost. |
| New connectors | Created paused in the dashboard, and through the REST API or connic MCP unless the request sets enabled: true. Start them with Resume. Connectors in code start active. |
Set up
Make the database reachable. Without a Bridge, its host must resolve only to public IP addresses. For a database in a private network, use a Bridge.
Create a database user with the
CONNECTpermission on the database. Receiving notifications needs no other permission.Open the agent. In Connector Flow, click Add inbound connector, then Create New Connector, and select PostgreSQL.
Under Connection, pick a saved Connection or create one with the database address and login; see Connection. If the database is in a private network, select the Bridge in the Connection. Enter the Notification Channel.
Click Create. The new connector is paused: click Resume in its details drawer to start listening. To reopen the drawer, hover over the connector in the flow and click the eye icon.
Send notifications on the channel from a trigger or from your application code.
In code
Declare the connector in connectors/*.yaml. The file names the Connection and never contains the database login. Connectors in code start active, so the connector starts listening when its first deploy goes live.
type: postgres
connection: app-db # Connection with the database address, login, and optional Bridge
config:
channel: new_customers
agents:
- customer-onboardingConfiguration
The fields of a PostgreSQL connector, the same in connectors/*.yaml, the REST API, and connic MCP. The descriptions name the matching setting in the dashboard. Connectors in code describes the fields every connector shares, such as agents and environments.
| Field | Type | Status | Description |
|---|---|---|---|
| type | string | Required | postgres. |
| connection | string | Required | Name or ID of a Connection of type postgres, which holds the database address, the login, and the Bridge. See Connection. Dashboard: Connection. |
| config | object | Required | PostgreSQL settings. |
| channel | string | Required | The channel to listen on, such as new_customers. Letters, digits, and underscores, not starting with a digit. connic stores it in lowercase. Dashboard: Notification Channel. |
| parse_json_payload | boolean | Optional | Parse each payload as JSON; see Agent input. Dashboard: Parse JSON Payload.Default: true |
Connection
A Connection of type postgres holds these fields. Every PostgreSQL connector in the project can use it, and a connector's config doesn't take them. Manage Connections in Project Settings → Connections or through the REST API.
| Field | Type | Status | Description |
|---|---|---|---|
| host | string | Required | Hostname or IP address of the database server. Dashboard: Host. |
| port | integer | Optional | Server port. Dashboard: Port.Default: 5432 |
| database | string | Required | Name of the database to connect to. Dashboard: Database. |
| username | string | Required | Database user. Dashboard: Username. |
| password | string | Required | Password of the database user. Secret. Dashboard: Password. |
| ssl_mode | string | Optional | disable connects without TLS. prefer uses TLS when the server supports it. require always uses TLS and verifies the server certificate and hostname. Dashboard: SSL Mode.Default: prefer |
| bridge | string | Optional | Name or ID of the Bridge that reaches a database in a private network. The REST API and connic MCP take it as the Connection's top-level bridge, not in config. Dashboard: Bridge. |
Every connector that uses the Connection goes through its Bridge. To use a different Bridge per environment, give each environment its own Connection; see Connections and Bridges. When you change the host, port, username, SSL mode, or Bridge of a saved Connection, enter the password again; connic refuses the change otherwise.
Send notifications
Every notification on the connector's channel starts runs. Send them from a trigger, so that each row change sends one, or from your application code. PostgreSQL delivers a notification when the sending transaction commits, and never for a transaction that rolls back.
From a trigger
This trigger sends a JSON object for each new row:
-- Send a notification for every new customer
CREATE OR REPLACE FUNCTION notify_new_customer()
RETURNS TRIGGER AS $$
BEGIN
PERFORM pg_notify(
'new_customers',
json_build_object(
'customer_id', NEW.id,
'email', NEW.email,
'company_name', NEW.company_name,
'created_at', NEW.created_at
)::text
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER customer_insert_trigger
AFTER INSERT ON customers
FOR EACH ROW
EXECUTE FUNCTION notify_new_customer();To report inserts and updates on one channel, include the operation:
-- Report inserts and updates, with the operation
CREATE OR REPLACE FUNCTION notify_customer_changes()
RETURNS TRIGGER AS $$
BEGIN
PERFORM pg_notify(
'customer_changes',
json_build_object(
'operation', TG_OP,
'customer_id', NEW.id,
'old_email', CASE WHEN TG_OP = 'UPDATE' THEN OLD.email ELSE NULL END,
'new_email', NEW.email,
'updated_at', NOW()
)::text
);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER customer_change_trigger
AFTER INSERT OR UPDATE ON customers
FOR EACH ROW
EXECUTE FUNCTION notify_customer_changes();From application code
SELECT pg_notify('new_customers', '{"customer_id": "12345", "action": "created"}');
-- or
NOTIFY new_customers, '{"customer_id": "12345", "action": "created"}';NOTIFY folds an unquoted channel name to lowercase, but pg_notify uses the name exactly as written. connic listens on the lowercase name, so pass it to pg_notify in lowercase.
Keep payloads small: PostgreSQL limits a payload to less than 8000 bytes. Send IDs and let the agent load the full record with a tool. Use a separate channel, with its own connector, for each type of event, such as orders_created and users_updated.
Agent input
Each notification becomes the input of every linked agent. With Parse JSON Payload on, the default, a JSON object keeps its fields, and connic adds the notification metadata under _postgres:
{
"customer_id": "12345",
"email": "customer@example.com",
"company_name": "Acme Corp",
"created_at": "2026-01-15T10:30:00",
"_postgres": {
"channel": "new_customers",
"pid": 48213,
"timestamp": "2026-01-15T10:30:00.123456"
}
}_postgres holds the channel, the pid of the database server process that sent the notification, and the timestamp when connic received it, in UTC.
Other JSON values, such as arrays or numbers, arrive under data. A payload that isn't valid JSON, and every payload while parsing is off, arrives as text under message.
Delivery
Each active connector keeps one database connection open and listens on its channel. Count these connections against the database's connection limit when you create several connectors. PostgreSQL sends a notification only to the listeners connected at that moment and doesn't store it.
Limits and errors
| Situation | What happens |
|---|---|
| A payload of 8000 bytes or more | PostgreSQL rejects the NOTIFY with an error in the sending transaction. |
| No agent is linked | connic records each notification as a connector run with No agents linked and starts no run. |
| Starting a run fails | connic records a failed connector run. The notification isn't delivered again. |
| The connection is lost | connic checks the connection every 30 seconds and reconnects with exponential backoff, from 5 seconds up to 2 minutes. Notifications sent in between are lost. |
| Wrong password, unknown database or role, or no pg_hba.conf entry | The listener stops and writes the error to the connector logs. It starts again when you update the connector or its Connection, or pause and resume it. |