> ## Documentation Index
> Fetch the complete documentation index at: https://sequinstream.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update database

> Update an existing Postgres database connection and optionally its replication slot.

### Path parameters

<ParamField path="id_or_name" type="string" required>
  The database ID or name to update
</ParamField>

### Request body

<Note>
  For updates, the `replication_slots` array is optional. If provided, it must contain a single replication slot object. If you include a replication slot, it must have an `id` field to identify which slot to update.
</Note>

<ParamField body="name" type="string">
  A name for this database connection. You can use this name to identify the database across the API.
</ParamField>

<ParamField body="url" type="string">
  The full connection URL for the database, e.g. `postgresql://postgres:secret-password@db.example.com:5432/postgres`.

  Pass in either this parameter or `database`, `hostname`, `port`, `username`, `password`.

  To specify SSL, use the separate `ssl` field.
</ParamField>

<ParamField body="hostname" type="string">
  The database server hostname.
</ParamField>

<ParamField body="database" type="string">
  The name of the logical database in Postgres.
</ParamField>

<ParamField body="username" type="string">
  The database username.
</ParamField>

<ParamField body="password" type="string">
  The database password.
</ParamField>

<ParamField body="port" type="integer">
  The database server port.
</ParamField>

<ParamField body="ssl" type="boolean">
  Whether to use SSL for the connection.
</ParamField>

<ParamField body="ipv6" type="boolean">
  Whether to use IPv6 for the connection.
</ParamField>

<ParamField body="primary" type="object">
  Connection details for the primary database, only needed when connecting to a replica.

  <Expandable title="primary properties">
    <ParamField body="hostname" type="string" required>
      The primary database server hostname.
    </ParamField>

    <ParamField body="database" type="string" required>
      The name of the logical database in the primary Postgres instance.
    </ParamField>

    <ParamField body="username" type="string" required>
      The primary database username.
    </ParamField>

    <ParamField body="password" type="string" required>
      The primary database password.
    </ParamField>

    <ParamField body="port" type="integer">
      The primary database server port. Defaults to `5432`.
    </ParamField>

    <ParamField body="ssl" type="boolean">
      Whether to use SSL for the primary connection. Defaults to `true`.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="annotations" type="object">
  Optional metadata as key-value pairs.
</ParamField>

<ParamField body="replication_slots" type="array">
  <Expandable title="properties" defaultOpen={true}>
    <ParamField body="id" type="string" required>
      The ID of the replication slot to update.
    </ParamField>

    <ParamField body="publication_name" type="string">
      The name of the publication to use for this replication slot.
    </ParamField>

    <ParamField body="slot_name" type="string">
      The name of the replication slot.
    </ParamField>

    <ParamField body="status" type="string">
      The replication slot status. Possible values: "active", "disabled".
    </ParamField>
  </Expandable>
</ParamField>

### Response

<Expandable title="properties" defaultOpen={false}>
  <ResponseField name="id" type="string (uuid)">
    The ID of the database connection.
  </ResponseField>

  <ResponseField name="name" type="string">
    The user-defined name for the database connection.
  </ResponseField>

  <ResponseField name="hostname" type="string">
    The hostname of the database server.
  </ResponseField>

  <ResponseField name="port" type="integer">
    The port number for the database connection.
  </ResponseField>

  <ResponseField name="database" type="string">
    The name of the logical Postgres database to connect to.
  </ResponseField>

  <ResponseField name="username" type="string">
    The username for authenticating with the database.
  </ResponseField>

  <ResponseField name="password" type="string">
    The password for authenticating with the database. This will be obfuscated unless `show_sensitive=true` is used.
  </ResponseField>

  <ResponseField name="ssl" type="boolean">
    Indicates whether SSL is enabled for the connection.
  </ResponseField>

  <ResponseField name="ipv6" type="boolean">
    Indicates whether the hostname resolves to an IPv6 address.
  </ResponseField>

  <ResponseField name="use_local_tunnel" type="boolean">
    Indicates whether this database connection uses the [Sequin local tunnel](/reference/cli#tunnel-sequin-cloud-only).
  </ResponseField>

  <ResponseField name="pool_size" type="integer">
    Database connection pool size (internal setting).
  </ResponseField>

  <ResponseField name="queue_interval" type="integer">
    Database connection pool queue interval (internal setting).
  </ResponseField>

  <ResponseField name="queue_target" type="integer">
    Database connection pool queue target (internal setting).
  </ResponseField>

  <ResponseField name="replication_slots" type="array">
    Details about the associated replication slot. Will be an empty array if no slot exists.

    <Expandable title="properties" defaultOpen={true}>
      <ResponseField name="id" type="string (uuid)">
        The ID of the replication slot.
      </ResponseField>

      <ResponseField name="publication_name" type="string">
        The name of the Postgres publication used for replication.
      </ResponseField>

      <ResponseField name="slot_name" type="string">
        The name of the Postgres replication slot.
      </ResponseField>

      <ResponseField name="status" type="string (enum: active | disabled)">
        The current status of the replication slot.
      </ResponseField>
    </Expandable>
  </ResponseField>
</Expandable>

<RequestExample>
  ```bash Using URL theme={null}
  curl --request PUT \
    --url https://api.sequinstream.com/api/postgres_databases/example-db \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --data '{
      "name": "example-db-renamed",
      "url": "postgresql://postgres:secret-password@new-db.example.com:5432/postgres"
    }'
  ```

  ```bash Updating database and replication slot theme={null}
  curl --request PUT \
    --url https://api.sequinstream.com/api/postgres_databases/example-db \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --data '{
      "name": "example-db-renamed",
      "hostname": "new-db.example.com",
      "replication_slots": [
        {
          "id": "rs_01HRMW3ZNE5EFGW9SDXW01TT93",
          "publication_name": "new_sequin_pub",
          "slot_name": "new_sequin_slot"
        }
      ]
    }'
  ```

  ```bash Using connection params theme={null}
  curl --request PUT \
    --url https://api.sequinstream.com/api/postgres_databases/example-db \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --data '{
      "name": "example-db-renamed",
      "hostname": "new-db.example.com"
    }'
  ```

  ```bash Updating replica connection theme={null}
  curl --request PUT \
    --url https://api.sequinstream.com/api/postgres_databases/replica-db \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --data '{
      "name": "replica-db-renamed",
      "hostname": "new-replica.example.com",
      "primary": {
        "hostname": "new-primary.example.com"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "id": "db_01HRMW3ZNE5EFGW9SDXW01TT92",
    "name": "example-db-renamed",
    "hostname": "new-db.example.com",
    "database": "postgres",
    "username": "postgres",
    "password": "************",
    "port": 5432,
    "ssl": true,
    "use_local_tunnel": false,
    "ipv6": false,
    "replication_slots": [
      {
        "id": "rs_01HRMW3ZNE5EFGW9SDXW01TT93",
        "publication_name": "new_sequin_pub",
        "slot_name": "new_sequin_slot",
        "status": "active"
      }
    ]
  }
  ```
</ResponseExample>
