Resources · n8n integration

MongoDB n8n integrationAutomate MongoDB with n8n.

Every document a workflow touches can live in a MongoDB collection. The MongoDB n8n integration exposes 11 operations across 2 resources: documents are found, inserted, updated, replaced, deleted or aggregated, and search indexes handled from the same node. No trigger ships with it: the workflow starts elsewhere.

Verified Trustpilot reviews · AI, automation & growth agency

Why automate

What does the MongoDB n8n integration actually do?

The MongoDB node connects an n8n workflow to a MongoDB database and runs queries against it. Eleven operations sit under 2 resources: Document, where data is read and written, and Search Index, where the indexes that make a collection searchable are created, listed, updated and dropped. Queries are written in JSON, the same JSON you would hand to the database itself, so nothing is hidden behind a simplified form.

The first shape of workflow treats MongoDB as the place where everything lands. A scraping branch walks through a list of pages, an HTTP Request node brings back the content, and document.insert writes one document per page. Teams that also keep a copy in Google Sheets usually leave the sheet for people to read and the collection for volume, because a sheet gets slow long before a collection does.

The second reads rather than writes. A Schedule Trigger wakes the workflow, document.find pulls the documents matching a query, and the result goes out as a message in Slack or as a row in a report. When the workflow only needs a count or a grouped total, document.aggregate pushes that work into the database and returns the result already computed, which keeps the execution small.

The third keeps two systems aligned. An incoming payload carries an identifier, document.findOneAndUpdate writes the new values onto the matching document, and Upsert creates it when nothing matches. The pattern is the same one used with the Postgres and MySQL nodes, except the target is a document instead of a row, so a field that did not exist yesterday does not need a migration today.

Two limits are worth knowing before building. MongoDB has no trigger node in n8n, so nothing reacts to a document changing on its own: a Schedule Trigger at a fixed interval, or a Webhook called by whatever writes the data, has to open the workflow. And every filter is hand written JSON, so a wrong operator returns an empty list instead of an error. Run the query through Find documents before wiring it into Delete documents.

So where does the HTTP Request node fit? Its usual job is calling an API endpoint that a dedicated node leaves out, reusing the same credential. Here the credential opens a MongoDB connection string rather than an API key, so there is no endpoint for HTTP Request to call: the escape hatch is Find documents and Aggregate documents instead, since both take a hand written JSON query or pipeline. Everything outside the 11 operations goes through one of those two. The choice between self hosting and the hosted plan, on the other hand, is covered in the n8n review.

Connect

What does n8n need to reach the database?

  1. 01

    Create a database user for the workflow

    A workflow connects to MongoDB as a database user, never as your own console account. Create one on the server with the permissions the workflow actually needs: read only if the branch stops at Find documents, read and write as soon as Insert documents, Update documents or Delete documents appear. Keep the user name and the password aside, both go into the credential in a minute.

  2. 02

    Open the network to n8n

    A cluster answers only the addresses it knows. As a Project Owner, open Network Access in the project and add the n8n IP addresses to the IP Access List Entries. Skip that step and the connection never gets as far as the query: the credential can be perfect and the database still refuses the caller. The entries sit at project level, so one list covers every workflow pointing at this cluster.

  3. 03

    Fill the MongoDB credential

    In the Credentials menu, create a MongoDB credential and pick a Configuration Type. Connection String takes the string found under Database then Connect then Drivers, shaped like mongodb+srv://user:password@cluster.mongodb.net/ with the placeholders replaced by the real user and password, plus the Database name. Values asks for the same facts one field at a time: Host, Database, User, Password and Port.

Actions

What the MongoDB node does, operation by operation

The MongoDB node exposes 11 operations across 2 resources. For each one: the node as you configure it in n8n, the required fields, and our field notes.

Resources × operations matrix
ResourceUpdateDeleteAggregateCreateDropFindFind And ReplaceFind And UpdateInsertListUpdate
Search Index✓✓✓✓
Document✓✓✓✓✓✓✓

Search Index

4 operations
01

Create Search Index

searchIndexes.createSearchIndex

What you see in n8n

Notes & use cases

Adds a search index to a collection so its content becomes searchable. The shape of the index comes from a JSON definition, not from a form.

Key parameters

  • Collection: the collection the index is built on, spelled as it is in the database.
  • Index Name: the name of the index, reused by every later operation.
  • Index Type: two values only, vectorSearch or search.
  • Index Definition: the definition in JSON, on the model shown in the field placeholder, { "type": "vectorSearch", "definition": {} }.
Use cases
a knowledge base filled document by document, then indexed in the same run, so the collection is ready before anyone searches it.
02

Drop Search Index

searchIndexes.dropSearchIndex

What you see in n8n

Notes & use cases

Removes a search index from a collection. The documents stay where they are, only the index disappears, and the node needs nothing more than two names to do it.

Key parameters

  • Collection: the collection the index currently belongs to.
  • Index Name: the exact name the index was created with, since this operation offers no list to pick from.
Use cases
a staging database rebuilt every night starts by dropping yesterday's index, then inserts the fresh documents and creates the index again, which avoids searching a collection that is half rewritten.
03

List Search Indexes

searchIndexes.listSearchIndexes

What you see in n8n

Notes & use cases

Returns the search indexes defined on a collection. It is the read only operation of the resource, and the one to call when the workflow has to decide what to do next.

Key parameters

  • Collection: the collection whose indexes are listed.
  • Index Name: optional, and it changes the nature of the call. Filled in, only indexes carrying that name come back, which turns the operation into an existence check.
Use cases
a maintenance workflow lists first, then branches between Create Search Index when nothing comes back and Update Search Index when the index is already there.
04

Update Search Index

searchIndexes.updateSearchIndex

What you see in n8n

Notes & use cases

Sends a new definition to a search index that already exists. Note what is missing compared to the creation: there is no Index Type here, the type stays the one chosen at the start.

Key parameters

  • Collection: the collection holding the index.
  • Index Name: the index that receives the new definition.
  • Index Definition: the full JSON definition, in the same format as at creation, placeholder included in the field.
Use cases
a field enters the scope of the search and the definition has to follow, without dropping the index and rebuilding it from scratch.

Document

7 operations
05

Aggregate documents

document.aggregate

What you see in n8n

Notes & use cases

Runs an aggregation pipeline on a collection and returns its output. The calculation happens inside the database, the workflow only receives the result.

Key parameters

  • Collection: the collection the pipeline reads from.
  • Query: the pipeline itself, a JSON array of stages, on the model of the placeholder [{ "$match": { "$gt": "1950-01-01" }, ... }]. An expression such as {{ $json.since }} drops a value from the previous node straight into a stage.
Use cases
a weekly summary that reads one aggregated figure per line instead of pulling every document into n8n and filtering there.
06

Delete documents

document.delete

What you see in n8n

Notes & use cases

Deletes the documents that match a filter. The operation takes nothing but a collection and a query, so the query is the only safeguard between the workflow and the data.

Key parameters

  • Collection: where the deletion runs.
  • Delete Query (JSON Format): the Mongo filter, shaped like the placeholder { "birth": { "$gt": "1950-01-01" } }. Run the same filter through Find documents first and count what comes back.
Use cases
a request to erase a person's data arrives, the workflow deletes every document carrying that identifier and logs the deletion elsewhere.
07

Find documents

document.find

What you see in n8n

Notes & use cases

Reads the documents matching a query and passes them on. It opens most MongoDB branches, since nothing in n8n reacts to the database on its own.

Key parameters

  • Query (JSON Format): the Mongo filter, on the model of { "birth": { "$gt": "1950-01-01" } }.
  • Limit: the maximum number of documents returned, 0 meaning no ceiling at all.
  • Skip: how many documents to step over, the companion of Limit on a long collection.
  • Sort (JSON Format): the order of the result set, written as { "field": -1 } for a descending sort.
  • Projection (JSON Format): the fields to keep or drop, { "_id": 0, "field": 1 }, which keeps the payload light.
Use cases
every morning, a scheduled run reads the documents created since yesterday and turns them into a digest.
08

Find and replace documents

document.findOneAndReplace

What you see in n8n

Notes & use cases

Looks for the document designated by the update key and swaps it for a new one, built from the fields listed in the operation.

Key parameters

  • Update Key: the property that decides which document is concerned, usually id, and it has to exist on the incoming item too.
  • Fields: the comma separated list of fields that go into the new document, in the form name,description.
  • Upsert: on, a document is inserted when the update key matches nothing.
Use cases
a nightly sync where the source system is the reference, and each incoming record replaces its stored twin rather than being merged with it.
09

Find and update documents

document.findOneAndUpdate

What you see in n8n

Notes & use cases

Finds the document that carries the update key and writes the listed fields onto it. Same two required fields as Find and replace documents, a different intention: here the document is kept and modified.

Key parameters

  • Update Key: the property used to recognize the document, id in most collections.
  • Fields: the fields to write, comma separated, in the same name,description form.
  • Date Fields: the fields to read as a Mongo Date rather than as text, which matters as soon as a date is compared later.
Use cases
an enrichment step returns a phone number, the workflow writes it onto the contact that already exists in the collection.
10

Insert documents

document.insert

What you see in n8n

Notes & use cases

Writes the incoming items into a collection as new documents. There is no update key on this operation, so nothing is looked up before the write.

Key parameters

  • Collection: the collection that receives the documents.
  • Fields: the comma separated list of fields included in the new document, name,description. Only what is named here lands in MongoDB.
  • Use Dot Notation: on when a date sits inside a nested object and has to be reached through a path.
Use cases
a scraping run collects several pages in one execution and stores one document per page, content and source URL together.
11

Update documents

document.update

What you see in n8n

Notes & use cases

Applies the listed fields to the documents identified by the update key. The bulk cousin of the find and update operation, aimed at a batch of items arriving together.

Key parameters

  • Collection: the collection where the update lands.
  • Update Key: the property that decides which documents change, id by convention.
  • Upsert: without it, an item that matches no document produces no insert at all.
Use cases
at the end of a run, every document that has been processed gets its status field rewritten, so the next execution skips it.
Need help

Need help automating MongoDB with n8n?

A person reads every message.

FAQ

MongoDB and n8n, the questions that come next

01Is the MongoDB n8n integration free?
On the n8n side, yes. The MongoDB node ships with n8n, so there is nothing to install and no extra cost, whether the workflow runs on n8n Cloud, the hosted offer, or on a self hosted instance under the Community Edition and its Sustainable Use licence. A workflow behaves identically in both places. What the database itself costs depends on where it runs and is not covered here. One credential created once in the Credentials menu is then offered in the dropdown of every MongoDB node, in every workflow, so the connection is set up a single time.
02Which credentials does the MongoDB node need?
One MongoDB credential, with a Configuration Type to choose first. Connection String expects the string copied under Database then Connect then Drivers, in the mongodb+srv form, with the user name and password of the database user filled in, plus the Database name. Values asks for the same information field by field: Host, Database, User, Password and Port. Both paths need a database user holding the right permissions on the server, and a Project Owner has to add the n8n IP addresses to the IP Access List Entries under Network Access. Use TLS adds the x.509 fields: CA Certificate, Public Client Certificate, Private Client Key and Passphrase.
03What are the limits of the MongoDB node in n8n?
Two of them shape how a workflow is built. There is no trigger, so nothing in n8n notices a document being written by another application. And every filter is hand written JSON in a Query field, which means a wrong operator gives an empty result rather than an error message. Find documents is the only operation with Options for volume: Limit caps the number of documents returned, with 0 for no ceiling, Skip walks past what has already been handled, Sort orders the result and Projection trims it. The credential opens a MongoDB connection string, not an API key, so there is no endpoint for the HTTP Request node to call here: anything the 11 operations do not cover goes through Find documents or Aggregate documents instead, with a hand written JSON query or pipeline.
04Can a workflow react when a document changes in MongoDB?
Not on its own, since MongoDB has no trigger node in n8n. Two routes replace it. A Schedule Trigger starts the workflow at a fixed interval and Find documents reads what changed since the previous run, so the freshness of the data equals the interval that was set. Or the application writing to the database also calls an n8n Webhook, a URL that n8n exposes and listens on, and the workflow picks the change up as it arrives. The first route costs one execution per interval whether anything changed or not, the second costs one per event.
05n8n or Make for MongoDB?
It depends mostly on where the data is allowed to sit. n8n runs on your own server or on n8n Cloud, while Make is hosted only, with no self hosting option, and bills per operation. A collection holding records that cannot leave a given infrastructure points to a self hosted n8n, since the database connection never leaves the network. A workflow inserting a few documents a day runs comfortably on either. The visual logic differs too: n8n builds branches around nodes and expressions, Make around its own modules. On cost, one side is a fixed machine, the other a meter that counts every operation.