# Update PostgreSQL Replication Mode

With the `PATCH` request, you can update the replication mode of the PostgreSQL cluster.

{% hint style="warning" %}
**Note:**

* PostgreSQL deprecates `SYNCHRONOUS` replication mode for new clusters.
* You can update the existing clusters from `SYNCHRONOUS` mode to either `ASYNCHRONOUS` or\
  `STRICTLY_SYNCHRONOUS` using this API.
  {% endhint %}

## Which replication mode to choose?

* Use `ASYNCHRONOUS` when you prioritize write performance and can tolerate potential data loss on failover.
* Use `STRICTLY_SYNCHRONOUS` when data durability is critical, and you have at least 3 replicas.

## What are the potential impacts of switching replication modes?

* Switching to `ASYNCHRONOUS` from `SYNCHRONOUS` mode should not pose any downtime.
* If you are using an `ASYNCHRONOUS` or `SYNCHRONOUS` cluster with less than 3 replicas and you decide to switch to the `STRICTLY_SYNCHRONOUS` mode (which requires 3 replicas at least),
  * You might experience some time where the DB is read-only.
  * The downtime is because the replication mode on writes needs confirmation from at least one synchronous-standby, and the primary is not allowed to continue in the standalone mode. For more information, see [<mark style="color:blue;">Replication Mode</mark>](/cloud/databases/postgresql/overview/high-availability.md#replication-modes).

{% hint style="info" %}
**Important:** If you are switching to `STRICTLY_SYNCHRONOUS` mode, we recommend:

* Performing the replication mode switch outside of the critical business hours.
* You should first update to 3 replicas, wait for them to be ready, and only then change to `STRICTLY_SYNCHRONOUS` mode.
  {% endhint %}

## Endpoint

Use the following endpoint to update the replication mode for an existing PostgreSQL cluster:`https://api.ionos.com/databases/postgresql/clusters/{clusterId}`

{% hint style="info" %}
**Note:** The sample UUID is `498ae72f-411f-11eb-9d07-046c59cc737e`.
{% endhint %}

## Request

```bash
curl --include \
    --request PATCH \
    --user "clientname@ionos.com:xxxxxx" \
    --header "Content-Type: application/json" \
    --data-binary '{
      "metadata": {},
      "properties": {
        "synchronizationMode": "ASYNCHRONOUS"
      }
    }' \
    https://api.ionos.com/databases/postgresql/clusters/498ae72f-411f-11eb-9d07-046c59cc737e
```

## Response

```json
{
  "type": "cluster",
  "id": "498ae72f-411f-11eb-9d07-046c59cc737e",
  "metadata": {
    "state": "AVAILABLE",
    "createdDate": "2020-12-10T12:37:50.000Z",
    "createdBy": "clientname@ionos.com",
    "createdByUserId": "012342f-411f-1eeb-9d07-046c59cc737e",
    "lastModifiedDate": "2020-12-18T21:37:50.000Z",
    "lastModifiedBy": "clientname@ionos.com",
    "lastModifiedByUserId": "012342f-411f-1eeb-9d07-046c59cc737e"
  },
  "properties": {
        "displayName": "an even better name",
        "location": "de/txl",
        "dnsName": "pg-pgov71sjg1c875ji.postgresql.de-txl.ionos.com",
        "connections": [
            {
                "datacenterId": "db7e8811-cfae-4b40-82ee-2f4cff81e105",
                "lanId": "2",
                "cidr": "10.7.222.3/23"
            }
        ],
        "cores": 4,
        "postgresVersion": "15",
        "ram": 4096,
        "instances": 1,
        "storageSize": 102400,
        "storageType": "HDD",
        "maintenanceWindow": {
            "dayOfTheWeek": "Sunday",
            "time": "03:30:00"
        },
        "synchronizationMode": "ASYNCHRONOUS",
        "connectionPooler": {
            "enabled": false,
            "poolMode": "transaction"
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ionos.com/cloud/databases/postgresql/api/v1-api/modify-cluster-attributes/update-postgresql-replication-mode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
