# PostgreSQL Destination Config Reference

<p><a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/" >PostgreSQL</a> is a warehouse destination. RudderStack stages events as files in object storage, then loads them into a PostgreSQL database on a schedule.</p>
<p>In a PostgreSQL destination spec:</p>
<ul>
<li><code>type: postgres</code></li>
<li><code>definition_version: 1</code></li>
</ul>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="sample-configuration">Sample configuration</h2><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">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: &#34;5432&#34;
    database: analytics
    user: &#34;{{ .PG_USER }}&#34;
    password: &#34;{{ .PG_PASSWORD }}&#34;
    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: &#34;arn:aws:iam::123456789012:role/RudderStackS3&#34;
    cleanup_object_storage_files: false

    sync_frequency: &#34;180&#34;
    sync_start_at: &#34;01:00&#34;
    exclude_window:
      start_time: &#34;02:00&#34;
      end_time: &#34;03:00&#34;

    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</code></pre></div>
</div>
<p>The above example stages files in your own S3 bucket through an IAM role, so it carries no access keys, and uses <code>require</code>, so it needs no certificates. Which keys apply depends on several switches — see <a href="#key-dependencies" >Key dependencies</a>.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="config-keys">Config keys</h2><p><code>config</code> accepts only the keys listed below. The <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/destination-types/#config-key-rules" >shared config key rules</a> cover unknown keys, defaults, and immutability.</p>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">PostgreSQL&rsquo;s string keys don&rsquo;t accept <code>{{ path || fallback }}</code> templates as a way around their constraints — a template is measured as literal text against the same rule. Use <code>{{ .VAR }}</code> substitution for the secret keys.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="key-dependencies">Key dependencies</h3><p><code>ssl_mode</code>, <code>use_ssh</code>, <code>use_rudder_storage</code>, and <code>bucket_provider</code> decide which other keys apply. Rudder CLI enforces every requirement below; a key outside its branch is accepted and ignored.</p>
<table>
<thead>
<tr>
<th>Key</th>
<th>Required when</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>client_key</code>, <code>client_cert</code>, <code>server_ca</code></td>
<td><code>ssl_mode</code> is <code>verify-ca</code></td>
</tr>
<tr>
<td><code>ssh</code> (all four fields)</td>
<td><code>use_ssh</code> is <code>true</code></td>
</tr>
<tr>
<td><code>bucket_provider</code></td>
<td><code>use_rudder_storage</code> is <code>false</code></td>
</tr>
<tr>
<td><code>bucket_name</code></td>
<td><code>use_rudder_storage</code> is <code>false</code> and <code>bucket_provider</code> isn&rsquo;t <code>AZURE_BLOB</code></td>
</tr>
<tr>
<td><code>s3.iam_role_arn</code></td>
<td><code>bucket_provider</code> is <code>S3</code> and <code>s3.role_based_auth</code> is <code>true</code></td>
</tr>
<tr>
<td><code>access_key_id</code>, <code>s3.access_key</code></td>
<td><code>bucket_provider</code> is <code>S3</code> and <code>s3.role_based_auth</code> isn&rsquo;t <code>true</code></td>
</tr>
<tr>
<td><code>gcs.credentials</code></td>
<td><code>bucket_provider</code> is <code>GCS</code></td>
</tr>
<tr>
<td><code>azure.account_name</code>, <code>azure.container_name</code></td>
<td><code>bucket_provider</code> is <code>AZURE_BLOB</code></td>
</tr>
<tr>
<td><code>azure.account_key</code></td>
<td><code>bucket_provider</code> is <code>AZURE_BLOB</code> and <code>azure.use_sas_tokens</code> isn&rsquo;t <code>true</code></td>
</tr>
<tr>
<td><code>azure.sas_token</code></td>
<td><code>bucket_provider</code> is <code>AZURE_BLOB</code> and <code>azure.use_sas_tokens</code> is <code>true</code></td>
</tr>
<tr>
<td><code>access_key_id</code>, <code>minio.end_point</code>, <code>minio.secret_access_key</code>, <code>minio.use_ssl</code></td>
<td><code>bucket_provider</code> is <code>MINIO</code></td>
</tr>
</tbody>
</table>
<p>Every storage requirement also assumes <code>use_rudder_storage</code> is <code>false</code>.</p>

<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text"><p>Three provider settings behave differently from the dashboard, which defaults them:</p>
<ul>
<li>An omitted <code>s3.role_based_auth</code> counts as <code>false</code>, so Rudder CLI asks for access keys. Write <code>role_based_auth: true</code> to use <code>s3.iam_role_arn</code>.</li>
<li>An omitted <code>azure.use_sas_tokens</code> counts as <code>false</code>, so Rudder CLI asks for <code>azure.account_key</code>.</li>
<li><code>minio.use_ssl</code> must be written out. The dashboard defaults it to <code>true</code>; a spec that omits it fails validation.</li>
</ul>
</div>
  </div>
</blockquote>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="connection">Connection</h3><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>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="tls">TLS</h3><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>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="ssh-tunnel">SSH tunnel</h3>
<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">SSH tunneling is available on the Enterprise plan. See <a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/#ssh-connection" >SSH connection</a>.</div>
  </div>
</blockquote>

</html>
<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/dev-tools/rudder-cli/import-resources/" >import</a> it to pick up the value.</p>

</div>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="object-storage">Object storage</h3><p><code>use_rudder_storage</code> decides whether RudderStack stages files in its own storage or in yours. With your own, <code>bucket_provider</code> picks the provider, and only that provider&rsquo;s block applies.</p>
<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: &#34;{{ .PG_GCS_CREDENTIALS }}&#34;</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>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="sync-scheduling">Sync scheduling</h3><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>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="table-behavior">Table behavior</h3><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>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="legacy-column-naming">Legacy column naming</h3><p>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.</p>
<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>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="per-source-keys">Per-source keys</h3><p>Both keys are objects keyed by the local source type — the tokens listed under <a href="#source-types" >Source types</a>. A key naming a source type this destination doesn&rsquo;t support fails validation.</p>
<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/dev-tools/rudder-cli/destination-types/#consent-management" >Consent management</a>.
</p>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="source-types">Source types</h2><p>PostgreSQL accepts events from these source types in the mentioned connection modes:</p>
<table>
<thead>
<tr>
<th>Source type</th>
<th>Connection mode</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>android</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>android_kotlin</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>ios</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>ios_swift</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>web</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>unity</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>cloud</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>react_native</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>flutter</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>cordova</code></td>
<td><code>cloud</code></td>
</tr>
</tbody>
</table>
<p>Every source type is <code>cloud</code> only — events reach the warehouse from RudderStack&rsquo;s servers, never in device mode.</p>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">The dashboard additionally offers PostgreSQL to AMP, Shopify, and cloud app sources. Rudder CLI doesn&rsquo;t manage those connections, so <code>amp</code>, <code>shopify</code>, and <code>cloud_source</code> are invalid here.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="connect-a-source">Connect a source</h2><p>An event stream connection to this destination is checked against two rules at <code>validate</code> time.</p>
<p><strong>The source&rsquo;s type must be supported.</strong> A source&rsquo;s type resolves to one of the tokens above before the check — a JavaScript source resolves to <code>web</code>, and webhook and server-side SDK sources resolve to <code>cloud</code>. An unsupported type reports:</p>
<div class="rs-code">
  <div class="rs-code__head"><button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-text" data-lang="text">destination &#39;postgres-prod&#39; (type &#39;postgres&#39;) does not support source &#39;my-source&#39;:
source type &#39;amp&#39; is not among supported source types: android, android_kotlin, ...</code></pre></div>
</div>
<p><strong>The destination config must carry a <code>connection_mode</code> entry for that source type.</strong> This lives on the destination spec, not on the <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/yaml-connections/" >connection spec</a>. Without it:</p>
<div class="rs-code">
  <div class="rs-code__head"><button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-text" data-lang="text">destination &#39;postgres-prod&#39; config has no &#39;connection_mode&#39; entry for source type &#39;web&#39;</code></pre></div>
</div>
<p>PostgreSQL needs no additional config keys to connect a source of any type.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="secrets">Secrets</h2><p>Rudder CLI treats eleven keys as secrets: <code>user</code>, <code>password</code>, <code>client_key</code>, <code>client_cert</code>, <code>access_key_id</code>, <code>s3.access_key</code>, <code>gcs.credentials</code>, <code>azure.account_key</code>, <code>azure.sas_token</code>, <code>minio.secret_access_key</code>, and <code>ssh.user</code>. Write each one you use as a <code>{{ .VAR }}</code> reference and supply the value at apply time:</p>
<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">config:
  user: &#34;{{ .PG_USER }}&#34;
  password: &#34;{{ .PG_PASSWORD }}&#34;</code></pre></div>
</div>
<div class="rs-code">
  <div class="rs-code__head">bash<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">export RUDDER_PG_USER=&#34;rudder&#34;
export RUDDER_PG_PASSWORD=&#34;...&#34;
rudder-cli apply

# or
rudder-cli apply --var-file secrets.vars.yaml</code></pre></div>
</div>
<p>Note that:</p>
<ul>
<li><code>server_ca</code> isn&rsquo;t a secret — a CA certificate is public by design.</li>
<li>The YAML that <code>rudder-cli import</code> writes may or may not include secret keys. Before you apply, make sure every secret key your configuration needs is present and populated through variable substitution.</li>
</ul>
<p>See <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/variable-substitution/" >How to Use Variable Substitution in Rudder CLI</a>.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="see-more">See more</h2><ul>
<li><a href="https://www.rudderstack.com/docs/destinations/warehouse-destinations/postgresql/" >PostgreSQL Destination</a> for user permissions, SSL modes, and IPs to allowlist</li>
<li><a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/destination-types/" >Destination Type Reference for Rudder CLI</a> for the rules shared across destination types</li>
<li><a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/yaml-destinations/" >Destination YAML Reference</a> for the spec envelope</li>
</ul>

