Applies a batch of write operations.
The documents.batchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse
for the success status of each write.
If you require an atomically applied set of writes, use documents.commit
instead.
HTTP request
POST https://firestore.googleapis.com/v1/{database=projects/*/databases/*}/documents:batchWrite
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
database |
Required. The database name. In the format: |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{
"writes": [
{
object ( |
Fields | |
---|---|
writes[] |
The writes to apply. Method does not apply writes atomically and does not guarantee ordering. Each write succeeds or fails independently. You cannot write to the same document more than once per request. |
labels |
Labels associated with this batch write. An object containing a list of |
Response body
The response from Firestore.BatchWrite
.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "writeResults": [ { object ( |
Fields | |
---|---|
writeResults[] |
The result of applying the writes. This i-th write result corresponds to the i-th write in the request. |
status[] |
The status of applying the writes. This i-th write status corresponds to the i-th write in the request. |
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 Authentication Overview.