Method: projects.databases.documents.write

Streams batches of document updates and deletes, in order.

HTTP request

POST https://firestore.googleapis.com/v1beta1/{database=projects/*/databases/*}/documents:write

The URL uses Google API HTTP annotation syntax.

Path parameters

Parameters
database

string

The database name. In the format: projects/{projectId}/databases/{databaseId}. This is only required in the first message.

Request body

The request body contains data with the following structure:

JSON representation
{
  "streamId": string,
  "writes": [
    {
      object(Write)
    }
  ],
  "streamToken": string,
  "labels": {
    string: string,
    ...
  },
}
Fields
streamId

string

The ID of the write stream to resume. This may only be set in the first message. When left empty, a new write stream will be created.

writes[]

object(Write)

The writes to apply.

Always executed atomically and in order. This must be empty on the first request. This may be empty on the last request. This must not be empty on all other requests.

streamToken

string (bytes format)

A stream token that was previously sent by the server.

The client should set this field to the token from the most recent WriteResponse it has received. This acknowledges that the client has received responses up to this token. After sending this token, earlier tokens may not be used anymore.

The server may close the stream if there are too many unacknowledged responses.

Leave this field unset when creating a new stream. To resume a stream at a specific point, set this field and the streamId field.

Leave this field unset when creating a new stream.

A base64-encoded string.

labels

map (key: string, value: string)

Labels associated with this write request.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

Response body

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

The response for Firestore.Write.

JSON representation
{
  "streamId": string,
  "streamToken": string,
  "writeResults": [
    {
      object(WriteResult)
    }
  ],
  "commitTime": string,
}
Fields
streamId

string

The ID of the stream. Only set on the first message, when a new stream was created.

streamToken

string (bytes format)

A token that represents the position of this response in the stream. This can be used by a client to resume the stream at this point.

This field is always set.

A base64-encoded string.

writeResults[]

object(WriteResult)

The result of applying the writes.

This i-th write result corresponds to the i-th write in the request.

commitTime

string (Timestamp format)

The time at which the commit occurred.

A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

Authorization Scopes

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.

Was this page helpful? Let us know how we did: