Required. The parent resource. For example: projects/{projectId}/databases/{databaseId}/documents or projects/{projectId}/databases/{databaseId}/documents/chatrooms/{chatroom_id}
collectionId
string
Required. The collection ID, relative to parent, to list. For example: chatrooms.
Query parameters
Parameters
documentId
string
The client-assigned document ID to use for this document.
Optional. If not specified, an ID will be assigned by the service.
[[["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 API endpoint is used to create a new document within a specified collection in a Firestore database.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eparent\u003c/code\u003e path parameter indicates the location where the document will be created, and \u003ccode\u003ecollectionId\u003c/code\u003e identifies the specific collection.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edocumentId\u003c/code\u003e query parameter allows optionally setting a client-assigned ID; if omitted, the service will generate one.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003emask\u003c/code\u003e query parameter enables selecting specific fields to be returned in the response.\u003c/p\u003e\n"],["\u003cp\u003eThe request body requires a \u003ccode\u003eDocument\u003c/code\u003e instance, and a successful response will also contain a \u003ccode\u003eDocument\u003c/code\u003e instance.\u003c/p\u003e\n"]]],[],null,["# Method: projects.databases.documents.createDocument\n\nCreates a new document.\n\n### HTTP request\n\n`POST https://firestore.googleapis.com/v1beta1/{parent=projects/*/databases/*/documents/**}/{collectionId}`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n### Query parameters\n\n### Request body\n\nThe request body contains an instance of [Document](/firestore/docs/reference/rest/v1beta1/projects.databases.documents#Document).\n\n### Response body\n\nIf successful, the response body contains an instance of [Document](/firestore/docs/reference/rest/v1beta1/projects.databases.documents#Document).\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)."]]