Stay organized with collections
Save and categorize content based on your preferences.
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
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
map (key: string, value: string)
Labels associated with this batch write.
An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-20 UTC."],[],[],null,["# Method: projects.databases.documents.batchWrite\n\nApplies a batch of write operations.\n\nThe 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](/docs/firestore/reference/rest/v1/projects.databases.documents/batchWrite#body.BatchWriteResponse) for the success status of each write.\n\nIf you require an atomically applied set of writes, use [documents.commit](/docs/firestore/reference/rest/v1/projects.databases.documents/commit#google.firestore.v1.Firestore.Commit) instead.\n\n### HTTP request\n\n`POST https://firestore.googleapis.com/v1/{database=projects/*/databases/*}/documents:batchWrite`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------------|\n| `database` | `string` Required. The database name. In the format: `projects/{projectId}/databases/{databaseId}`. |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------|\n| ``` { \"writes\": [ { object (/docs/firestore/reference/rest/v1/Write) } ], \"labels\": { string: string, ... } } ``` |\n\n| Fields ||\n|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `writes[]` | `object (`[Write](/docs/firestore/reference/rest/v1/Write)`)` 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. |\n| `labels` | `map (key: string, value: string)` Labels associated with this batch write. An object containing a list of `\"key\": value` pairs. Example: `{ \"name\": \"wrench\", \"mass\": \"1.3kg\", \"count\": \"3\" }`. |\n\n### Response body\n\nThe response from [Firestore.BatchWrite](/docs/firestore/reference/rest/v1/projects.databases.documents/batchWrite#google.firestore.v1.Firestore.BatchWrite).\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"writeResults\": [ { object (/docs/firestore/reference/rest/v1/WriteResult) } ], \"status\": [ { object (/docs/firestore/reference/rest/Shared.Types/Operation#Status) } ] } ``` |\n\n| Fields ||\n|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `writeResults[]` | `object (`[WriteResult](/docs/firestore/reference/rest/v1/WriteResult)`)` The result of applying the writes. This i-th write result corresponds to the i-th write in the request. |\n| `status[]` | `object (`[Status](/docs/firestore/reference/rest/Shared.Types/Operation#Status)`)` The status of applying the writes. This i-th write status corresponds to the i-th write in the request. |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/datastore`\n- `https://www.googleapis.com/auth/cloud-platform`\n\nFor more information, see the [OAuth 2.0 Overview](https://developers.google.com/identity/protocols/OAuth2)."]]