# Method: projects.instances.databases.sessions.adaptMessage

- [HTTP request](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.AdaptMessageResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.aspect)
- [Try it!](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#try-it)

Handles a single message from the client and returns the result as a stream. The server will interpret the message frame and respond with message frames to the client.

### HTTP request

Choose a location:
<button value="global" default="">global</button> <button value="europe-west8">europe-west8</button> <button value="me-central2">me-central2</button> <button value="us-central1">us-central1</button> <button value="us-central2">us-central2</button> <button value="us-east1">us-east1</button> <button value="us-east4">us-east4</button> <button value="us-east5">us-east5</button> <button value="us-south1">us-south1</button> <button value="us-west1">us-west1</button> <button value="us-west2">us-west2</button> <button value="us-west3">us-west3</button> <button value="us-west4">us-west4</button> <button value="us-west8">us-west8</button> <button value="us-east7">us-east7</button>   
`POST https://spanner.googleapis.com/v1/{name=projects/*/instances/*/databases/*/sessions/*}:adaptMessage`

<br />

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

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The database session in which the adapter request is processed. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `name`: - `spanner.databases.adapt` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "protocol": string, "payload": string, "attachments": { string: string, ... } } ``` |

| Fields ||
|---|---|
| `protocol` | `string` Required. Identifier for the underlying wire protocol. |
| `payload` | `string (https://developers.google.com/discovery/v1/type-format format)` Optional. Uninterpreted bytes from the underlying wire protocol. A base64-encoded string. |
| `attachments` | `map (key: string, value: string)` Optional. Opaque request state passed by the client to the server. |

### Response body

Message sent by the adapter to the client.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "payload": string, "stateUpdates": { string: string, ... }, "last": boolean } ``` |

| Fields ||
|---|---|
| `payload` | `string (https://developers.google.com/discovery/v1/type-format format)` Optional. Uninterpreted bytes from the underlying wire protocol. A base64-encoded string. |
| `stateUpdates` | `map (key: string, value: string)` Optional. Opaque state updates to be applied by the client. |
| `last` | `boolean` Optional. Indicates whether this is the last `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage#body.AdaptMessageResponse` in the stream. This field may be optionally set by the server. Clients should not rely on this field being set in all cases. |

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/spanner.data`
- `https://www.googleapis.com/auth/cloud-platform`

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