# PostgreSQL Destination Config Reference


> Complete Rudder CLI reference for the PostgreSQL destination config keys, SSL modes, object storage providers, sync scheduling, and secrets.



[PostgreSQL](https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/) is a warehouse destination. RudderStack stages events as files in object storage, then loads them into a PostgreSQL database on a schedule.

In a PostgreSQL destination spec:

- `type: postgres`
- `definition_version: 1`

## Sample configuration

```yaml
version: rudder/v1
kind: destination
metadata:
  name: postgres-prod
spec:
  id: postgres-prod
  display_name: PostgreSQL Production
  type: postgres
  definition_version: 1
  enabled: true
  config:
    host: db.example.com
    port: "5432"
    database: analytics
    user: "{{ .PG_USER }}"
    password: "{{ .PG_PASSWORD }}"
    namespace: rudder_events

    ssl_mode: require
    use_ssh: false

    use_rudder_storage: false
    bucket_provider: S3
    bucket_name: acme-postgres-staging
    s3:
      role_based_auth: true
      iam_role_arn: "arn:aws:iam::123456789012:role/RudderStackS3"
    cleanup_object_storage_files: false

    sync_frequency: "180"
    sync_start_at: "01:00"
    exclude_window:
      start_time: "02:00"
      end_time: "03:00"

    prefer_append: true
    skip_users_table: true
    skip_tracks_table: false
    json_paths: context.traits,properties.metadata

    underscore_divide_numbers: false
    allow_users_context_traits: false

    connection_mode:
      web: cloud
      cloud: cloud
    consent_management:
      web:
        - provider: oneTrust
          consents:
            - analytics
```

The above example stages files in your own S3 bucket through an IAM role, so it carries no access keys, and uses `require`, so it needs no certificates. Which keys apply depends on several switches — see [Key dependencies](#key-dependencies).

## Config keys

`config` accepts only the keys listed below. The [shared config key rules](https://www.rudderstack.com/docs/rudder-cli/destination-types/#config-key-rules) cover unknown keys, defaults, and immutability.

**Info:** PostgreSQL&#39;s string keys don&#39;t accept `{{ path || fallback }}` templates as a way around their constraints — a template is measured as literal text against the same rule. Use `{{ .VAR }}` substitution for the secret keys.

### Key dependencies

`ssl_mode`, `use_ssh`, `use_rudder_storage`, and `bucket_provider` decide which other keys apply. Rudder CLI enforces every requirement below; a key outside its branch is accepted and ignored.

| Key | Required when |
| :-----| :-----|
| `client_key`, `client_cert`, `server_ca` | `ssl_mode` is `verify-ca` |
| `ssh` (all four fields) | `use_ssh` is `true` |
| `bucket_provider` | `use_rudder_storage` is `false` |
| `bucket_name` | `use_rudder_storage` is `false` and `bucket_provider` isn't `AZURE_BLOB` |
| `s3.iam_role_arn` | `bucket_provider` is `S3` and `s3.role_based_auth` is `true` |
| `access_key_id`, `s3.access_key` | `bucket_provider` is `S3` and `s3.role_based_auth` isn't `true` |
| `gcs.credentials` | `bucket_provider` is `GCS` |
| `azure.account_name`, `azure.container_name` | `bucket_provider` is `AZURE_BLOB` |
| `azure.account_key` | `bucket_provider` is `AZURE_BLOB` and `azure.use_sas_tokens` isn't `true` |
| `azure.sas_token` | `bucket_provider` is `AZURE_BLOB` and `azure.use_sas_tokens` is `true` |
| `access_key_id`, `minio.end_point`, `minio.secret_access_key`, `minio.use_ssl` | `bucket_provider` is `MINIO` |

Every storage requirement also assumes `use_rudder_storage` is `false`.

**Warning**

Three provider settings behave differently from the dashboard, which defaults them:

- An omitted `s3.role_based_auth` counts as `false`, so Rudder CLI asks for access keys. Write `role_based_auth: true` to use `s3.iam_role_arn`.
- An omitted `azure.use_sas_tokens` counts as `false`, so Rudder CLI asks for `azure.account_key`.
- `minio.use_ssl` must be written out. The dashboard defaults it to `true`; a spec that omits it fails validation.

### Connection

<div class="rs-ckeys">
<div class="rs-ckey" id="host">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">host</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Hostname of the PostgreSQL server.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>1 to 200 characters, and must not contain line breaks.</li>
<li>An <code>ngrok.io</code> host is rejected.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="port">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">port</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Port of the PostgreSQL server, written as a string — <code>&quot;5432&quot;</code>, not <code>5432</code>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>At most 100 characters, and must not contain line breaks.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="database">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">database</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Name of the database RudderStack loads data into.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>At most 100 characters, and must not contain line breaks.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="user">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">user</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Database user with the permissions RudderStack needs to create schemas and load tables.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>At most 100 characters, and must not contain line breaks.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/#setting-user-permissions-in-postgresql" >Setting user permissions in PostgreSQL</a>.
</div>

</div>

<div class="rs-ckey" id="password">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">password</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Password for <code>user</code>.
</p>

<div class="rs-ckey__extra">
  Supply it as a <code>{{ .VAR }}</code> reference rather than a literal — see <a href="#secrets" >Secrets</a>.
</div>

</div>

<div class="rs-ckey" id="namespace">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">namespace</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Schema RudderStack creates its tables in. Defaults to the source name when omitted.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>At most 64 characters, and must not start with <code>pg_</code> in any capitalization.</li>
<li>The PostgreSQL setup guide says the namespace can&rsquo;t be changed later, so treat it as fixed. It isn&rsquo;t marked immutable in the API schema, so a change isn&rsquo;t rejected.</li>
</ul>

</div>

</div>

</div>

### TLS

<div class="rs-ckeys">
<div class="rs-ckey" id="ssl_mode">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">ssl_mode</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  How RudderStack secures its connection to the server.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>disable</code> — no encryption.</li>
<li><code>require</code> — encrypted, without verifying the server.</li>
<li><code>verify-ca</code> — encrypted, and the server&rsquo;s certificate is checked against <code>server_ca</code>. Needs all three certificate keys below.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/#ssl-modes" >SSL modes</a>.
</div>

</div>

<div class="rs-ckey" id="client_key">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">client_key</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Contents of the client key PEM file.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>ssl_mode</code> is <code>verify-ca</code>. Leave it unset otherwise.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="client_cert">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">client_cert</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Contents of the client certificate PEM file.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>ssl_mode</code> is <code>verify-ca</code>. Leave it unset otherwise.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="server_ca">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">server_ca</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Contents of the server CA PEM file.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>ssl_mode</code> is <code>verify-ca</code>. Leave it unset otherwise.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/#using-verify-ca-to-configure-postgresql-destination" >Using verify-ca to configure PostgreSQL destination</a> for how to obtain the three files.
</div>

</div>

</div>

### SSH tunnel

**Info:** SSH tunneling is available on the Enterprise plan. See [SSH connection](https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/#ssh-connection).

<div class="rs-ckeys">
<div class="rs-ckey" id="use_ssh">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">use_ssh</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Connect to PostgreSQL through an SSH tunnel via a bastion host.
</p>

</div>

<div class="rs-ckey" id="ssh">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">ssh</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Bastion host connection details.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_ssh</code> is <code>true</code>, with all four fields. Leave it unset otherwise.</li>
<li><code>host</code> — IP address or hostname of the bastion host. At most 100 characters.</li>
<li><code>port</code> — SSH port of the bastion host, as a string. At most 100 characters.</li>
<li><code>user</code> — user RudderStack logs in to the bastion host as. At most 100 characters. <strong>Secret</strong> — see <a href="#secrets" >Secrets</a>.</li>
<li><code>public_key</code> — the public key RudderStack generates for this destination. At most 1000 characters.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">use_ssh: true
ssh:
  host: 203.0.113.10
  port: &#34;22&#34;
  user: &#34;{{ .PG_SSH_USER }}&#34;
  public_key: &#34;ssh-rsa AAAA...&#34;</code></pre></div>
</div><p>RudderStack holds the private key; add <code>public_key</code> to the bastion host&rsquo;s <code>authorized_keys</code>. The key comes from RudderStack, so the practical route is to enable SSH on the destination in the dashboard, then <a href="https://www.rudderstack.com/docs/rudder-cli/import-resources/" >import</a> it to pick up the value.</p>
</div>

</div>

</div>

### Object storage

`use_rudder_storage` decides whether RudderStack stages files in its own storage or in yours. With your own, `bucket_provider` picks the provider, and only that provider's block applies.

<div class="rs-ckeys">
<div class="rs-ckey" id="use_rudder_storage">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">use_rudder_storage</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Stage files in RudderStack-managed object storage instead of your own.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Available only on RudderStack-hosted data planes. Self-hosted data planes must set <code>false</code> and configure a provider.</li>
<li>The dashboard defaults this field to <code>false</code>. Rudder CLI requires it explicitly.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="bucket_provider">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">bucket_provider</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Object storage provider for staging files.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_rudder_storage</code> is <code>false</code>. Leave it unset otherwise.</li>
<li>One of <code>S3</code>, <code>GCS</code>, <code>AZURE_BLOB</code>, or <code>MINIO</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="bucket_name">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">bucket_name</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Name of the staging bucket. The bucket must already exist. Azure uses <code>azure.container_name</code> instead.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_rudder_storage</code> is <code>false</code> and <code>bucket_provider</code> isn&rsquo;t <code>AZURE_BLOB</code>. Leave it unset otherwise.</li>
<li>3 to 63 characters, whichever provider you use, and must not contain line breaks.</li>
<li>For <code>S3</code>: lowercase letters, digits, dots, and hyphens; not starting with <code>xn--</code>, no consecutive dots, not an IP address.</li>
<li>For <code>GCS</code>: lowercase letters, digits, dots, hyphens, and underscores; not starting with <code>goog</code>, not containing <code>google</code>, no consecutive dots, not an IP address.</li>
<li>For <code>MINIO</code>: lowercase letters, digits, dots, and hyphens; not an IP address.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="access_key_id">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">access_key_id</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Access key ID for S3 or MinIO. It sits at the top level because both providers use it.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>bucket_provider</code> is <code>MINIO</code>, or <code>S3</code> with <code>s3.role_based_auth</code> not <code>true</code>. Leave it unset otherwise.</li>
<li>At most 100 characters, and must not contain line breaks.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="cleanup_object_storage_files">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">cleanup_object_storage_files</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Delete staged files after a sync completes successfully.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Applies when <code>use_rudder_storage</code> is <code>false</code>.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="s3">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">s3</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Amazon S3 settings.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_rudder_storage</code> is <code>false</code> and <code>bucket_provider</code> is <code>S3</code>. Leave it unset otherwise.</li>
<li><code>role_based_auth</code> — boolean. <code>true</code> to use <code>iam_role_arn</code>; omitted or <code>false</code> to use <code>access_key_id</code> and <code>access_key</code>.</li>
<li><code>iam_role_arn</code> — ARN of the IAM role RudderStack assumes. Required when <code>role_based_auth</code> is <code>true</code>. At most 100 characters.</li>
<li><code>access_key</code> — AWS secret access key matching <code>access_key_id</code>. Required when <code>role_based_auth</code> isn&rsquo;t <code>true</code>. At most 100 characters. <strong>Secret</strong>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">bucket_provider: S3
bucket_name: acme-postgres-staging
s3:
  role_based_auth: true
  iam_role_arn: &#34;arn:aws:iam::123456789012:role/RudderStackS3&#34;</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="gcs">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">gcs</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Google Cloud Storage settings.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_rudder_storage</code> is <code>false</code> and <code>bucket_provider</code> is <code>GCS</code>. Leave it unset otherwise.</li>
<li><code>credentials</code> — contents of the JSON key file for a service account that can create objects in the bucket. Required. <strong>Secret</strong>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">bucket_provider: GCS
bucket_name: acme-postgres-staging
gcs:
  credentials: &#39;{{ .PG_GCS_CREDENTIALS }}&#39;</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="azure">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">azure</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Azure Blob Storage settings.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_rudder_storage</code> is <code>false</code> and <code>bucket_provider</code> is <code>AZURE_BLOB</code>. Leave it unset otherwise.</li>
<li><code>account_name</code> — storage account name. Required. At most 100 characters.</li>
<li><code>container_name</code> — staging container, which must already exist. Required. 3 to 63 characters of lowercase letters, digits, and single hyphens.</li>
<li><code>use_sas_tokens</code> — boolean. <code>true</code> to authenticate with <code>sas_token</code>; omitted or <code>false</code> to use <code>account_key</code>.</li>
<li><code>account_key</code> — storage account key. Required when <code>use_sas_tokens</code> isn&rsquo;t <code>true</code>. At most 100 characters. <strong>Secret</strong>.</li>
<li><code>sas_token</code> — shared access signature token. Required when <code>use_sas_tokens</code> is <code>true</code>. <strong>Secret</strong>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">bucket_provider: AZURE_BLOB
azure:
  account_name: acmestorage
  container_name: rudder-staging
  use_sas_tokens: true
  sas_token: &#34;{{ .PG_AZURE_SAS_TOKEN }}&#34;</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="minio">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">minio</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  MinIO settings. The access key ID goes in the top-level <code>access_key_id</code>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Required when <code>use_rudder_storage</code> is <code>false</code> and <code>bucket_provider</code> is <code>MINIO</code>. Leave it unset otherwise.</li>
<li><code>end_point</code> — MinIO server endpoint. Required. 1 to 100 characters; an <code>ngrok.io</code> endpoint is rejected.</li>
<li><code>secret_access_key</code> — MinIO secret access key. Required. At most 100 characters. <strong>Secret</strong>.</li>
<li><code>use_ssl</code> — boolean. Connect to MinIO over TLS. Required, even when <code>true</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">bucket_provider: MINIO
bucket_name: rudder-staging
access_key_id: &#34;{{ .MINIO_ACCESS_KEY_ID }}&#34;
minio:
  end_point: minio.example.com:9000
  secret_access_key: &#34;{{ .MINIO_SECRET_ACCESS_KEY }}&#34;
  use_ssl: true</code></pre></div>
</div>
</div>

</div>

</div>

### Sync scheduling

<div class="rs-ckeys">
<div class="rs-ckey" id="sync_frequency">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">sync_frequency</p>Required</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  How often RudderStack syncs staged events into PostgreSQL, in minutes. Written as a string, not a number.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>One of <code>5</code>, <code>10</code>, <code>15</code>, <code>30</code>, <code>60</code>, <code>180</code>, <code>360</code>, <code>720</code>, or <code>1440</code>.</li>
<li>The dashboard defaults this field to <code>180</code>. Rudder CLI requires it explicitly.</li>
<li>A spec that omits this key fails validation.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="sync_start_at">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">sync_start_at</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Time of day, in UTC, that anchors the sync schedule. Subsequent syncs are computed from it at <code>sync_frequency</code> intervals. Written as <code>HH:MM</code>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Not validated locally: any string is accepted, and a value the scheduler can&rsquo;t parse silently yields no scheduled times.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="exclude_window">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">exclude_window</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Daily window, in UTC, during which RudderStack doesn&rsquo;t sync. Omit the block entirely to sync around the clock.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>When present, both fields are required: <code>start_time</code> and <code>end_time</code>, each <code>HH:MM</code>.</li>
<li>Neither field&rsquo;s format is validated locally.</li>
</ul>

</div>

</div>

</div>

### Table behavior

<div class="rs-ckeys">
<div class="rs-ckey" id="prefer_append">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">prefer_append</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>true</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Append incoming events to existing tables. Set it to <code>false</code> to merge instead, which guarantees no duplicates at the cost of noticeably longer syncs. This is what the dashboard calls <strong>Warehouse Append</strong>.
</p>

</div>

<div class="rs-ckey" id="skip_users_table">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">skip_users_table</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>true</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Send <code>identify</code> events only to the <code>identifies</code> table, skipping the <code>users</code> table. The <code>users</code> table holds one row per unique user and is maintained with a merge, which can add significant time to each sync.
</p>

</div>

<div class="rs-ckey" id="skip_tracks_table">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">skip_tracks_table</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Skip sending events to the <code>tracks</code> table. Per-event tables are unaffected.
</p>

</div>

<div class="rs-ckey" id="json_paths">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">json_paths</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Comma-separated dot-notation paths whose values are stored as JSON columns instead of being flattened. Applies to every <code>track</code> event sent to this destination.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Not validated locally.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/json-column-support/" >JSON Column Support</a>.
</div>

</div>

</div>

### Legacy column naming

Both keys below preserve the column naming of destinations created before the behavior changed. Leave them at their defaults on a new destination. Neither can be changed once the destination exists — the API rejects the update.

<div class="rs-ckeys">
<div class="rs-ckey" id="underscore_divide_numbers">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">underscore_divide_numbers</p>ImmutableInternal</div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  When <code>false</code>, numeric suffixes in column names are preserved: <code>v3</code> stays <code>v3</code> rather than being split into <code>v_3</code>.
</p>

</div>

<div class="rs-ckey" id="allow_users_context_traits">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">allow_users_context_traits</p>ImmutableInternal</div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  When <code>false</code>, <code>context.traits.*</code> fields aren&rsquo;t promoted to top-level traits and are stored only as <code>context_traits_*</code> columns.
</p>

</div>

</div>

### Per-source keys

Both keys are objects keyed by the local source type — the tokens listed under [Source types](#source-types). A key naming a source type this destination doesn't support fails validation.

<div class="rs-ckeys">
<div class="rs-ckey" id="connection_mode">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">connection_mode</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps each source type you connect to the mode its events reach PostgreSQL in, using the modes in <a href="#source-types" >Source types</a>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>An entry is required for each source type you connect — see <a href="#connect-a-source" >Connect a source</a>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">connection_mode:
  web: cloud
  cloud: cloud</code></pre></div>
</div>
</div>

</div>

<div class="rs-ckey" id="consent_management">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">consent_management</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Consent provider configuration per source type. The entry shape, accepted providers, and the rules on <code>resolution_strategy</code> and <code>consents</code> are shared across all destination types — see <a href="https://www.rudderstack.com/docs/rudder-cli/destination-types/#consent-management" >Consent management</a>.
</p>

</div>

</div>

## Source types

PostgreSQL accepts events from these source types in the mentioned connection modes:

| Source type | Connection mode |
| :-----| :-----|
| `android` | `cloud` |
| `android_kotlin` | `cloud` |
| `ios` | `cloud` |
| `ios_swift` | `cloud` |
| `web` | `cloud` |
| `unity` | `cloud` |
| `cloud` | `cloud` |
| `react_native` | `cloud` |
| `flutter` | `cloud` |
| `cordova` | `cloud` |

Every source type is `cloud` only — events reach the warehouse from RudderStack's servers, never in device mode.

**Info:** The dashboard additionally offers PostgreSQL to AMP, Shopify, and cloud app sources. Rudder CLI doesn&#39;t manage those connections, so `amp`, `shopify`, and `cloud_source` are invalid here.

## Connect a source

An event stream connection to this destination is checked against two rules at `validate` time.

**The source's type must be supported.** A source's type resolves to one of the tokens above before the check — a JavaScript source resolves to `web`, and webhook and server-side SDK sources resolve to `cloud`. Every type an event stream source can resolve to is supported here, so this check always passes.

**The destination config must carry a `connection_mode` entry for that source type.** This lives on the destination spec, not on the [connection spec](https://www.rudderstack.com/docs/rudder-cli/yaml-connections/). Without it:

```text
destination 'postgres-prod' config has no 'connection_mode' entry for source type 'web'
```

PostgreSQL needs no additional config keys to connect a source of any type.

## Secrets

Rudder CLI treats eleven keys as secrets: `user`, `password`, `client_key`, `client_cert`, `access_key_id`, `s3.access_key`, `gcs.credentials`, `azure.account_key`, `azure.sas_token`, `minio.secret_access_key`, and `ssh.user`. Write each one you use as a `{{ .VAR }}` reference and supply the value at apply time:

```yaml
config:
  user: "{{ .PG_USER }}"
  password: "{{ .PG_PASSWORD }}"
```

```bash
export RUDDER_PG_USER="rudder"
export RUDDER_PG_PASSWORD="..."
rudder-cli apply

# or
rudder-cli apply --var-file secrets.vars.yaml
```

Note that:

- `gcs.credentials` is JSON, so write its reference in single quotes: `credentials: '{{ .PG_GCS_CREDENTIALS }}'`.
- `client_key` and `client_cert` span several lines. In a var file, write each as a YAML literal block. A reference that is the whole quoted value, such as `'{{ .PG_CLIENT_KEY }}'`, keeps the line breaks in either quote style, including the single-quoted references `rudder-cli import` writes. An environment variable can carry a file's contents directly: `export RUDDER_PG_CLIENT_KEY="$(cat client-key.pem)"`.
- `server_ca` isn't a secret — a CA certificate is public by design.
- `rudder-cli import` writes only the secrets the API returns, as `{{ .VAR }}` references, and leaves the others out. Add any secret key it leaves out, then supply the variables before you apply — see [Secrets](https://www.rudderstack.com/docs/rudder-cli/destination-types/#secrets).

See [How to Use Variable Substitution in Rudder CLI](https://www.rudderstack.com/docs/rudder-cli/variable-substitution/).

## Changes by release

<table>
  <thead>
    <tr>
      <th>Version</th>
      <th>Change</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>v0.29.0</td>
      <td><strong>Breaking:</strong> A <code>null</code> config value, written as <code>key: null</code>, <code>key: ~</code>, or <code>key:</code> with no value, fails <code>validate</code> with <code>'&lt;key&gt;' must not be null; set a value or remove the key</code>. Earlier releases accepted it: a top-level null planned an update on every <code>apply</code>, and a null inside a list item failed at the API.<br><strong>What to do:</strong> Remove the key to leave it unset, or give it a value.</td>
    </tr>
    <tr>
      <td>v0.29.0</td>
      <td><strong>Breaking:</strong> An empty string, <code>&quot;&quot;</code>, on a key that takes one of a fixed set of values fails <code>validate</code> with <code>'&lt;key&gt;' must be one of [...]</code>, unless <code>&quot;&quot;</code> is one of the key&rsquo;s values. Earlier releases accepted it, and the API rejected it at <code>apply</code>.<br><strong>What to do:</strong> Remove the key to leave it unset, or set one of the listed values.</td>
    </tr>
    <tr>
      <td>v0.29.0</td>
      <td><strong>Changed:</strong> <code>validate</code> warns when a secret key holds anything but one <code>{{ .VAR }}</code> reference with no default, and when one variable fills two secret keys. It also masks secret values in the lines it prints.</td>
    </tr>
    <tr>
      <td>v0.29.0</td>
      <td><strong>Changed:</strong> <code>rudder-cli import</code> writes each secret reference single-quoted, as <code>'{{ .VAR }}'</code>, so a value containing double quotes, like a JSON key file, substitutes as a string. A single quote in a value that fills such a reference is written as <code>''</code>.<br><strong>What to do:</strong> In a spec imported by an earlier release, quote each reference to a JSON value by hand: <code>'{{ .VAR }}'</code>.</td>
    </tr>
    <tr>
      <td>v0.29.0</td>
      <td><strong>Changed:</strong> A multi-line value, like a PEM key, keeps its line breaks when it fills a quoted <code>{{ .VAR }}</code> reference, in either quote style. Earlier releases folded the line breaks into spaces, so the destination stored a broken key unless the value was written with <code>\n</code> in a double-quoted reference. That form still works.</td>
    </tr>
    <tr>
      <td>v0.29.0</td>
      <td><strong>Changed:</strong> <code>validate</code> reports a value of the wrong type once per key, such as <code>'email' must be a string</code>, instead of one raw decoding error.</td>
    </tr>
  </tbody>
</table>

For changes across every destination type, see [Destination Type Changes by Release](https://www.rudderstack.com/docs/rudder-cli/destination-types/changes/).

## See more

- [PostgreSQL Destination](https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/) for user permissions, SSL modes, and IPs to allowlist
- [Destination Type Reference for Rudder CLI](https://www.rudderstack.com/docs/rudder-cli/destination-types/) for the rules shared across destination types
- [Destination YAML Reference](https://www.rudderstack.com/docs/rudder-cli/yaml-destinations/) for the spec envelope

