Maintaining original data when using n8n workflow nodes

I’m working with n8n workflows and running into an issue where my original input data gets lost when I process it through certain nodes. I’m particularly having trouble with an API request node where I need to keep track of specific identifiers from the initial data. The main problem is that after making the API call, I lose important fields like the record ID that I need later for matching and combining data from different sources. I want to pass through some of the original fields alongside the new data I get from the API response. Here’s an example of my API request configuration:

{
  "outputFormat": "json",
  "extractMainContent": true,
  "waitTime": 5000,
  "deviceType": "desktop",
  "validateSSL": true,
  "requestTimeout": 45000,
  "region": {
    "locale": "EN"
  },
  "adBlocking": false,
  "targetUrl": "{{ $json.company_domain }}",
  "customActions": []
}

I need to preserve the company_id field from my input data so I can use it in subsequent workflow steps. What’s the best way to achieve this in n8n workflows?

ohh totally! i also faced that, just enable the ‘keep only set’ in the HTTP node - it helps merge your original data with API results. and make sure ur syntax is correct like {{ $node["previous_node"].json.company_id }} to pull the fields u need.

I’ve had the same data loss issues. The Code node approach works great for this - just drop one right after your API request and build exactly what you need. You can grab the original data from previous nodes plus the API response, then return a combined object. Something like return { ...items[0].json, api_result: $input.item.json } gives you complete control over what gets preserved. It’s especially handy when you need to transform or rename fields during the merge, and way more predictable than those node settings that randomly break.

The merge node works great here. After your API request, add a merge node and set it to combine your original input with the API response. Use ‘append’ or ‘merge by fields’ depending on what you need. This keeps your company_id and other original fields while adding the new API data. I use this all the time when joining multiple data sources later in the workflow. You could also use a Set node before the API call to define which fields to carry forward, then reference them with expressions like {{ $node["Set"].json.company_id }} in other nodes.