---
title: "POST /v1/{+database}/sessions"
method: POST
path: "/v1/{+database}/sessions"
tags: ["projects"]
---

# POST /v1/{+database}/sessions

`POST /v1/{+database}/sessions`

Creates a new session. A session can be used to perform transactions that read and/or modify data in a Cloud Spanner database. Sessions are meant to be reused for many consecutive transactions. Sessions can only execute one transaction at a time. To execute multiple concurrent read-write/write-only transactions, create multiple sessions. Note that standalone reads and queries use a transaction internally, and count toward the one transaction limit. Active sessions use additional server resources, so it's a good idea to delete idle and unneeded sessions. Aside from explicit deletes, Cloud Spanner can delete sessions when no operations are sent for more than an hour. If a session is deleted, requests to it return `NOT_FOUND`. Idle sessions can be kept alive by sending a trivial SQL query periodically, for example, `"SELECT 1"`.

## Path parameters

- `database` string, required

## Request body

- CreateSessionRequest — The request for CreateSession.
  - `session` Session — A session in the Cloud Spanner API.
    - `name` string — Output only. The name of the session. This is always system-assigned.
    - `labels` object — 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, google-datetime — Output only. The timestamp when the session is created.
    - `approximateLastUseTime` string, google-datetime — Output only. The approximate timestamp when the session is last used. It's typically earlier than the actual last use time.
    - `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 `sessions.create` to create multiplexed sessions. Don't use BatchCreateSessions to create a multiplexed session. You can't delete or list multiplexed sessions.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/spanner.md) · [All operations](https://skmtc.net/google/apis/spanner/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/spanner/versions/4b66067d2622/schema)
