Overview
This node integrates with Google Cloud Firestore to manage documents within Firestore databases. It supports creating, reading, updating, and deleting documents by specifying their paths and data.
The Create operation allows users to add new documents to a collection or set a document at a specific path. This is useful for workflows that need to store structured data dynamically in Firestore, such as logging events, saving user-generated content, or syncing data from other systems.
Example use case: Automatically create a new Firestore document when a form is submitted, storing the form data as JSON in a specified collection.
Properties
| Name | Meaning |
|---|---|
| Path | The Firestore path to the collection or document where the new document will be created. Can include placeholders like {id} for dynamic segments. If the path points to a collection (odd number of segments), a new document with an auto-generated ID will be created. If it points to a document (even number of segments), the document will be created or overwritten at that exact path. |
| Data (JSON) | The JSON data to store in the new document. Supports special Firestore types using objects with __type keys: - "reference": a reference to another Firestore document, specified by its path.- "timestamp": a timestamp value, given as an ISO date string.- "geopoint": a geographic point with latitude and longitude numbers.The data can be provided as a JSON string or an object. |
Output
The output JSON contains information about the result of the create operation:
success: Boolean indicating if the creation was successful.operation: The operation performed, here always"create".id: The Firestore document ID of the newly created document (auto-generated or specified).path: The full Firestore path to the created document.
If the document is successfully created, these fields help downstream nodes identify and reference the new document.
Dependencies
- Requires a valid Google Cloud Firestore service account credential configured in n8n.
- Uses Firebase Admin SDK internally to interact with Firestore.
- The node expects the service account JSON to be provided as part of the credentials.
Troubleshooting
- Invalid JSON format in Data field: Occurs if the "Data (JSON)" property contains malformed JSON when provided as a string. Ensure the JSON syntax is correct.
- Data field is not a valid object or JSON string: Happens if the data input is neither a valid JSON string nor an object. Provide proper JSON or an object.
- Invalid collection path for auto-ID: When using
{id}placeholder in the path, ensure the path correctly points to a collection; otherwise, the node cannot generate an ID. - Firestore Error: General errors from Firestore API calls are wrapped and reported. Check the error message for details, such as permission issues or invalid paths.
- Make sure the Firestore database rules allow write access for the authenticated service account.