Skip to content
Visual explainer 3h to learn 5 steps

Secure n8n webhook intake for booking requests

Receive booking requests on an authenticated production webhook, validate them and acknowledge only after durable acceptance.

By Invicly Tech, , in n8n, AI Automation and Voice Agents. About 11 minutes to read.

Topic 7 of 43

In short

A webhook is a URL that n8n listens on. Another system sends it an HTTP request, and a workflow starts. For booking requests you want the production URL, a caller check, validation, and a saved copy of the request before you answer with a clear status code.

Think of it like this: A webhook is like a letterbox with a lock: anyone can post a letter, but you only open the ones with the right key, and you write the letter in a ledger before you tell the sender it arrived.

Explained simply

Many systems tell you something happened by sending an HTTP request to a web address. In n8n, a Webhook node gives you that address. When a request arrives, the workflow starts and the request body becomes the first item.

n8n gives every Webhook node two addresses. The test address only works while you are looking at the editor and have clicked the listen button. The production address works all the time, but only once the workflow is active. Put the production address in the system that sends the requests.

Because the address is public, you must check who is calling. The Webhook node can require a secret header, a username and password, or a signed token. Calls without the right secret are refused before your workflow runs.

Then check the data. A booking needs a name, an email, a service and a start time. If something is missing, answer with a 400 status code. If the data is good, save it first and answer with 202, which means received and will be handled. Saving first means you never promise something you could lose.

Press Play on a diagram to walk through it one step at a time.

SequenceAccept a booking request safely
Caller
n8n Webhook node
Data table
  1. 1POST /webhook/bookings with a secret header
    Caller to n8n Webhook node: POST /webhook/bookings with a secret header
  2. 2Check header, fields and size
    n8n Webhook node to n8n Webhook node: Check header, fields and size
  3. 3Insert the request with its request ID
    n8n Webhook node to Data table: Insert the request with its request ID
  4. 4Row saved
    Data table to n8n Webhook node: Row saved
  5. 5202 Accepted with the request ID
    n8n Webhook node to Caller: 202 Accepted with the request ID
CompareTest URL and production URL
Test URL
  • Path starts with /webhook-test/
  • Listens only while you click Listen for test event
  • Shows incoming data in the editor
  • Use it while building
Production URL
  • Path starts with /webhook/
  • Works only when the workflow is active
  • Runs appear in the Executions list
  • Give this one to the real caller
MapWhich status code to return
Incoming booking request
  • 202 Accepted
    • Authenticated
    • Valid
    • Saved
  • 400 Bad Request
    • Missing field
    • Invalid date or email
  • 401 or 403
    • Missing secret
    • Wrong secret
  • 413 Payload Too Large
    • Body over the limit
  • 503 Service Unavailable
    • Could not save, caller should retry

In depth

Test and production endpoints

While you build, you click Listen for test event, send a request to the test address and see the data appear in the editor. That address contains /webhook-test/ and stops listening after one event. The production address contains /webhook/ and only works when the workflow is active. Executions from it appear in the Executions list, not in the canvas.

A common surprise is that the test run works but production returns 404. The usual cause is that the workflow is not active, or the path or HTTP method differs. Newer n8n versions may call activating 'publishing', but the idea is the same: the live version is the one the production address runs.

  • Test URL: /webhook-test/PATH, one event at a time
  • Production URL: /webhook/PATH, needs an active workflow
  • Path and HTTP method must match what the caller sends
  • Use a fixed, hard-to-guess path as well as authentication

Authenticate the caller

On the Webhook node, set Authentication to Basic, Header or JWT and pick a credential. With Header auth you choose a header name, such as X-Booking-Key, and a long random value. n8n returns 403 when the header is missing or wrong, before any later node runs.

The node also has an IP allowlist option and an allowed origins option for browsers. Treat these as extra layers, not replacements. Keep the secret value in the credential, and share it with the caller through a safe channel. Change it if it ever appears in a chat, a log or a screenshot.

  • Header auth: simple shared secret in a header
  • Basic auth: username and password
  • JWT auth: a signed token you verify
  • IP allowlist: useful only when the sender has fixed addresses
LayersDefence in layers for a public webhook
  1. 1
    Network

    HTTPS only, optional IP allowlist

  2. 2
    Authentication

    Header, Basic or JWT credential

  3. 3
    Validation

    Required fields, types, size

  4. 4
    Durable storage

    Save with a request ID

  5. 5
    Response

    Clear status code

Validate fields and size

Never assume the body is well formed. After the Webhook node, add an If or Code step that checks required fields, simple types and allowed values. Check dates are valid RFC 3339 strings and the email looks like an email. Reject anything else with 400 and a short message that names the field.

Size matters too. n8n limits request bodies by default to 16 MiB, set by the N8N_PAYLOAD_SIZE_MAX setting, and a booking request needs a tiny fraction of that. Put a stricter limit in front of n8n, in a reverse proxy, if you can. Large bodies waste memory and make executions slow.

  • Check required fields before anything else
  • Return the field name in the 400 message
  • Limit body size at the proxy as well
  • Log a request ID, not the whole personal data

Store first, then acknowledge

A caller treats a 2xx reply as 'you can stop worrying'. So send it only after the request is saved somewhere durable, such as an n8n data table or a database row. Use the request ID from the caller as a unique key. If the same request comes again, the insert fails or finds the old row, and you reply with the same answer instead of making a duplicate.

In the Webhook node set Respond to Using 'Respond to Webhook' Node. Then the Respond to Webhook node, placed after the save step, sends 202 and a JSON body. Heavy work, such as sending emails or calling a model, can continue after the reply.

  • Unique request ID gives duplicate protection
  • Respond after the save, not before
  • 202 means accepted, not finished
  • Do slow work after the reply

Learn it in 5 short steps

About 35m each. Track them with a timer in your plan.

  1. 1
    Compare test and production URLs~35m
  2. 2
    Authenticate the caller~35m
  3. 3
    Validate fields and payload size~35m
  4. 4
    Store the request before acknowledging~35m
  5. 5
    Return a clear response code~35m

Key points

  • The test URL and the production URL are different. Give the caller the production URL and activate the workflow.
  • Turn on authentication on the Webhook node (Basic, Header or JWT) so strangers cannot start your workflow.
  • Check required fields, types and size first. Reject bad input with a 4xx code, not a crash.
  • Save the request before you answer. Then a 2xx reply means the request is safe even if later steps fail.
  • Use Respond to Webhook when you need to choose the status code and body yourself.

Key terms

Tap a card to flip it. 0/5 known

Examples

json
{
  "requestId": "req-1042",
  "name": "Alex Example",
  "email": "alex@example.com",
  "service": "consultation",
  "start": "2027-03-02T09:30:00+01:00",
  "timezone": "Europe/Berlin"
}

A synthetic booking request. Reject it with 400 if any field is missing or start is not an RFC 3339 date.

Validate a booking in a Code node

After the Webhook node, a Code node (run once for all items) checks the body. A bad item is flagged so an If node can send 400. Test it with the example payload from the explainer.

javascript
const b = $input.first().json.body;
const errors = [];
for (const f of ["requestId", "name", "email", "service", "start"]) {
  if (!b[f]) errors.push("missing " + f);
}
if (b.email && !/^[^@\s]+@[^@\s]+$/.test(b.email)) errors.push("bad email");
if (b.start && Number.isNaN(Date.parse(b.start))) errors.push("bad start");
return [{ json: { ok: errors.length === 0, errors, body: b } }];

Call the production URL with curl

Prerequisites: an active workflow with Header auth set to X-Booking-Key. Replace the host and secret with placeholders from your lab. Expected evidence: HTTP 202 and a new execution in the Executions list. Cleanup: deactivate the workflow and delete the test rows.

bash
curl -i -X POST https://n8n.example.com/webhook/bookings \
  -H "X-Booking-Key: <secret>" \
  -H "Content-Type: application/json" \
  -d '{"requestId":"req-1042","name":"Alex Example","email":"alex@example.com","service":"consultation","start":"2027-03-02T09:30:00+01:00"}'

Quick reference

  • Test URL has /webhook-test/ and works for one event; production URL has /webhook/ and needs an active workflow.
  • Set Authentication on the Webhook node: Basic, Header or JWT.
  • Return 400 for bad input, 401 or 403 for bad credentials, 413 for too large, 202 for accepted.
  • Default body limit is 16 MiB (N8N_PAYLOAD_SIZE_MAX); set a lower one at your proxy.
  • Respond to Webhook node gives you control of status code, headers and body.
  • Save the request with its request ID before replying 2xx.
  • A repeated request ID should return the earlier answer, not create a new booking.

Common mistakes

  • Testing with the test URL and then giving it to the caller. It stops working as soon as you stop listening.
  • Replying 200 first and saving later. If n8n stops in between, the request is lost and the caller thinks it worked.
  • Leaving the webhook open with no authentication, so anyone who guesses the path can fill your queue.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1The test run worked but the real caller gets 404. What is the most likely cause?

Question 2

2When should a webhook workflow send its 202 response?

Question 3

3Which status code suits a request with a missing email field?

Question 4

4Which option stops strangers from starting your workflow?

Question 5

5Why use the caller's request ID as a unique key?

0/5 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Create a Webhook node with path bookings-lab. Send one request to the test URL with curl and find the data in the editor. Then activate the workflow and send to the production URL.

  2. Exercise 2medium

    Add Header auth to the webhook with a placeholder secret. Show that a call without the header is refused and a call with it is accepted.

  3. Exercise 3hard

    Build the full intake: authenticate, validate fields, insert into a data table keyed by requestId, then respond 202. Send the same requestId twice and show one row.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Why does my webhook work in the editor but not live?
The editor uses the test URL. The live caller needs the production URL, and the workflow must be active.
Is a secret in the URL path enough?
No. Paths leak in logs and screenshots. Use real authentication and treat the path as extra.
Should I reply 200 or 202?
Use 202 when you saved the request but will process it later. Use 200 when the work is finished in the reply.
Can the same event arrive twice?
Yes, senders often retry. Use a unique request ID and ignore repeats you have stored.

Go deeper

ShareXLinkedInWhatsApp