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/v1beta1/{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"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-02 UTC."],[[["\u003cp\u003eThis \u003ccode\u003ebatchWrite\u003c/code\u003e method applies multiple write operations to documents, but not atomically, and the order of operations is not guaranteed.\u003c/p\u003e\n"],["\u003cp\u003eEach write operation within the batch succeeds or fails independently, and you can find the individual success status for each in the \u003ccode\u003eBatchWriteResponse\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe method does not allow more than one write operation per document within a single batch write request.\u003c/p\u003e\n"],["\u003cp\u003eIf an atomic set of writes is needed, the \u003ccode\u003edocuments.commit\u003c/code\u003e method should be used instead of \u003ccode\u003ebatchWrite\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ewrites[]\u003c/code\u003e and \u003ccode\u003estatus[]\u003c/code\u003e results from the response body of the request contain information about each write operation's result and status, respectively.\u003c/p\u003e\n"]]],[],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](/firestore/docs/reference/rest/v1beta1/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](/firestore/docs/reference/rest/v1beta1/projects.databases.documents/commit#google.firestore.v1beta1.Firestore.Commit) instead.\n\n### HTTP request\n\n`POST https://firestore.googleapis.com/v1beta1/{database=projects/*/databases/*}/documents:batchWrite`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n### Request body\n\nThe request body contains data with the following structure:\n\n### Response body\n\nThe response from [Firestore.BatchWrite](/firestore/docs/reference/rest/v1beta1/projects.databases.documents/batchWrite#google.firestore.v1beta1.Firestore.BatchWrite).\n\nIf successful, the response body contains data with the following structure:\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 [Authentication Overview](/docs/authentication#authorization-gcp)."]]