Module 2 of 6 — Advanced

API Chaining Automation – Build Multi-Step Workflows That Connect Any API to Any API

Master API chaining in n8n — connect multiple REST APIs in sequence, transform data between steps, handle authentication, and build production pipelines that actually work.

14 min read Jan 8, 2026 5 Steps Advanced Level
Step-by-Step Instructions
1
Step 1 — Understand API Chaining Fundamentals

API chaining means taking the output of one API call and using it as the input for the next. In n8n, every HTTP Request node output is automatically available to all downstream nodes via expressions like {{ $node["Get Customer"].json.id }}.

The key principle: each node in the chain should do exactly one thing. "Get customer data" is one node. "Create invoice using customer data" is the next node. "Send invoice PDF via email" is the third node. Never combine multiple API operations in a single HTTP Request node.

This granularity makes debugging easy — you can see exactly which API call failed and with what data, and you can retry individual nodes without re-running the entire chain.

2
Step 2 — Set Up Authentication for Each API

Most production APIs require authentication. n8n stores credentials securely and makes them available to HTTP Request nodes. Set up your credentials first before building the workflow — this avoids interruption mid-build.

For Bearer Token APIs (most modern REST APIs): go to Credentials → New → Header Auth. Set the header name to Authorization and the value to Bearer YOUR_API_KEY.

For OAuth2 APIs (Google, Slack, HubSpot): use n8n's built-in OAuth2 credential type. n8n handles token refresh automatically.

For APIs that require a token from a login endpoint: add an HTTP Request node at the start of your workflow that logs in and retrieves the token. Use a Set node to extract the token, then reference it in subsequent requests: {{ $node["Get Auth Token"].json.access_token }}

3
Step 3 — Build the Chain with Correct Data References

After each HTTP Request node, n8n automatically provides its response JSON. Reference previous nodes' data using the expression panel.

In the HTTP Request node for step 2 of your chain, open the Body field and switch to "Expression" mode. Reference the first API's output: {{ $node["Step 1: Get Lead"].json.data.id }}

For nested data: {{ $node["Step 1"].json.customer.address.city }}

For arrays, use a SplitInBatches node or Item Lists node before your next HTTP Request to iterate over each item in the array. This lets you make one API call per array item automatically.

Common pattern for "get list, process each item":

HTTP Request → Get All Products (returns array)
Item Lists → Split into individual items
HTTP Request → Update each product price (runs once per item)
Merge → Collect all results
4
Step 4 — Handle Rate Limits and Pagination

Production APIs enforce rate limits. To handle them in n8n, add a Wait node set to 1-2 seconds between your HTTP Request nodes when processing large batches. This prevents 429 "Too Many Requests" errors.

For paginated APIs, use a Loop pattern: a Code node checks if next_page_token exists in the response. If yes, the workflow loops back to make another request with the token. If no, it continues downstream.

// Code Node — Check Pagination
const response = $input.first().json;
if (response.next_page_token) {
  return [{ continue: true, token: response.next_page_token }];
} else {
  return [{ continue: false, token: null }];
}
5
Step 5 — Merge Multiple API Results

Often you need data from multiple APIs simultaneously before taking action. For example: customer data from CRM + order history from your database + credit score from a third-party API — all needed together to make a decision.

Run all three API calls in parallel (connect the trigger to all three simultaneously). Then use a Merge node in "Merge By Position" or "Merge By Key" mode to combine the results into a single item.

After merging, a single Set node packages everything into the final shape your action node needs. This pattern is significantly faster than running the API calls in sequence.

Sample Workflow Diagram
Real-World Automation Example
Real-World Example: Lead Enrichment & Multi-CRM Sync

A B2B SaaS company captures leads from multiple sources (website form, LinkedIn ads, webinar signups). Each lead needs to be enriched, verified, and synced across HubSpot, Slack, and their MySQL database — automatically.

1
Webhook receives new lead from any source (form, Zapier forward, or direct API).
2
Clearbit API enriches the email with company data, LinkedIn profile, and estimated revenue — all in one HTTP Request node.
3
Hunter.io API verifies the email address is real and deliverable.
4
Merge node combines enrichment + verification results. IF node routes invalid emails to a "quarantine" branch.
5
Valid leads: HubSpot contact creation, MySQL record insert, Slack notification, and SendGrid email — all fire in parallel.
6
Result: From form submission to fully enriched CRM entry in under 3 seconds, with zero human intervention.
Frequently Asked Questions
How do I pass data from one HTTP Request node to the next?
Use the Expression editor in the next node's body or parameters. Click the gear icon or type {{ to open expressions. Reference the previous node's JSON output as: $node["NodeName"].json.field or simply $json.field if referencing the immediately preceding node's output.
What happens if one API in the chain fails?
By default, n8n stops execution and marks the workflow as failed. You can add Error outputs to individual HTTP Request nodes and route them to error-handling branches — for example, logging the failure and sending a Slack alert while still continuing with a fallback value. Module 5 covers comprehensive error handling patterns.
How do I loop through an array from an API response?
Use the Item Lists node (set to "Split Out Items") to convert an array into individual n8n items. Downstream nodes then run once per item automatically. For large arrays, add a SplitInBatches node before the Item Lists to process in controlled chunks.