How to maintain original data when using n8n nodes?

I’m working with n8n workflows and running into an issue where my original input data gets wiped out after processing through certain nodes, particularly when using API request nodes.

The main problem is that I lose important properties from my initial data, especially ID fields that I need later for data merging operations. For instance, I have a customer_id field in my input that disappears after the node processes.

Here’s an example of my API request payload:

{
  "output": [
    "text"
  ],
  "includeHeaders": false,
  "retryOnFail": true,
  "maxRedirects": 5,
  "followRedirects": true,
  "headers": {
    "Content-Type": "application/json"
  },
  "requestUrl": "{{ $json.company_domain }}",
  "parameters": {}
}

I need to preserve the customer_id value from my input so I can use it in subsequent merge operations. What’s the best approach in n8n to ensure input data carries through to the output alongside the new data returned by the node?

you can also stick the customer_id right in the http request body or headers if your api supports it. it’ll automatically come back with the response - super handy when merge nodes aren’t an option.

I’ve hit this exact problem tons of times with n8n. Most nodes just replace your input data with their response, which kills all your original properties. Here’s what actually works: In your HTTP Request setup, use a Set node right after with this expression: {{ Object.assign({}, $input.all(), $response) }}. It merges everything together perfectly. Or just use a Merge node after the API call - set it to combine mode with your original input on one side and the API response on the other. Both methods keep all your original fields while adding the new API data. Just watch out for duplicate field names when setting up the merge.

Easiest fix is throwing preserve_fields in your request body with the customer_id, then pull it from the response. Beats dealing with messy merges and works with most APIs that echo unknown fields back.

To maintain your original data in n8n, I recommend adding a Set node prior to the API request. This allows you to explicitly specify which fields to retain, such as customer_id, alongside any new data returned from the API. Alternatively, you can utilize the Keep Only Set option in the HTTP Request node settings to select which input fields to include in the output. Being intentional in this process is essential, as different nodes manage data passthrough uniquely, which can lead to unexpected data loss.

Most n8n nodes don’t pass input data through - they just output their own results. I’ve learned to plan for this upfront instead of scrambling to fix it later. Here’s what works: use a Function node before your API call to bundle your original data with the API parameters. Put your preserved fields under something like ‘original_data’. Then after the API response, use another Function node to pull that data back out and flatten it into your final output. This way you control exactly what survives each node, no matter how they handle data internally.

Had the exact same problem! Use the merge node’s “append” mode - don’t try to preserve data through the API node. Feed your original data and API response into separate merge inputs. It’ll combine everything without losing the customer_id fields. Way easier than dealing with set nodes.

The problem is n8n nodes usually only output their results, not the original input data. I found the easiest fix is tweaking the HTTP Request node settings. Go to ‘Options’ and turn on ‘Add Input Data to Output’ - this automatically keeps all your original fields plus the API response without any extra merge steps. If that doesn’t work, try a Code node after your API call with return [{...items[0].json, ...newApiData}]. This lets you control exactly which fields to keep and handles conflicts between your original data and the API response.