MongoDB Action
Reads and writes a MongoDB collection from a flow. Seven operations — insert, find one, find all, update, find-and-update, delete, and a full aggregation pipeline — all driven by JSON templates, so the query and the document are built from the payload at run time.
Overview
The MongoDB Action node is a post-delivery action that writes data to an external MongoDB database after a webhook processes a webhook event. It connects to your MongoDB instance using an encrypted connection URI and performs the configured operation. The node appears on the canvas with a green color.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Friendly label for the MongoDB action |
| connectionUri | string | Yes | MongoDB connection string. Encrypted at rest. |
| database | string | Yes | Target database name |
| collection | string | Yes | Target collection name |
| operation | string | Yes | One of the seven values in Operations |
| document | string | Yes | JSON template for the document to insert/replace. Supports {{payload.*}}, {{response.*}}. |
| filter | string | Conditional | JSON template for the filter query. Used by every operation except insertOne. |
| inputNodes | { nodeType, nodeId }[] | Yes | Upstream nodes that feed this one |
| isActive | boolean | No | Enable or disable without deleting. Default: true. |
connectionUri is encrypted before being stored. It is never returned in API responses after creation. Make sure your MongoDB instance allows connections from HostWebhook servers.Operations
The Operation dropdown decides what the node does and which template boxes appear under it. Five of the seven read; only two write blindly.
| Value | In the dropdown | Does | Templates it shows |
|---|---|---|---|
| insertOne | Insert One | Inserts a single document | document |
| findOne | Find One | Returns the first matching document | query |
| findAll | Find All | Returns every match, capped at 1000 | query · include count |
| updateOne | Update One | Updates the first matching document | query · update |
| findOneAndUpdate | Find & Update | Updates and returns the document in one round trip | query · update |
| deleteOne | Delete One | Deletes the first matching document | query |
| aggregate | Aggregate | Runs a pipeline — $match, $group, $sort… | pipeline |
replaceOne. It is not one of the seven and the API rejects it. If a node of yours is configured with it, switch to updateOne.The update box is a builder rather than a raw box: it writes the operators ($set, $inc…) for you so a typo cannot turn an update into a replacement. Query and document boxes take JSON with templates inside, so { "orderId": "{{payload.id}}" } is the normal shape.
findAll returns at most 1000 documents. If you need more, narrow the query or move the work into aggregate, where $group can do the counting server-side instead of shipping rows to the flow.Create a MongoDB Action
curl -X POST /api/mongo-actions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Log Orders to MongoDB",
"connectionUri": "mongodb+srv://user:[email protected]",
"database": "analytics",
"collection": "webhook_events",
"operation": "insertOne",
"document": "{ "eventType": "{{payload.type}}", "orderId": "{{payload.order.id}}", "amount": {{payload.order.total}}, "deliveryStatus": {{response.status}}, "processedAt": "{{response.body.processedAt}}", "receivedAt": { "$date": "{{payload.timestamp}}" } }",
"inputNodes": [{ "nodeType": "webhook", "nodeId": "6642f1a2c3b4d5e6f7890123" }],
"isActive": true
}'Response
{
"_id": "6644b2c3d4e5f6a7b8901234",
"name": "Log Orders to MongoDB",
"database": "analytics",
"collection": "webhook_events",
"operation": "insertOne",
"document": "{ "eventType": "{{payload.type}}", ... }",
"inputNodes": [{ "nodeType": "webhook", "nodeId": "6642f1a2c3b4d5e6f7890123" }],
"isActive": true,
"organizationId": "6640a1b2c3d4e5f6a7890001",
"createdAt": "2025-05-15T09:00:00.000Z",
"updatedAt": "2025-05-15T09:00:00.000Z"
}Update a MongoDB Action
curl -X PATCH /api/mongo-actions/6644b2c3d4e5f6a7b8901234 \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"operation": "updateOne",
"filter": "{ "orderId": "{{payload.order.id}}" }",
"document": "{ "$set": { "lastStatus": {{response.status}}, "updatedAt": "{{payload.timestamp}}" } }"
}'Response
{
"_id": "6644b2c3d4e5f6a7b8901234",
"name": "Log Orders to MongoDB",
"database": "analytics",
"collection": "webhook_events",
"operation": "updateOne",
"filter": "{ "orderId": "{{payload.order.id}}" }",
"document": "{ "$set": { "lastStatus": {{response.status}}, ... } }",
"inputNodes": [{ "nodeType": "webhook", "nodeId": "6642f1a2c3b4d5e6f7890123" }],
"isActive": true,
"organizationId": "6640a1b2c3d4e5f6a7890001",
"createdAt": "2025-05-15T09:00:00.000Z",
"updatedAt": "2025-05-15T10:30:00.000Z"
}Canvas Integration
On the visual canvas, the MongoDB Action node uses the type mongo-action and is rendered with a green color scheme. Connect it to any webhook node to persist data after deliveries.
The node displays the action name, database/collection path, and the operation type. Edges from webhooks flow into the MongoDB action node.
triggerOn: always to create a complete log of every webhook delivery, including failures, for later analysis.Payload Examples
insertOne — Full Event Log
{
"eventType": "{{payload.type}}",
"orderId": "{{payload.order.id}}",
"customer": {
"email": "{{payload.customer.email}}",
"name": "{{payload.customer.name}}"
},
"amount": {{payload.order.total}},
"deliveryStatus": {{response.status}},
"responseBody": "{{response.body}}",
"receivedAt": "{{payload.timestamp}}"
}updateOne — Upsert Order Status
{ "orderId": "{{payload.order.id}}" }{
"$set": {
"lastDeliveryStatus": {{response.status}},
"lastEventType": "{{payload.type}}",
"updatedAt": "{{payload.timestamp}}"
},
"$inc": { "deliveryCount": 1 }
}findOneAndUpdate — Update and read back
{ "externalId": "{{payload.id}}" }{
"$set": {
"type": "{{payload.type}}",
"status": {{response.status}},
"updatedAt": "{{payload.timestamp}}"
}
}The updated document comes back in the node's output, so the next node can read the new state without a second query.
findAll — Everything matching, with a count
{ "customerId": "{{payload.customerId}}", "status": "open" }Turn on include count to get the total alongside the documents. Remember the 1000-document ceiling.
aggregate — Group without shipping rows
[
{ "$match": { "customerId": "{{payload.customerId}}" } },
{ "$group": { "_id": "$status", "total": { "$sum": "$amount" } } },
{ "$sort": { "total": -1 } }
]Use Cases
Webhook Event Archival
Store every incoming webhook event and its delivery result in a MongoDB collection for long-term archival and compliance. Use insertOne with triggerOn: always to capture both successes and failures.
Real-Time Analytics Pipeline
Insert delivery data into a collection that feeds a real-time analytics dashboard. Include response times, status codes, and payload metadata to track integration health.
Idempotent State Updates
Use updateOne with a filter on a unique payload field (like an order ID) to maintain current state in MongoDB. Each delivery updates the record instead of creating duplicates.
Data Synchronization
Use findOneAndUpdate to keep a MongoDB collection in sync with an external system: each webhook writes the new values and hands the resulting document to the next node, so the flow can react to what actually landed rather than to what it hoped to write.
API Reference
| Method | Webhook | Description |
|---|---|---|
| GET | /api/mongo-actions | List all MongoDB actions for your organization |
| POST | /api/mongo-actions | Create a new MongoDB action |
| GET | /api/mongo-actions/:id | Get a single MongoDB action by ID |
| PATCH | /api/mongo-actions/:id | Update a MongoDB action |
| DELETE | /api/mongo-actions/:id | Delete a MongoDB action |