← All guides

Secure V2 · SDK 0.3.0

PostgreSQL integration

Updated October 11, 2026 · verified against repository implementation

Verified TLS inserts into an existing customer-owned table.

Prepare the destination yourself

Run the following in your own database with appropriate administrative access. Struct does not create or alter customer tables. Give the integration user only CONNECT, schema USAGE, INSERT and the column SELECT permissions required by verification and idempotency. Use your actual role/database names. event_id must be a non-partial single-column unique or primary key.

CREATE TABLE public.struct_events (
  event_id uuid PRIMARY KEY,
  device_id uuid NOT NULL,
  received_at timestamptz NOT NULL,
  payload jsonb NOT NULL
);
GRANT CONNECT ON DATABASE telemetry TO struct_writer;
GRANT USAGE ON SCHEMA public TO struct_writer;
GRANT INSERT, SELECT ON public.struct_events TO struct_writer;

Connection and mapping

Enter a public host, port, database, schema, table, username/password and optionally a PEM CA certificate. TLS verification cannot be disabled. Private addresses and arbitrary connection strings are rejected; private connectivity is not implemented. Each connection validates DNS and pins the IP while verifying the original hostname. A bounded pool allows one connection per configuration with a process-wide maximum of 32 pools.

Inserts use fixed parameterized SQL with validated identifiers. Mapping controls the JSON payload column, not arbitrary SQL expressions or arbitrary database columns. event_id, device_id and received_at columns come from stable source metadata. ON CONFLICT(event_id) DO NOTHING treats an existing event as idempotent acceptance; Struct does not overwrite it. Different integrations writing the same table intentionally deduplicate by event ID.

Verification and failure recovery

Basic verification checks the TLS connection, target columns, INSERT privilege and unique event key without inserting a reading. Explicit test-send performs a synthetic insert. A successful autocommitted insert, or an already-existing event ID, is reported as accepted. Network/timeout/outage errors retry; deterministic SQL schema/permission/value errors are terminal. Fix the table/credentials and retry while the source payload remains available. Statement and query timeouts bound operations.

Open device setup · Contact support