Skip to content
New: a free website for your business, live in 48 to 72 hoursWorkflow automation on n8n and Claude, built for your businessFixed price, agreed before we start · Live in 5 to 10 business days30-day money-back guarantee on every planProfessional firms · Agencies · E-commerceYou own every workflow, in your own n8nClaude API: your data is not used for trainingHuman approval on every sensitive stepFree automation audit, no obligation
PURIST
30 days
Money-back window
14 h/wk
Modeled time saved
99.97%
Uptime SLA
< 7 days
Deploy time
PURIST AI
Claude Opus 4.7 · n8n v1.71 · <80ms
What type of business are you running? I'll show you exactly which processes we'd automate first and your estimated ROI.
Powered by n8n + Claude Opus 4.7 Get my free automation plan →
n8n Respond to Webhook: Return JSON, Status Codes, Redirects and Files
Guides 7 min read · 1,578 words

n8n Respond to Webhook: Return JSON, Status Codes, Redirects and Files

Turn an n8n webhook into a real API endpoint: when to respond immediately, after the last node or with the Respond to Webhook node, plus status codes, headers, files and the multi-item trap.

Steve, founder of PURIST

November 6, 2026

PURIST: Stuck on n8n? Our n8n experts fix and build workflows like this one, at a fixed price →

By default an n8n webhook answers "Workflow got started" as soon as it receives a request. That is fine for fire-and-forget events, but not when a form, an app or another system waits for a result. The Webhook node and the Respond to Webhook node let you return exactly what the caller needs: JSON, a status code, headers, a file or a redirect.

In short. In the Webhook node, set Respond to "Using 'Respond to Webhook' Node", then place a Respond to Webhook node where the answer is ready. It answers once, with the first item it receives: aggregate items first if you need to return a list. On n8n Cloud, answer within 100 seconds or the caller gets a 524 error.

n8n Respond to Webhook: Return JSON, Status Codes, Redirects and Files: workflow diagram
An API-style workflow that answers on every branch with the right status code. Illustration: PURIST.

The four response modes of the Webhook node

Respond settingWhat the caller receivesUse it for
ImmediatelyThe response code and "Workflow got started"Events where the sender only needs an acknowledgement
When Last Node FinishesThe output of the last node that ranSimple linear workflows
Using 'Respond to Webhook' NodeWhatever the Respond to Webhook node sendsBranches, custom codes, files, redirects
Streaming responseData streamed as the workflow runsAI agent chats, with nodes that support streaming

"When Last Node Finishes" has a Response Data option: All Entries, First Entry JSON, First Entry Binary or No Response Body.

Set up the Respond to Webhook node

  1. 1 In the Webhook node, set Respond to "Using 'Respond to Webhook' Node".
  2. 2 Add a Respond to Webhook node after the nodes that produce the answer.
  3. 3 Choose "Respond With": All Incoming Items, Binary File, First Incoming Item, JSON, JWT Token, No Data, Redirect or Text.
  4. 4 Add options if needed: Response Code, Response Headers, Put Response in Field.

Example JSON body with an expression:

json
{
  "ok": true,
  "leadId": "{{ $json.id }}",
  "message": "Thanks, we will call you within one business day."
}
n8n Respond to Webhook: Return JSON, Status Codes, Redirects and Files: node settings
A Respond to Webhook node returning JSON with a 201 status and headers. Illustration: PURIST.

Return a proper status code

APIs communicate through status codes. Use the Response Code option:

  • 200 or 201 when the request succeeded or created something;
  • 400 when the input is invalid (missing email, wrong format);
  • 401 or 403 when authentication fails;
  • 409 when the record already exists.

A typical pattern is an IF node right after the Webhook: one branch validates and processes, the other goes to a Respond to Webhook node with code 400 and a clear message such as {"error":"email is required"}.

The multi-item trap

The Respond to Webhook node runs once, using the first item it receives. If the previous node outputs 50 items, the caller gets one. Two documented solutions:

  • Choose "All Incoming Items" in Respond With, which returns every item.
  • Or put an Aggregate node before it ("All Item Data (Into a Single List)") to build one item that contains the list.

What happens in edge cases

The documentation lists the behaviour precisely:

  • The workflow finishes without reaching a Respond to Webhook node: the caller receives a standard message with status 200.
  • The workflow errors before the first Respond to Webhook node: the caller receives an error with status 500.
  • A second Respond to Webhook node runs after the first: it is ignored.

So put the Respond to Webhook node on every branch that should answer, including your error path.

Return a file

Set Respond With to "Binary File" and select the binary property, for example a PDF generated earlier. Add a Content-Disposition response header if the browser should download it rather than display it:

text
Content-Disposition: attachment; filename="quote-812.pdf"

Redirect the user

For form submissions from a website, "Redirect" sends the visitor to a thank-you page. Set Redirect URL to an absolute address.

HTML responses are sandboxed

Since n8n 1.103.0, HTML returned to a webhook is wrapped in a sandboxed iframe. JavaScript cannot access the top window or local storage, basic auth headers are not available inside, and relative URLs do not work. Use absolute URLs, or return JSON and render it on your own site.

Long-running workflows

On n8n Cloud, requests go through Cloudflare. If the webhook does not respond within 100 seconds, the caller receives a 524 error. For long jobs, the documentation recommends two webhooks: one that starts the job and answers immediately with a job ID, and a second one the caller polls for the result.

Worked example: a quote calculator API for your website

Your website has a small form: square metres and service type. You want an instant price shown on the page, computed by n8n.

  1. 1 Webhook: POST /webhook/quote, Respond: "Using 'Respond to Webhook' Node", Allowed Origins (CORS): https://www.yoursite.com.
  2. 2 IF: {{ Number($json.body.sqm) > 0 && ['standard','premium'].includes($json.body.service) }}.
  3. 3 Code (true branch): compute the price.
javascript
const { sqm, service } = $input.first().json.body;
const rate = service === 'premium' ? 42 : 28;
const price = Math.max(150, Math.round(Number(sqm) * rate));
return [{ json: { price, currency: 'USD', service, sqm: Number(sqm) } }];
  1. 1 Respond to Webhook (true branch): JSON { "price": {{ $json.price }}, "currency": "USD" }, code 200.
  2. 2 Respond to Webhook (false branch): JSON { "error": "sqm and service are required" }, code 400.

On the website, a few lines of JavaScript call the webhook and display the price:

javascript
const res = await fetch('https://n8n.example.com/webhook/quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ sqm: 85, service: 'standard' }),
});
const data = await res.json();

The rates in this example are placeholders: use your own.

Respond Immediately, then keep working

For webhooks from payment providers or CRMs, the sender only needs a fast acknowledgement. Set Respond to "Immediately": n8n answers at once and the rest of the workflow keeps running. This avoids sender timeouts and retries, which can otherwise trigger the same workflow several times.

If you need to acknowledge first and still return a custom code, place a Respond to Webhook node right after the Webhook, then continue the work after it. Only the first Respond to Webhook node that runs is used.

Status codes worth using

CodeMeaning for the callerExample
200OK, here is the resultQuote returned
201CreatedLead created
202Accepted, processing laterLong job started
400Your input is wrongMissing email
401 / 403Not allowedBad or missing key
409ConflictLead already exists
429Slow downYour own rate limit
500Our side failedUnexpected error

Troubleshooting table

SymptomLikely causeFix
Caller always gets "Workflow got started"Respond set to ImmediatelyUse Respond to Webhook node mode
Caller gets only the first recordRespond to Webhook uses the first itemChoose All Incoming Items, or Aggregate first
Caller gets 500Error before the Respond nodeAdd validation; check the failed execution
Browser blocks the call (CORS)Origin not allowedSet Allowed Origins (CORS)
HTML response looks brokenSandboxed iframe since 1.103.0Absolute URLs, or return JSON
524 on n8n CloudMore than 100 secondsRespond early, process after

Production checklist

  • A Respond to Webhook node on every branch, including validation failures.
  • Status codes that match the outcome (200, 201, 400, 409).
  • Lists aggregated or returned with "All Incoming Items".
  • A response in under 100 seconds on n8n Cloud, or an asynchronous pattern.

Frequently asked questions

Why does my n8n webhook only return one item?

The Respond to Webhook node uses the first incoming item. Choose "All Incoming Items" or aggregate the items into one before responding.

How do I return a custom status code from an n8n webhook?

Use the Response Code option in the Respond to Webhook node, or in the Webhook node when you do not use Respond to Webhook.

What does n8n return if the workflow fails before responding?

An error with status 500, when the failure happens before the first Respond to Webhook node.

How long can an n8n webhook take to respond?

On n8n Cloud, less than 100 seconds, or the request fails with 524. Self-hosted limits depend on your proxy and server timeouts.

How do I return HTML from an n8n webhook?

Use Respond With "Text", which sends text/html by default. Since n8n 1.103.0 the HTML renders in a sandboxed iframe, so use absolute URLs and avoid scripts that access the parent window.

Can I set cookies or custom headers in the webhook response?

Yes, with the Response Headers option of the Respond to Webhook node.

What happens if two Respond to Webhook nodes run?

Only the first one is used; the second is ignored.

Tags

n8nwebhookrespond to webhookapijson
Steve, founder of PURIST

Steve founded PURIST, a workflow automation studio working with n8n, Make and Claude AI, and is the point of contact on every project. Prices and features in our articles come from vendor documentation and public pricing pages. How we research and score tools.

Complete guide

Automation Tools & Platforms

11 min read n8n Code Node: 15 JavaScript Examples You Can Copy and … 8 min read n8n Code Node With Multiple Inputs: 3 Methods That Work 7 min read Fix "Cannot find module" in the n8n Code Node (npm Pack… 7 min read n8n Code Node Errors Fixed: "Code doesn't return items … 7 min read $env and Credentials in the n8n Code Node: What Works a… 7 min read n8n Code Node Binary Data: Read, Change and Return File… 7 min read Python in the n8n Code Node (n8n 2.x): Setup, Syntax an… 7 min read Fix n8n "The requested webhook is not registered" (Test… 6 min read n8n Webhook URL: Test vs Production, and How to Change … 8 min read Secure an n8n Webhook: Header Auth, Basic Auth, JWT and… 7 min read n8n Webhook Not Working? 10 Causes and How to Fix Each … 7 min read n8n HTTP Request Pagination: Every Pattern With Working… 7 min read n8n HTTP Request Authentication: API Keys, Bearer Token… 7 min read n8n HTTP Request Timeout and "Aborted" Errors: Causes a… 7 min read Upload and Download Files With the n8n HTTP Request Nod… 6 min read Fix ECONNREFUSED in n8n: Docker, localhost and 127.0.0.… 6 min read n8n 429 Too Many Requests: Batching, Retries and Rate L… 6 min read Fix redirect_uri_mismatch for n8n OAuth2 Credentials (G… 7 min read n8n Expression Errors Fixed: "Referenced node is unexec… 6 min read Anatomy Claude skill: what it is, how to install it, an… 5 min read How to explain a business process with the Anatomy skil… 5 min read Anatomy vs Mermaid vs Excalidraw: which to explain a wo… 14 min read n8n LinkedIn Job Automation: Auto-Apply, Track, and Fol… 16 min read n8n HTTP Request Node: Complete Documentation and Examp… 18 min read The future of automation: how our engineering team is s… 8 min read n8n vs Make vs Zapier: the honest comparison your busin… 11 min read n8n vs Make vs Zapier: an honest comparison for product… 7 min read Webhook vs polling: the architecture decision that dete… 24 min read n8n tutorial: build your first production workflow in u… 26 min read The 9 best Zapier alternatives in 2026: an honest ranki… 21 min read Make.com tutorial: build powerful automations without c… 19 min read Automation consultant vs DIY: how to decide what is rig… 14 min read n8n Self-Hosted vs Cloud: The Complete Decision Guide (… 15 min read 5 Zapier Free Alternatives That Handle Real Production … 15 min read WhatsApp Business Automation With n8n: Build a 24/7 Cus… 17 min read Google Workspace Automation: 15 Workflows for Sheets, D… 16 min read Claude AI for Business Automation: What It Does, What I… 15 min read Airtable Automation With n8n: 10 Workflows That Make Yo… 15 min read Droven.io AI Automation Tools: Full Review and Best Alt… 14 min read Droven.io RPA and Business Automation: An Honest 2026 R… 15 min read Enterprise Workflow Automation: The Complete Guide for … 13 min read Document Workflow Automation: Software, Implementation,… 14 min read Marketing Automation Workflow: From Content Creation to… 16 min read Ad Campaign Workflow Data Model and SDR Inbound Pipelin… 14 min read ComfyUI Workflows for Business: Product Photography, Ma… 13 min read GPT-5.2 for Business Workflows and the spec-workflow-mc… 17 min read ServiceNow vs IBM BAW vs n8n: Enterprise Workflow Autom… 16 min read 9 Best Workflow Automation Tools for Small Business in …

Keep reading

More from the blog.

All articles

From audit to deployment

Experience the automation
these articles are about.

Get my free automation plan →