The HTTP Request node is the most powerful tool in n8n. While n8n offers 400+ pre-built integrations, the HTTP Request node lets you connect to any APIâeven ones without dedicated nodes.
Need to pull data from an internal company API? Send webhooks to a custom service? Integrate with a niche tool that doesnât have an n8n node? The HTTP Request node handles it all, no coding required.
This guide covers everything you need to master API calls in n8n: authentication, headers, pagination, error handling, and real-world examples you can adapt to your workflows.
When to Use the HTTP Request Node
Before diving into how, letâs clarify when:
| Scenario | Use HTTP Request? |
|---|---|
| Service has a dedicated n8n node | Noâuse the built-in node for easier setup |
| Service has no n8n node | YesâHTTP Request is your only option |
| Built-in node missing a feature you need | YesâHTTP Request gives full API access |
| Calling internal/private APIs | Yesâno built-in nodes for custom APIs |
| Webhooks to custom endpoints | Yesâperfect for sending data anywhere |
Rule of thumb: Start with built-in nodes when available. Switch to HTTP Request when you need more control or when no node exists.
Understanding API Requests
Every HTTP request has four key components:
- URL: Where the request goes (e.g.,
https://api.example.com/users) - Method: What action to perform (GET, POST, PUT, DELETE)
- Headers: Metadata about the request (authentication, content type)
- Body: Data youâre sending (for POST/PUT requests)
Think of it like sending a letter:
- URL = the address
- Method = âplease read thisâ vs. âplease update my accountâ
- Headers = the envelope information
- Body = the letter contents
Your First HTTP Request
Letâs start with something simple: fetching data from a public API.
Step 1: Add the HTTP Request Node
- Open your n8n workflow
- Click + to add a node
- Search for âHTTP Requestâ
- Click to add it
Step 2: Configure a GET Request
Weâll fetch a random user from the free JSONPlaceholder API:
- Method: GET (this is the default)
- URL:
https://jsonplaceholder.typicode.com/users/1 - Leave everything else as default
- Click Test step
Step 3: Read the Response
Youâll see a JSON response like:
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]",
"address": {
"street": "Kulas Light",
"city": "Gwenborough"
}
}
You can now use this data in subsequent nodes with expressions like:
{{ $json.name }}â âLeanne Grahamâ{{ $json.email }}â â[email protected]â{{ $json.address.city }}â âGwenboroughâ
Common Beginner Mistakes
Mistake 1: Forgetting the protocol
â api.example.com/users
â
https://api.example.com/users
Mistake 2: Wrong method for the operation
â Using GET when the API expects POST
â
Check the API documentation for the correct method
Mistake 3: Not testing before connecting other nodes
â Building a full workflow, then discovering the API call fails
â
Always click "Test step" on the HTTP Request node first
HTTP Methods Explained
Different HTTP methods tell the API what action you want to perform:
GET: Retrieve Data
Use GET to fetch information without changing anything.
GET https://api.example.com/users
GET https://api.example.com/orders/123
GET https://api.example.com/products?category=electronics
Key points:
- No request body needed
- Parameters go in the URL (query strings)
- Safe to repeatâdoesnât change data
POST: Create or Send Data
Use POST to create new records or send data to be processed.
POST https://api.example.com/users
Body: { "name": "John", "email": "[email protected]" }
Key points:
- Requires a request body
- Creates new resources
- Not idempotentârepeating may create duplicates
PUT/PATCH: Update Data
Use PUT to replace a resource entirely, PATCH to update specific fields.
PUT https://api.example.com/users/123
Body: { "name": "John Updated", "email": "[email protected]" }
PATCH https://api.example.com/users/123
Body: { "email": "[email protected]" }
Key points:
- PUT replaces the entire resource
- PATCH updates only specified fields
- Both require a request body
DELETE: Remove Data
Use DELETE to remove resources.
DELETE https://api.example.com/users/123
Key points:
- Usually no request body needed
- Irreversibleâbe careful with automation
- Some APIs use POST with a delete action instead
Quick Reference Table
| Method | Purpose | Has Body? | Idempotent? |
|---|---|---|---|
| GET | Retrieve data | No | Yes |
| POST | Create/send data | Yes | No |
| PUT | Replace resource | Yes | Yes |
| PATCH | Partial update | Yes | Yes |
| DELETE | Remove resource | Rarely | Yes |
Authentication: Connecting to Protected APIs
Most APIs require authentication to prove who you are. The HTTP Request node supports multiple authentication methods.
No Authentication
Some APIs are public and require no authentication:
- Leave Authentication set to âNoneâ
- Enter the URL and send your request
Examples: Public weather APIs, JSONPlaceholder, some government data APIs.
API Key Authentication
The most common method for simple APIs. The API key can be sent in different places:
Option 1: API Key in Header
- Set Authentication to âGeneric Credential Typeâ
- Select âHeader Authâ
- Create credentials with:
- Name: The header name (e.g.,
X-API-Key,Authorization) - Value: Your API key
- Name: The header name (e.g.,
Or manually add the header:
- Expand Options â Headers
- Add your header:
Name: X-API-Key Value: your-api-key-here
Option 2: API Key in Query String
Some APIs want the key in the URL:
https://api.example.com/data?api_key=your-api-key-here
In n8n:
- Expand Options â Query Parameters
- Add:
Name: api_key Value: your-api-key-here
Bearer Token Authentication
Common for OAuth 2.0 and JWT-based APIs:
- Set Authentication to âGeneric Credential Typeâ
- Select âHeader Authâ
- Create credentials:
- Name:
Authorization - Value:
Bearer your-token-here
- Name:
Or predefined:
- Set Authentication to âPredefined Credential Typeâ
- Select âHeader Authâ
- Configure with your token
Basic Authentication
For APIs using username/password:
- Set Authentication to âGeneric Credential Typeâ
- Select âBasic Authâ
- Enter your username and password
n8n automatically encodes these as a Base64 header.
OAuth 2.0
For services requiring OAuth flows (Google, Microsoft, Salesforce):
- Set Authentication to âPredefined Credential Typeâ
- Search for and select the OAuth2 credential type
- Follow the OAuth flow to authorize
For detailed troubleshooting, see our guide to fixing n8n authentication errors.
Authentication Comparison
| Method | Security | Complexity | Best For |
|---|---|---|---|
| None | Low | Easy | Public APIs |
| API Key | Medium | Easy | Most third-party APIs |
| Bearer Token | High | Medium | Modern REST APIs |
| Basic Auth | Medium | Easy | Legacy systems |
| OAuth 2.0 | High | Complex | User-context APIs |
Headers: The Hidden Power
Headers carry metadata about your request. While n8n sets many automatically, some APIs require custom headers.
Content-Type Header
Tells the API what format your request body is in:
| Content-Type | When to Use |
|---|---|
application/json | JSON data (most common) |
application/x-www-form-urlencoded | Form data |
multipart/form-data | File uploads |
text/plain | Plain text |
n8n sets Content-Type: application/json automatically when you use JSON body. Override it in Options â Headers if needed.
Common Custom Headers
Accept: application/json // What format you want back
X-Request-ID: unique-id-123 // For request tracking
User-Agent: MyApp/1.0 // Identify your application
Cache-Control: no-cache // Bypass caching
Dynamic Headers with Expressions
Use expressions to set headers dynamically:
// Header value from previous node
{
{
$("Previous Node").item.json.apiKey;
}
}
// Current timestamp
{
{
Date.now();
}
}
// Computed signature
{
{
$json.computedSignature;
}
}
This is useful when APIs require signed requests or dynamic tokens. If youâre building complex expressions, our expression validator tool can help catch errors before runtime.
Request Body: Sending Data
For POST, PUT, and PATCH requests, you need to send data in the body.
JSON Body (Most Common)
- Set Body Content Type to âJSONâ
- Add your JSON:
{
"name": "New Customer",
"email": "[email protected]",
"plan": "premium"
}
Using Expressions in JSON
Make your request body dynamic using data from previous nodes:
{
"name": "{{ $json.customerName }}",
"email": "{{ $json.customerEmail }}",
"orderId": "{{ $('Order Node').item.json.id }}",
"timestamp": "{{ $now.toISO() }}"
}
Form Data
For APIs expecting form submissions:
- Set Body Content Type to âForm Urlencodedâ
- Add key-value pairs in the form fields
Common JSON Errors
Error: âJSON parameter need to be an valid JSONâ
This happens when expressions break JSON syntax. Wrap the entire object in expression brackets:
{{
{
"name": $json.name,
"items": $json.items
}
}}
If youâre struggling with malformed JSON, try our JSON fixer tool to identify and correct formatting issues.
Error: Values not substituting
Make sure expressions are inside the JSON, not outside:
â {{ { "name": "John" } }}
â
{ "name": "{{ $json.firstName }}" }
Handling API Responses
Once your request succeeds, you need to work with the response data.
Accessing Response Data
The response becomes available as $json in subsequent nodes:
// Access top-level properties
{
{
$json.id;
}
}
{
{
$json.status;
}
}
// Access nested properties
{
{
$json.data.user.name;
}
}
{
{
$json.results[0].title;
}
}
// Access array items
{
{
$json.items[0];
}
}
{
{
$json.items.length;
}
}
Handling Different Response Formats
JSON Response (Default)
Most APIs return JSON. n8n parses it automatically:
{
{
$json.propertyName;
}
}
Array Response
If the API returns an array, each item becomes a separate n8n item:
[
{ "id": 1, "name": "Item 1" },
{ "id": 2, "name": "Item 2" }
]
Both items flow through your workflow separately.
Binary Response (Files)
For file downloads, enable âResponse Formatâ â âFileâ in options. The file becomes available as binary data for use with file nodes.
Checking Response Status
To access the HTTP status code, enable Options â Full Response:
{
{
$json.statusCode;
}
} // 200, 404, 500, etc.
{
{
$json.headers;
}
} // Response headers
{
{
$json.body;
}
} // The actual response data
Pagination: Getting All Your Data
Many APIs limit how much data they return per request. Pagination lets you fetch all results across multiple requests.
Why APIs Paginate
Returning 10,000 records at once would be slow and memory-intensive. Instead, APIs return pages of results (e.g., 100 at a time) with information about how to get the next page.
n8nâs Built-in Pagination
The HTTP Request node has automatic pagination support:
- Expand Options â Pagination
- Choose your pagination type
Offset-Based Pagination
APIs that use offset and limit parameters:
Page 1: /api/items?offset=0&limit=100
Page 2: /api/items?offset=100&limit=100
Page 3: /api/items?offset=200&limit=100
Configure in n8n:
- Pagination Mode: Offset
- Limit Parameter:
limit - Offset Parameter:
offset - Page Size:
100
Cursor-Based Pagination
APIs that return a nextCursor or next_page token:
{
"data": [...],
"nextCursor": "abc123xyz"
}
Configure in n8n:
- Pagination Mode: Cursor
- Next URL:
{{ $response.body.nextCursor }}or the next page URL
Page Number Pagination
APIs that use page numbers:
Page 1: /api/items?page=1
Page 2: /api/items?page=2
Configure using expressions:
- Next Page URL Expression: Include
{{ $pageCount + 1 }}in your URL
Pagination Best Practices
- Set a maximum: Configure âMax Pagesâ to prevent infinite loops
- Add delays: Some APIs require delays between requests (see our rate limiting guide)
- Monitor performance: Paginating through thousands of items takes time
Error Handling and Retry
API calls can fail for many reasons. n8n provides tools to handle errors gracefully.
Common HTTP Error Codes
| Code | Meaning | Typical Cause |
|---|---|---|
| 400 | Bad Request | Malformed request or invalid data |
| 401 | Unauthorized | Invalid or expired credentials |
| 403 | Forbidden | Valid credentials, insufficient permissions |
| 404 | Not Found | Resource doesnât exist |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Server Error | API-side problem |
| 503 | Service Unavailable | API temporarily down |
Retry on Failure
Enable automatic retries for transient failures:
- Expand Options â Retry on Fail
- Set Max Tries: How many times to retry (e.g., 3)
- Set Wait Between Tries: Delay in milliseconds (e.g., 1000)
This handles temporary network issues and brief API outages automatically.
Continue on Fail
If you want the workflow to continue even when the HTTP Request fails:
- Open node Settings (gear icon)
- Enable Continue On Fail
The node outputs an error object instead of stopping the workflow:
{
{
$json.error;
}
} // Error message
{
{
$json.statusCode;
}
} // HTTP status code
Error Trigger Workflow
For complex error handling, use the Error Trigger node:
- Create a separate workflow with Error Trigger
- Configure it to run when your main workflow fails
- Send notifications, log errors, or trigger recovery actions
For timeout-related errors, check our timeout troubleshooting guide.
Real-World Examples
Example 1: Fetching Data from a REST API
Scenario: Get all products from your e-commerce API
Method: GET
URL: https://api.mystore.com/products
Authentication: Header Auth (X-API-Key)
Response handling:
// Filter to in-stock items in next node
{
{
$json.items.filter((item) => item.inStock);
}
}
Example 2: Posting Data to a Webhook
Scenario: Send form submission to a custom endpoint
Method: POST
URL: https://hooks.mycompany.com/form-handler
Content-Type: application/json
Body:
{
"formId": "{{ $json.formId }}",
"submittedAt": "{{ $now.toISO() }}",
"data": {
"name": "{{ $json.name }}",
"email": "{{ $json.email }}",
"message": "{{ $json.message }}"
}
}
Example 3: Authenticated API with Pagination
Scenario: Sync all contacts from a CRM
Method: GET
URL: https://api.crm.com/v1/contacts
Authentication: Bearer Token
Pagination:
- Mode: Cursor
- Next URL: {{ $response.body.pagination.next }}
- Complete When: {{ !$response.body.pagination.hasMore }}
Example 4: Downloading a File
Scenario: Download a report PDF
Method: GET
URL: https://api.reports.com/export/monthly.pdf
Authentication: API Key
Options:
- Response Format: File
- Put Output in Field: data
The PDF becomes available as binary data for use with Google Drive, S3, or email nodes.
Pro Tips and Best Practices
1. Test Before Building
Always click âTest stepâ on your HTTP Request node before connecting other nodes. This verifies:
- The URL is correct
- Authentication works
- The response format matches expectations
Use our workflow debugger to catch issues across your entire workflow.
2. Use Variables for URLs
Donât hardcode URLs. Store base URLs in credentials or use expressions:
// If you have the base URL from a previous node or variable
{{ $vars.apiBaseUrl }}/users/{{ $json.userId }}
This makes switching between staging and production easier.
3. Keep Credentials Secure
Never put API keys directly in the URL or body. Use n8n credentials:
â https://api.example.com/data?key=sk_live_1234567890
â
Use Header Auth credential with your API key
See our self-hosting mistakes guide for more security best practices.
4. Handle Empty Responses
Some APIs return empty responses (204 No Content). Handle these gracefully:
{
{
$json.data ? $json.data : [];
}
}
5. Log Important Requests
For debugging and auditing, log critical API calls:
- Add a Set node after HTTP Request
- Include request details, response status, and timestamp
- Send to a logging service or database
6. Respect Rate Limits
Many APIs limit requests per minute/hour. Read the rate limiting guide to:
- Understand limit headers
- Implement throttling
- Handle 429 errors gracefully
When to Get Help
The HTTP Request node handles most API integration needs. But some scenarios benefit from expert help:
- Complex OAuth flows with multiple authorization steps
- SOAP/XML APIs with strict schema requirements
- GraphQL APIs needing optimized queries
- Webhooks requiring cryptographic signature verification
Our workflow development services and consulting packages can accelerate complex integrations.
For best practices on structuring workflows, see our n8n workflow best practices guide.
Frequently Asked Questions
When should I use HTTP Request instead of a built-in node?
Use the HTTP Request node when: (1) no dedicated node exists for your service, (2) the built-in node doesnât support the specific endpoint or feature you need, (3) youâre connecting to internal/private APIs, or (4) you need more control over headers, authentication, or request formatting than the built-in node provides. Start with built-in nodes when availableâthey handle authentication and pagination automaticallyâand switch to HTTP Request only when you hit limitations.
How do I debug failed HTTP requests in n8n?
Start by clicking âTest stepâ on the HTTP Request node to see the exact error. Enable Options â Full Response to see the status code, headers, and raw response body. Common debugging steps: (1) verify the URL is correct and includes https://, (2) check authentication credentials are valid and not expired, (3) test the same request in Postman or curl to isolate whether the issue is n8n-specific, (4) check the API documentation for required headers or parameters you might be missing. For persistent issues, try our workflow debugger tool.
Can I download files using the HTTP Request node?
Yes. Set Options â Response Format to âFileâ and the binary data will be available for use with file-handling nodes (Google Drive, S3, FTP, Email attachments). You can also specify which field the binary data should be stored in using âPut Output in Fieldâ. For large files, consider increasing the node timeout in Settings â Timeout to prevent timeouts during download.
How do I handle APIs that require multiple authentication steps?
Some APIs require a preliminary request to obtain an access token before making the actual API call. Build this as a two-step process: (1) First HTTP Request node gets the token from the auth endpoint, (2) Second HTTP Request node uses that token in the Authorization header. For OAuth 2.0 flows with refresh tokens, n8nâs built-in OAuth2 credential type handles token refresh automatically. For truly complex auth (like AWS Signature V4), you may need a Function node to compute the signature before the HTTP Request.
Why does my API request work in Postman but not in n8n?
The most common causes are: (1) Header differencesâPostman may be sending headers youâre not replicating in n8n, like Accept or User-Agent. Enable âFull Responseâ and compare headers. (2) Body formattingâPostman automatically formats JSON while n8n expressions might break JSON syntax. Validate your JSON structure. (3) Authentication timingâOAuth tokens might expire between getting them and using them. (4) URL encodingâspecial characters in URLs might be encoded differently. Try URL-encoding parameters manually if needed. (5) SSL issuesâif youâre hitting internal APIs with self-signed certificates, you may need to disable SSL verification in node options (not recommended for production).