Connect a PostgreSQL Database
This guide walks you through registering a PostgreSQL database as a data connection in CRAFT. Once connected, the database is available to solutions like Data Insights (for NL-to-SQL queries) and Data Governance (for profiling and enrichment).Prerequisites
Before you begin, ensure you have:
- A running CRAFT instance
- A valid JWT token with the
developeroradminrole - Network connectivity between the platform and your PostgreSQL instance
- A PostgreSQL user with read access to the target schemas
How Data Connections Work
Data connections are managed by the Assets service (reachable at/api/assets through the platform gateway). When you register a connection:
- The connection metadata (host, port, database name) is stored in the Assets database
- Credentials (username, password) are stored securely via the platform Secrets API (Infisical or ESO + GCP Secret Manager) — never in the Assets database
- Solutions retrieve the connection at runtime via the Assets SDK and use the credentials to establish a live database session
- All connections are scoped to an organization and project for multi-tenant isolation
Step 1: Prepare Your Database
Ensure your PostgreSQL instance is configured to accept connections from the platform.Configure network access
Update Reload the configuration:
pg_hba.conf to allow connections from the platform’s network:Step 2: Register the Data Connection
Use the Assets API to register the connection in the platform.201 Created with the resource:
- The platform constructs
resource_uriasdata:<org-id>:<project-id>:<name>(or a kebab-caseresource_urioverride if you supply one in the request). - The
credentialsfield is encrypted and stored via the platform Secrets API upon registration. It will not appear on subsequentGETresponses (useGET /assets/data/{resource_uri}/secretif a solution needs to read the credentials at runtime). - For object-storage connections (
s3,gcs,minio), usestorage_configinstead ofdatabase_config. For filesystem connections (nfs,smb), usefilesystem_config. The complete list of supportedconnection_typevalues isGET /api/assets/data/types.
Step 3: Test the Connection
Verify the platform can reach your database. There are two flavors of verify:POST /api/assets/data/verify with the same body shape as the
create request — no name/description needed:
success: false and a message describing the
failure mode (details and latency_ms may be null).
Step 4: Use the Connection with Data Insights
Once registered, the connection’sresource_uri (returned in Step 2) is
what you pass to other platform services. The Data Insights solution
consumes it from its chat UI / SDK; the underlying HTTP contract lives at
POST /api/talk2data/chat/messages (paired with /api/talk2data/chat/sessions
for session management — see the Data Insights › Text-to-SQL guide
for the full message-and-session model). The Data Insights UI handles
session creation implicitly when a user opens a new chat against this
connection.
Connection Configuration Reference
- PostgreSQL
- Credentials
| Parameter | Type | Required | Description |
|---|---|---|---|
host | string | Yes | Database hostname or IP |
port | integer | No | Port number (default: 5432) |
database | string | Yes | Database name |
schema | string | No | Default schema (default: public) |
ssl_mode | string | No | SSL mode: disable (no TLS) or require (TLS, encrypt-only). Default disable. |
Security Considerations
Credential Storage
Credential Storage
Credentials are stored via the platform Secrets API (backed by Infisical or ESO + GCP Secret Manager). They are encrypted at rest and organization-scoped. Credentials are injected at runtime only when a solution needs to establish a connection.
Network Security
Network Security
Configure your database firewall to accept connections only from the platform’s Kubernetes cluster CIDR. Use
ssl_mode: require for production deployments so traffic is TLS-encrypted between the platform and your database. Certificate-pinning modes (verify-ca, verify-full) are not currently accepted by the Assets API.Principle of Least Privilege
Principle of Least Privilege
Always create a dedicated read-only user for the platform. Never use a superuser or an account with write privileges unless the solution explicitly requires write access.
Troubleshooting
Connection test fails with timeout
Connection test fails with timeout
Verify network connectivity between the Kubernetes cluster and your database. Check firewall rules, security groups, and
pg_hba.conf configuration. Ensure the database host is resolvable from within the cluster.Authentication failure
Authentication failure
Confirm the username and password are correct. Check that the user exists in the target database and has the
CONNECT privilege. Verify the pg_hba.conf entry allows the authentication method being used.SSL connection required
SSL connection required
If your database requires SSL, set
ssl_mode: require. Certificate-pinning modes (verify-ca, verify-full) are not currently accepted by the Assets API — track this if your database requires server-cert verification at the client.Next Steps
Chat with Data
Learn how to ask natural-language questions against your connected database.
Data Profiling
Profile your connected database to understand data quality and structure.
Backup & Restore
Learn how to back up your platform data including connection configurations.
Network Security
Review network security policies for data connections.

