Method: projects.beginTransaction

Begins a new transaction.

HTTP request

POST https://datastore.googleapis.com/v1/projects/{projectId}:beginTransaction

The URL uses Google API HTTP annotation syntax.

Path parameters

Parameters
projectId

string

The ID of the project against which to make the request.

Request body

The request body contains data with the following structure:

JSON representation
{
  "transactionOptions": {
    object(TransactionOptions)
  },
}
Fields
transactionOptions

object(TransactionOptions)

Options for a new transaction.

Response body

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

The response for Datastore.BeginTransaction.

JSON representation
{
  "transaction": string,
}
Fields
transaction

string (bytes format)

The transaction identifier (always present).

A base64-encoded string.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/datastore
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

TransactionOptions

Options for beginning a new transaction.

Transactions can be created explicitly with calls to Datastore.BeginTransaction or implicitly by setting ReadOptions.new_transaction in read requests.

JSON representation
{

  // Union field mode can be only one of the following:
  "readWrite": {
    object(ReadWrite)
  },
  "readOnly": {
    object(ReadOnly)
  },
  // End of list of possible types for union field mode.
}
Fields
Union field mode. The mode of the transaction, indicating whether write operations are supported. mode can be only one of the following:
readWrite

object(ReadWrite)

The transaction should allow both reads and writes.

readOnly

object(ReadOnly)

The transaction should only allow reads.

ReadWrite

Options specific to read / write transactions.

JSON representation
{
  "previousTransaction": string,
}
Fields
previousTransaction

string (bytes format)

The transaction identifier of the transaction being retried.

A base64-encoded string.

ReadOnly

Options specific to read-only transactions.

Try it!

Send feedback about...

Cloud Datastore