Stay organized with collections
Save and categorize content based on your preferences.
Updates or inserts a document.
Every document in Cloud Firestore is uniquely identified by its location within
the database. Documents live in collections and the names of documents within a
collection are unique. Note that {document_path} refers to the fully specified
document path and includes the collection ID. For more information, see
Cloud Firestore data model
and the
Cloud Firestore connector sample.
Arguments
Parameters
name
string
Required. The resource name of the document, for example projects/{project_id}/databases/{database_id}/documents/{document_path}.
currentDocument.exists
boolean
When set to true, the target document must exist. When set to false, the target document must not exist.
[[["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-08-28 UTC."],[],[],null,["# Method: googleapis.firestore.v1.projects.databases.documents.patch\n\nUpdates or inserts a document.\n\nEvery document in Cloud Firestore is uniquely identified by its location within\nthe database. Documents live in collections and the names of documents within a\ncollection are unique. Note that `{document_path}` refers to the fully specified\ndocument path and includes the collection ID. For more information, see\n[Cloud Firestore data model](https://firebase.google.com/docs/firestore/data-model)\nand the\n[Cloud Firestore connector sample](/workflows/docs/reference/googleapis/firestore/Overview#firestore-sample).\n\nArguments\n---------\n\nRaised exceptions\n-----------------\n\nResponse\n--------\n\nIf successful, the response contains an instance of [`Document`](/workflows/docs/reference/googleapis/firestore/v1/Overview#Document).\n\nSubworkflow snippet\n-------------------\n\nSome fields might be optional or required.\nTo identify required fields, refer to the [API documentation](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.documents/patch). \n\n### YAML\n\n```yaml\n- patch:\n call: googleapis.firestore.v1.projects.databases.documents.patch\n args:\n name: ...\n currentDocument:\n exists: ...\n updateTime: ...\n mask:\n fieldPaths: ...\n updateMask:\n fieldPaths: ...\n body:\n fields: ...\n name: ...\n result: patchResult\n```\n\n### JSON\n\n```json\n[\n {\n \"patch\": {\n \"call\": \"googleapis.firestore.v1.projects.databases.documents.patch\",\n \"args\": {\n \"name\": \"...\",\n \"currentDocument\": {\n \"exists\": \"...\",\n \"updateTime\": \"...\"\n },\n \"mask\": {\n \"fieldPaths\": \"...\"\n },\n \"updateMask\": {\n \"fieldPaths\": \"...\"\n },\n \"body\": {\n \"fields\": \"...\",\n \"name\": \"...\"\n }\n },\n \"result\": \"patchResult\"\n }\n }\n]\n```"]]