Method: projects.databases.documents.commit
Stay organized with collections
Save and categorize content based on your preferences.
Commits a transaction, while optionally updating documents.
HTTP request
POST https://firestore.googleapis.com/v1/{database=projects/*/databases/*}/documents:commit
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters |
database |
string
Required. The database name. In the format: projects/{projectId}/databases/{databaseId} .
|
Request body
The request body contains data with the following structure:
JSON representation |
{
"writes": [
{
object (Write )
}
],
"transaction": string
} |
Fields |
writes[] |
object (Write )
The writes to apply. Always executed atomically and in order.
|
transaction |
string (bytes format)
If set, applies all writes in this transaction, and commits it. A base64-encoded string.
|
Response body
The response for Firestore.Commit
.
If successful, the response body contains data with the following structure:
JSON representation |
{
"writeResults": [
{
object (WriteResult )
}
],
"commitTime": string
} |
Fields |
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. Any read with an equal or greater readTime is guaranteed to see the effects of the commit. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z" , "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30" .
|
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 OAuth 2.0 Overview.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-26 UTC.
[null,null,["Last updated 2025-08-26 UTC."],[],[],null,["# Method: projects.databases.documents.commit\n\nCommits a transaction, while optionally updating documents.\n\n### HTTP request\n\n`POST https://firestore.googleapis.com/v1/{database=projects/*/databases/*}/documents:commit`\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) } ], \"transaction\": string } ``` |\n\n| Fields ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `writes[]` | `object (`[Write](/docs/firestore/reference/rest/v1/Write)`)` The writes to apply. Always executed atomically and in order. |\n| `transaction` | `string (`[bytes](https://developers.google.com/discovery/v1/type-format)` format)` If set, applies all writes in this transaction, and commits it. A base64-encoded string. |\n\n### Response body\n\nThe response for [Firestore.Commit](/docs/firestore/reference/rest/v1/projects.databases.documents/commit#google.firestore.v1.Firestore.Commit).\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) } ], \"commitTime\": string } ``` |\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| `commitTime` | `string (`[Timestamp](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp)` format)` The time at which the commit occurred. Any read with an equal or greater `readTime` is guaranteed to see the effects of the commit. Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than \"Z\" are also accepted. Examples: `\"2014-10-02T15:01:23Z\"`, `\"2014-10-02T15:01:23.045123456Z\"` or `\"2014-10-02T15:01:23+05:30\"`. |\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)."]]