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

Initiates a manual failover of a high availability (HA) primary instance to a standby instance, which becomes the primary instance. Users are then rerouted to the new primary. For more information, see the [Overview of high availability](https://cloud.google.com/sql/docs/sqlserver/high-availability) page in the Cloud SQL documentation. If using Legacy HA (MySQL only), this causes the instance to failover to its failover replica instance.

### HTTP request

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

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

### Path parameters

| Parameters ||
|---|---|
| `project` | `string` ID of the project that contains the read replica. |
| `instance` | `string` Cloud SQL instance ID. This does not include the project ID. |

### Request body

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

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/sql/docs/sqlserver/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).

## InstancesFailoverRequest

Instance failover request.

| JSON representation |
|---|
| ``` { "failoverContext": { object (`https://docs.cloud.google.com/sql/docs/sqlserver/admin-api/rest/v1beta4/instances/failover#FailoverContext`) } } ``` |

| Fields ||
|---|---|
| `failoverContext` | ``object (`https://docs.cloud.google.com/sql/docs/sqlserver/admin-api/rest/v1beta4/instances/failover#FailoverContext`)`` instances.failover Context. |

## FailoverContext

Database instance failover context.

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

| Fields ||
|---|---|
| `settingsVersion` | `string (https://developers.google.com/discovery/v1/type-format format)` The current settings version of this instance. Request will be rejected if this version doesn't match the current settings version. |
| `kind` | `string` This is always `sql#failoverContext`. |