- [HTTP request](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#body.request_body)
- [Response body](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#body.aspect)
- [InstancesDemoteRequest](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#InstancesDemoteRequest)
  - [JSON representation](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#InstancesDemoteRequest.SCHEMA_REPRESENTATION)
- [DemoteContext](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#DemoteContext)
  - [JSON representation](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#DemoteContext.SCHEMA_REPRESENTATION)
- [Examples](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#examples)
- [Try it!](https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#try-it)

Demotes an existing standalone instance to be a Cloud SQL read replica for an external database server.

### HTTP request

`POST https://sqladmin.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/demote`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `project` | `string` Required. The project ID of the project that contains the instance. |
| `instance` | `string` Required. The name of the Cloud SQL instance. |

### Request body

The request body contains an instance of `https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#InstancesDemoteRequest`.

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/operations#Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloudsql`
- `
  https://www.googleapis.com/auth/cloud-platform`
- `
  https://www.googleapis.com/auth/sqlservice.admin`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

## InstancesDemoteRequest

This request is used to demote an existing standalone instance to be a Cloud SQL read replica for an external database server.

| JSON representation |
|---|
| ``` { "demoteContext": { object (`https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#DemoteContext`) } } ``` |

| Fields ||
|---|---|
| `demoteContext` | ``object (`https://docs.cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances/demote#DemoteContext`)`` Required. This context is used to demote an existing standalone instance to be a Cloud SQL read replica for an external database server. |

## DemoteContext

This context is used to demote an existing standalone instance to be a Cloud SQL read replica for an external database server.

| JSON representation |
|---|
| ``` { "kind": string, "sourceRepresentativeInstanceName": string } ``` |

| Fields ||
|---|---|
| `kind` | `string` This is always `sql#demoteContext`. |
| `sourceRepresentativeInstanceName` | `string` Required. The name of the instance which acts as an on-premises primary instance in the replication setup. |