📡 Lesson 5 of 12  ·  N8N Automation

HTTP Requests &
Working with APIs

Connect N8N to any web service using the HTTP Request node. Learn REST methods, authentication patterns, and N8N's powerful expression system to chain data between nodes.

HTTP Methods (GET/POST/PUT/DELETE) Authentication Types N8N Expressions JSON Parsing Node Chaining

🌐 REST API Basics in N8N

The HTTP Request node is your universal connector in N8N. It speaks REST — the language of the web — letting you talk to virtually any API that has a URL. Every API operation maps to one of four core HTTP methods, each with a specific purpose.

5
HTTP Methods
APIs Supported
1
Node To Rule Them All
MethodActionWhen to UseHas Body?
GET Read data Fetch a user, list records, get weather data No
POST Create data Submit a form, create a record, send a message Yes
PUT Replace data Update an entire record, replace file content Yes
PATCH Partial update Update only specific fields of a record Yes
DELETE Remove data Delete a record, remove a file, cancel subscription Sometimes
💡
CRUD Maps Directly to HTTP Methods
Remember: Create = POST  |  Read = GET  |  Update = PUT/PATCH  |  Delete = DELETE. Most APIs follow this REST convention, making it easy to predict the right method for any operation.

Key Fields in the HTTP Request Node

Open any HTTP Request node in N8N and you'll see these core configuration fields. Each plays a distinct role in building your API call:

🔗
URL
The full API endpoint address
Method
GET / POST / PUT / DELETE
📋
Headers
Content-Type, auth tokens
📖
Query Params
URL ?key=value pairs
📦
Body
JSON, form data, raw text
🔒
Auth
N8N credential reference
🔄
Options
Timeout, retry, redirects
🎯
Response
Auto-parse JSON / binary

🔒 Authentication Methods

Most APIs require authentication to verify who is making the request. N8N supports all major auth methods through its Credentials system — storing secrets encrypted so they never appear in plain text in your workflow JSON.

🗹
API Key
A static secret token passed as a request header (X-API-Key) or query parameter (?api_key=...). The most common method for simple APIs like OpenWeather, SendGrid, and many SaaS platforms.
Most Common
🎫
Bearer Token
Passed in the Authorization header as "Bearer {token}". Used by modern REST APIs and services issuing JWT tokens — including GitHub, Stripe, and custom backends.
Very Common
👤
Basic Auth
A username and password encoded in Base64 and sent in the Authorization header. An older standard still used by some services, CMS tools, and internal APIs.
Legacy
🔐
OAuth 2.0
The industry standard for delegated access. The user grants permission, and N8N handles the full token exchange and automatic refresh. Required by Google, Slack, Microsoft, and most enterprise APIs.
Enterprise
⚠️
Always Use N8N Credentials — Never Paste Raw Keys
Never paste an API key directly into a node field — it will appear in plain text in your workflow export. Create a Credential in N8N Settings, then reference it from the node. Credentials are encrypted, reusable, and easy to rotate without editing every workflow.

Example: Configuring Headers for Different Auth Types

HTTP Headers
// API Key in header (most common)
X-API-Key: sk_live_your_secret_api_key
Content-Type: application/json

// Bearer Token (JWT / OAuth access token)
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

// Basic Auth — N8N auto-encodes username:password
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=

// API Key as query param (some older APIs)
GET https://api.example.com/data?apikey=your_key

N8N Expressions

Expressions are N8N's superpower for chaining nodes together. Wrap any value in {{ }} double curly braces to make it dynamic. Reference data from any previous node, call built-in functions, and perform calculations — all inline inside node configuration fields.

{{ $json.name }}
Access the current node's incoming data. $json always refers to the current item's JSON payload — the most frequently used expression in N8N.
{{ $node["HTTP Request"].json.data[0].id }}
Reference data from a specific named node anywhere in the workflow. Navigate nested JSON with dot notation and array indices. The node name must match exactly.
{{ $now.toISO() }}
Built-in date/time via Luxon. $now is the current timestamp. Chain methods like .toFormat('yyyy-MM-dd') or .plus({days:7}) for powerful date manipulation.
{{ $items().length }}
Count the total items flowing through the workflow at this point. Use for logging, conditional batch size checks, or capping output quantities.
{{ $json.price * 1.2 }}
Inline math — expressions are full JavaScript. Perform arithmetic, string concatenation, ternary conditionals, and more without needing a separate Code node.
{{ $json.email.toLowerCase().trim() }}
Chain JS string methods directly in the field. Clean and normalize text data on the fly — no extra node required for simple transformations.
🪄
Use the Expression Editor for Autocomplete
Click the fx button next to any node field to open the Expression Editor. It shows a live preview of the output as you type, and provides field autocomplete from all previous nodes. Massively speeds up building complex expressions!

📦 Parsing JSON Responses

When an API responds, N8N automatically parses the JSON body and makes it available as $json in the next node. Navigate nested objects and arrays using dot notation in your expressions.

Example API Response Structure

{ "status": "success", "data": { "users": [ { "id": 1, "name": "Alice", "role": "admin" }, { "id": 2, "name": "Bob", "role": "user" } ], "total": 2, "page": 1 } }
{{ $json.status }}
Top-level field access → returns "success"
{{ $json.data.total }}
Nested object access → returns 2
{{ $json.data.users[0].name }}
Array index + field → returns "Alice"
{{ $json.data.users.map(u => u.name).join(', ') }}
Map + join array → returns "Alice, Bob"
📌
Split Arrays into Individual N8N Items
If the API returns an array of objects in the response body, use the Split Out node to turn the array into separate N8N items — one per object. Each downstream node then processes each user/record individually, which is the idiomatic N8N pattern.

🔄 Complete API Workflow Pattern

Here's the canonical pattern for making an API call in N8N: trigger the workflow, make the HTTP request, route based on the response, transform the data, and deliver the result.

API Request Workflow — Node by Node
🕐 Trigger
Schedule / Webhook
📡 HTTP Request
GET /api/users
⇄ IF Node
status == "success"
⚙️ Set Node
Format fields
✅ Response
Return result
IF false path: Log error to sheet → Send Slack/email alert to team
🕐
1. Trigger
Starts the workflow. Could be a schedule, a webhook call, or an app event like "new form submission".
Entry Point
📡
2. HTTP Request
Calls the external API with the configured method, headers, and body. Returns the JSON response.
Core Node
3. IF Node
Routes the flow based on the response status code or a field value. TRUE path continues, FALSE handles errors.
Logic
⚙️
4. Set Node
Maps and renames API response fields into your desired output structure using expressions.
Transform
🧠 Quick Knowledge Check

1. Which HTTP method is used to create new data in an API?

A GET — reads existing data
B POST — creates new resources
C DELETE — removes data
D PATCH — partially updates data

2. How do you reference the current node's data in an N8N expression?

A [data.field]
B {{ $json.field }}
C (input.field)
D #field

3. Which N8N node is used to call an external web API?

A Set Node
B Webhook Node
C HTTP Request Node
D Code Node
← Lesson 4: Triggers & Events