# REST Resource: projects.instances.databases.sessions

- [Resource: Session](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions#Session)
  - [JSON representation](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions#Session.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions#METHODS_SUMMARY)

## Resource: Session

A session in the Cloud Spanner API.

| JSON representation |
|---|
| ``` { "name": string, "labels": { string: string, ... }, "createTime": string, "approximateLastUseTime": string, "creatorRole": string, "multiplexed": boolean } ``` |

| Fields ||
|---|---|
| `name` | `string` Output only. The name of the session. This is always system-assigned. |
| `labels` | `map (key: string, value: string)` The labels for the session. - Label keys must be between 1 and 63 characters long and must conform to the following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`. - Label values must be between 0 and 63 characters long and must conform to the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`. - No more than 64 labels can be associated with a given session. See <https://goo.gl/xmQnxf> for more information on and examples of labels. |
| `createTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The timestamp when the session is created. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `approximateLastUseTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The approximate timestamp when the session is last used. It's typically earlier than the actual last use time. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `creatorRole` | `string` The database role which created this session. |
| `multiplexed` | `boolean` Optional. If `true`, specifies a multiplexed session. Use a multiplexed session for multiple, concurrent operations including any combination of read-only and read-write transactions. Use `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/create#google.spanner.v1.Spanner.CreateSession` to create multiplexed sessions. Don't use `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/batchCreate#google.spanner.v1.Spanner.BatchCreateSessions` to create a multiplexed session. You can't delete or list multiplexed sessions. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adaptMessage` | Handles a single message from the client and returns the result as a stream. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/adapter` | Creates a new session to be used for requests made by the adapter. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/batchCreate` | Creates multiple new sessions. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/batchWrite` | Batches the supplied mutation groups in a collection of efficient transactions. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/beginTransaction` | Begins a new transaction. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/commit` | Commits a transaction. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/create` | Creates a new session. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/delete` | Ends a session, releasing server resources associated with it. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeBatchDml` | Executes a batch of SQL DML statements. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeSql` | Executes an SQL statement, returning all results in a single reply. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeStreamingSql` | Like `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeSql#google.spanner.v1.Spanner.ExecuteSql`, except returns the result set as a stream. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/get` | Gets a session. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/list` | Lists all sessions in a given database. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/partitionQuery` | Creates a set of partition tokens that can be used to execute a query operation in parallel. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/partitionRead` | Creates a set of partition tokens that can be used to execute a read operation in parallel. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read` | Reads rows from the database using key lookups and scans, as a simple key/value style alternative to `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeSql#google.spanner.v1.Spanner.ExecuteSql`. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/rollback` | Rolls back a transaction, releasing any locks it holds. |
| ### `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/streamingRead` | Like `https://docs.cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read#google.spanner.v1.Spanner.Read`, except returns the result set as a stream. |