
MONGODB n8n INTEGRATION: AUTOMATE MONGODB WITH N8N
Looking to automate MongoDB with n8n? You're in the right place. The MongoDB n8n integration gives you access to 11 powerful actions to automate your database operations without writing complex scripts or managing manual data transfers.
Whether you need to insert documents into collections, run aggregation pipelines, manage search indexes, or synchronize your MongoDB data with hundreds of other applications, this native integration handles it all. From basic CRUD operations to advanced search index management, n8n transforms MongoDB into a fully programmable component of your automation stack.
In this guide, you'll discover exactly how to connect MongoDB to n8n, explore each available action in detail, and learn how to leverage this integration to build robust, database-driven workflows that scale with your business needs.
Need help automating Mongodb with n8n?
Our team will get back to you in minutes.
Why automate Mongodb with n8n?
The MongoDB n8n integration gives you access to 11 actions covering the full spectrum of document and search index management. You can insert, update, find, delete, and aggregate documents—plus create, list, update, and drop search indexes—all from within your automated workflows.
Significant time savings: No more manual database operations or custom scripts for routine tasks. Set up workflows that automatically insert new leads into your MongoDB collections when they come from your CRM, update customer records when they interact with your app, or clean up stale data on a schedule. What used to require a developer writing code now happens automatically.
Seamless integration: Connect MongoDB to over 400 applications in n8n's ecosystem. Sync your database with Slack notifications, trigger document updates from webhook events, aggregate data and send reports via email, or build complete data pipelines that span your entire tech stack. MongoDB becomes a living, breathing part of your automation infrastructure.
Concrete use cases: Automatically archive customer support tickets to MongoDB after resolution. Sync product inventory between your e-commerce platform and MongoDB. Run nightly aggregation pipelines and push reports to Google Sheets. Manage Atlas Search indexes programmatically based on application events. The possibilities are virtually limitless.
How to connect Mongodb to n8n?
! 1 stepHow to connect Mongodb to n8n?
- 01
Add the node
Search and add the node in your workflow.
TIP💡 TIP: Create a dedicated database user with only the permissions your workflows need—avoid using your admin credentials. This follows the principle of least privilege and keeps your database secure even if your n8n instance is compromised.- 01
Need help automating Mongodb with n8n?
Our team will get back to you in minutes.
Mongodb actions available in n8n
01 Action 01Aggregate documents
The Aggregate documents action lets you run MongoDB's powerful aggregation pipelines directly from your n8n workflows. This is the go-to action when you need to transform, filter, group, or analyze data across multiple documents—think of it as running complex database queries without leaving your automation environment.
Key parameters:
- Credential to connect with: Select your MongoDB account credential from the dropdown. This is required for authentication.
- Collection: Text field where you specify the MongoDB collection to run the aggregation against. Required.
- Query: A code editor where you write your aggregation pipeline as a JSON array. This follows MongoDB's standard aggregation syntax with stages like
$match,$group,$project, etc.
Use cases:
- Calculate daily sales totals and push the results to a reporting dashboard
- Generate customer segmentation data by grouping users based on activity patterns
- Build real-time analytics by aggregating event logs and sending summaries via Slack
The aggregation pipeline is MongoDB's most flexible query mechanism, and having it accessible in n8n means you can build sophisticated data transformations that feed into any downstream workflow.

02 Action 02Find documents
The Find documents action retrieves documents from a MongoDB collection based on query criteria you define. It's the foundation for any read operation—whether you're looking up a single record or pulling batches of data for processing.
Key parameters:
- Credential to connect with: Dropdown to select your MongoDB connection credentials. Required.
- Collection: Text input for the collection name you want to query. Required.
- Query (JSON Format): A JSON editor where you define your search criteria. An empty object
{}returns all documents; otherwise, use MongoDB query syntax like{"status": "active"}. - Options: Additional properties to fine-tune your query (projection, sort, limit, etc.).
Use cases:
- Retrieve all orders placed in the last 24 hours and sync them to your fulfillment system
- Look up customer details by email address when processing support tickets
- Pull product catalog data to populate dynamic content in marketing emails

03 Action 03Insert documents
The Insert documents action adds new documents to a MongoDB collection. This is essential for any workflow that creates records—capturing form submissions, logging events, or importing data from external sources.
Key parameters:
- Credential to connect with: Select your MongoDB account credentials. Required.
- Collection: Text field specifying the target collection for insertion. Required.
- Fields: Comma-separated list of field names to include in the inserted document (e.g.,
name,description,email). The values come from previous nodes in your workflow. - Options: Additional insertion configurations if needed.
Use cases:
- Automatically create lead records when someone fills out a contact form
- Log webhook events for audit trails and debugging
- Import data from CSV files or other sources into MongoDB collections

04 Action 04Update documents
The Update documents action modifies existing documents in a collection based on a matching key. Use this when you need to change multiple fields across one or more documents that share a common identifier.
Key parameters:
- Credential to connect with: Your MongoDB connection credential. Required.
- Collection: The target collection name. Required.
- Update Key: The field used to match documents for updating (e.g.,
idoremail). Documents with matching values in this field will be updated. - Fields: Comma-separated field names to update (e.g.,
name,description). Values come from your workflow data. - Upsert: Toggle switch—when enabled, creates a new document if no match is found. Disabled by default.
Use cases:
- Sync customer profile changes from your CRM back to MongoDB
- Update order statuses as they progress through your fulfillment pipeline
- Bulk update product prices when running promotions

05 Action 05Find and update document
The Find and update document action combines a search and update operation atomically—it finds a single document matching your criteria and updates it in one operation. This is perfect when you need to modify exactly one record.
Key parameters:
- Credential to connect with: MongoDB credentials dropdown. Required.
- Collection: Target collection name. Required.
- Update Key: The field used to identify the document to update (e.g.,
id). - Fields: Comma-separated list of fields to update (e.g.,
name,description). - Upsert: Toggle to create a document if none matches. Off by default.
- Options: Additional optional parameters.
Use cases:
- Update a specific user's last login timestamp when they authenticate
- Modify a single order's shipping status based on carrier webhook data
- Increment a counter field on a specific document

06 Action 06Find And Replace
The Find And Replace action locates a document by a matching key and completely replaces its contents with new data. Unlike update operations that modify specific fields, this action replaces the entire document structure.
Key parameters:
- Credential to connect with: Select your MongoDB account. Required.
- Collection: Target collection name (text input). Required.
- Update Key: The field used to match the document to replace (e.g.,
id). - Fields: Fields to include in the replacement document (e.g.,
name,description). - Upsert: Toggle to insert if no document matches. Disabled by default.
Use cases:
- Completely overwrite configuration documents when settings change
- Replace outdated records with fresh data from an external API
- Swap out template documents with updated versions

07 Action 07Delete documents
The Delete documents action removes documents from a collection based on a JSON query. This is your tool for cleaning up data, removing stale records, or implementing data retention policies.
Key parameters:
- Credential to connect with: MongoDB connection credentials. Required.
- Collection: The collection to delete from. Required.
- Delete Query (JSON Format): A JSON object defining which documents to delete. An empty
{}would delete ALL documents (use with extreme caution).
Use cases:
- Automatically purge session data older than 30 days
- Remove canceled orders from your active orders collection
- Clean up temporary documents created during data processing workflows
💡 TIP: Always test your delete query with a Find documents action first to verify exactly which documents will be affected before running the delete.

08 Action 08Create Search Index
The Create Search Index action sets up a new Atlas Search index on a MongoDB collection. This enables full-text search and vector search capabilities on your data—essential for building search features or AI-powered retrieval systems.
Key parameters:
- Credential to connect with: MongoDB account credentials. Required.
- Collection: The collection to index. Required.
- Index Name: A unique name for your search index. Required.
- Index Definition: JSON object defining the index structure and field mappings.
- Index Type: Dropdown to select the index type (e.g., Vector Search for AI embeddings).
Use cases:
- Set up full-text search indexes when deploying new features
- Create vector search indexes for semantic search applications
- Automate index creation as part of database provisioning workflows

09 Action 09List Search Indexes
The List Search Indexes action retrieves all search indexes defined on a specific collection. Use this to audit your search infrastructure or verify index configurations.
Key parameters:
- Credential to connect with: MongoDB credentials. Required.
- Collection: The collection to list indexes for. Required.
- Index Name: Optionally filter to a specific index by name.
Use cases:
- Generate reports of all search indexes across your collections
- Verify that deployment workflows successfully created expected indexes
- Monitor search infrastructure as part of operational dashboards

10 Action 10Update Search Index
The Update Search Index action modifies an existing search index's definition. This is how you refine search behavior—adjusting field mappings, analyzers, or other index properties without dropping and recreating.
Key parameters:
- Credential to connect with: MongoDB account. Required.
- Collection: The collection containing the index. Required.
- Index Name: The name of the index to update. Required.
- Index Definition: JSON object with the new index configuration.
Use cases:
- Adjust search relevance by modifying field weights
- Add new fields to existing indexes when your schema evolves
- Update vector search dimensions when switching embedding models

11 Action 11Drop Search Index
The Drop Search Index action removes a search index from a collection. Use this for cleanup, migrations, or when replacing indexes with updated configurations.
Key parameters:
- Credential to connect with: MongoDB credentials. Required.
- Collection: The collection containing the index. Required.
- Index Name: The exact name of the index to drop. Required.
Use cases:
- Clean up deprecated search indexes during migrations
- Remove test indexes from production collections
- Automate index lifecycle management in deployment pipelines

Build your first workflow with our team
Drop your email and we'll send you the catalog of automations you can ship today.
- Free n8n & Make scenarios to import
- Step-by-step setup docs
- Live cohort + community support
Frequently asked questions
Is the MongoDB n8n integration free?
Yes, the MongoDB integration is included with n8n at no additional cost—it's a native node available in both the self-hosted open-source version and n8n Cloud plans. However, you'll need your own MongoDB database to connect to. MongoDB Atlas offers a free tier with 512MB storage that works perfectly for testing and small projects. For production workloads, you'll want a paid Atlas cluster or self-hosted MongoDB instance. The n8n side of the equation adds no extra licensing fees beyond your chosen n8n plan.What data operations can I perform between MongoDB and n8n?
The integration covers comprehensive document operations: inserting new documents, finding/querying documents with full MongoDB query syntax, updating existing documents (both partial updates and full replacements), deleting documents based on query criteria, and running complex aggregation pipelines for data transformation and analysis. Additionally, you get full control over Atlas Search indexes—creating, listing, updating, and dropping them programmatically. This means you can build complete data workflows from simple CRUD operations to sophisticated analytics pipelines and search infrastructure management. Our n8n agency can help you design these complex workflows.How long does it take to set up the MongoDB n8n integration?
If you already have a MongoDB database running, the integration takes about 5 minutes to configure. You'll copy your connection string from MongoDB Atlas (or construct it for self-hosted instances), paste it into n8n's credential manager, and test with a simple Find operation. The main time investment comes from designing your actual workflows—deciding what triggers actions, mapping data between nodes, and testing edge cases. For a basic workflow like "insert webhook data into MongoDB," you're looking at 10-15 minutes total from start to finish. If you need help with n8n troubleshooting, we've got you covered.


