Automatically Enrich Object Lists with Detail Data via JSON POST
Automate enriching a base list with detail data through a secured webhook. Send two lists as JSON—the workflow validates input, links entries by ID, and returns an enriched result list or a clear error message. Ideal for teams regularly merging data from various sources with emphasis on traceability and error handling.
This workflow targets users who regularly merge two data lists—such as from CRM, ERP, or other systems—based on a common ID. Via a secured webhook endpoint (POST /enrich-list, Basic Auth), you can send a base list and a detail list as JSON. The workflow checks if both lists are correctly provided, creates a lookup for the detail data, and enriches the base objects with matching detail information. Faulty or incomplete inputs receive a clear error message (HTTP 400). On success, you receive an enriched list as JSON (HTTP 200). Authentication is handled via n8n credentials and must be set up before production use. Execution data is stored in n8n—please configure retention and access rights according to your data protection requirements. The workflow is flexibly adaptable for various use cases, such as marketing, sales, or data management.
AI-generated image
Installation
1. Import the workflow into your n8n instance.
2. Open the workflow and activate the test webhook listener in the Webhook node ("enrich-list").
3. Copy the displayed test URL and send a POST request with Content-Type application/json and the following example body:
```json
{
"baseList": [
{"id": "A1", "name": "Station Alpha"},
{"id": "B2", "name": "Station Beta"}
],
"details": [
{"id": "A1", "location": "Berlin", "status": "active"},
{"id": "B2", "location": "Hamburg", "status": "inactive"}
]
}
```
4. The response should be as follows:
```json
{
"status": "success",
"result": {
"enrichedList": [
{"id": "A1", "name": "Station Alpha", "location": "Berlin", "status": "active"},
{"id": "B2", "name": "Station Beta", "location": "Hamburg", "status": "inactive"}
]
}
}
```
HTTP status: 200
5. Test error case: For example, send only an empty object:
```json
{}
```
Response:
```json
{
"status": "error",
"message": "Feld \"baseList\" (Array) fehlt"
}
```
HTTP status: 400
6. After successful testing, publish/activate the workflow and use the production URL from the Webhook node.
7. Before production use: Set up your own webhook authentication (e.g., Basic Auth) in the Webhook node to prevent unauthorized access. Note that n8n stores execution data; configure retention and access as needed.
Usage
1. Send a POST request with Content-Type application/json to the webhook path /enrich-list. For testing, use the test URL of the Webhook node; for production, use the production URL.
2. The request body must be a JSON object containing the fields baseList (array of objects with id) and details (array of objects with id). The id can be a string or number.
3. For each object in baseList, the matching object from details is searched by id (comparison as string). Fields from details overwrite identically named fields in baseList. If no matching detail exists, the base object remains unchanged. The order remains as in baseList. An empty baseList results in an empty enrichedList and is not an error.
4. If baseList or details is missing or not an array, the response is HTTP 400 with an error message. Invalid entries within the lists are ignored.
5. The interface processes only the data sent in the JSON body. No external APIs are queried. Authentication must be enabled in the Webhook node before public operation. n8n stores execution data by default, which may contain payload data.
Example of a successful request (HTTP 200):
```json
{
"baseList": [
{"id": "A1", "name": "Station Alpha"},
{"id": "B2", "name": "Station Beta"}
],
"details": [
{"id": "A1", "location": "Berlin", "status": "active"},
{"id": "B2", "location": "Hamburg", "status": "inactive"}
]
}
```
Expected response (HTTP 200):
```json
{
"status": "success",
"result": {
"enrichedList": [
{
"id": "A1",
"name": "Station Alpha",
"location": "Berlin",
"status": "active"
},
{
"id": "B2",
"name": "Station Beta",
"location": "Hamburg",
"status": "inactive"
}
]
}
}
```
Example of an error case (HTTP 400):
```json
{
"details": [
{"id": "A1", "location": "Berlin"}
]
}
```
Expected response (HTTP 400):
```json
{
"status": "error",
"message": "Feld \"baseList\" (Array) fehlt"
}
```
Limitations: Enrichment is based solely on id fields, with comparison always as string. No duplicates are removed or ranges summed. The interface does not check other field contents or types. The API compares only data structure, not semantics of other interfaces.
Required connections and APIs
API connections
No saved API credentials were detected in the workflow JSON. Still check webhooks, target systems, credentials, and data protection before activation.
Nodes
WebhookCodeIfRespond to Webhook
Isolated functional test passed
Optional isolated functional test
The isolated data flow was tested without external services or credentials.
✓ two_matching_recordsChecks a documented data case for this workflow.Isolated functional test passed✓ missing_base_listChecks a documented data case for this workflow.Isolated functional test passed✓ missing_detailsChecks a documented data case for this workflow.Isolated functional test passed✓ empty_listsChecks a documented data case for this workflow.Isolated functional test passed✓ numeric_string_id_and_overrideChecks a documented data case for this workflow.Isolated functional test passed