# Receive data with webhooks

> Use the Webhook node to start n8n workflows from websites, forms and other apps, test safely, secure the URL and send a response back.

Source: https://viralistic.nl/help/n8n/webhooks

A webhook is a URL that another system calls when something happens: a form is submitted, a payment succeeds, a deal changes stage. The Webhook node gives your workflow such a URL. It is the most flexible trigger in n8n, because almost every app and website can send data to a URL.

## How it works

1. You add a Webhook node and n8n generates a URL.
2. You paste that URL into the other app, often in a section called Webhooks or Integrations.
3. The app sends an HTTP request with data (usually JSON) whenever the event happens.
4. n8n starts the workflow with that data as the first item.

## Test URL and production URL

Every Webhook node has two URLs. You switch between them at the top of the node.

|                      | Test URL                                                    | Production URL               |
| -------------------- | ----------------------------------------------------------- | ---------------------------- |
| Path contains        | `/webhook-test/`                                            | `/webhook/`                  |
| Works when           | You select **Listen for test event**, for about two minutes | The workflow is published    |
| Data shown on canvas | Yes                                                         | No, check the Executions tab |
| Use for              | Building and debugging                                      | The real integration         |

> **Warning:** The most common webhook problem is a live app still pointing at the test URL. When you go live, copy the production URL into the other app.

## Step 1: Add and configure the node

1. Create a workflow and add the **Webhook** node as the trigger.
2. Set **HTTP Method** to what the sender uses. Most apps send `POST`.
3. Change **Path** to something readable, such as `new-lead`. The default is a random string, which is fine too.
4. Choose how to **Respond** (see below).

## Step 2: Send a test request

1. Select **Listen for test event**.
2. Trigger the event in the other app, or send a request yourself:

   ```bash
   curl -X POST "https://your-n8n-domain/webhook-test/new-lead" \
     -H "Content-Type: application/json" \
     -d '{"name": "Jane", "email": "jane@example.com", "source": "website"}'
   ```

3. The node shows the received data. You find the JSON body under `body`, and also `headers` and `query`.
4. Pin the output and build the rest of the workflow.

## Step 3: Choose a response

The sender usually waits for an answer. Under **Respond** you choose:

- **Immediately:** n8n answers right away that the workflow started. Best for most integrations, because senders often time out after a few seconds.
- **When Last Node Finishes:** n8n answers with the output of the last node. Useful for simple APIs.
- **Using 'Respond to Webhook' Node:** you decide exactly what to send back, and when, with a separate node. Good for redirects after a form, or custom status codes.
- **Streaming:** sends the answer piece by piece, for example from an AI Agent.

## Step 4: Secure the webhook

Anyone who knows the URL can call it. Protect it:

1. Set **Authentication** to **Header Auth** and choose a long random secret. Configure the sender to include that header. Basic Auth and JWT are also available.
2. Use **IP(s) Allowlist** under options if the sender has fixed IP addresses.
3. Turn on **Ignore Bots** for URLs that might get shared, so link previews do not trigger runs.
4. Validate the data early in the workflow. Stop when required fields are missing.

> **Note:** Some apps sign their webhooks instead of sending a fixed header. Check the app's documentation. You can verify a signature with a Code node or the Crypto node.

## Step 5: Publish and connect

1. Click **Publish**.
2. Copy the **Production URL** into the other app.
3. Trigger one real event and check the **Executions** tab.

## Webhooks from your website

Static sites, such as our Astro sites, can post form submissions straight to an n8n webhook. Then n8n can store the lead, notify you and send a confirmation email. See [Add forms to a static site](https://viralistic.nl/help/astro/forms).

For a simple form without a website, the **n8n Form Trigger** is easier: it hosts the form for you. See [Build your first workflow](https://viralistic.nl/help/n8n/first-workflow).

## Self-hosted tips

- The URL must be reachable from the internet. A workflow on `localhost` cannot receive webhooks from online apps.
- Behind a reverse proxy, set the `WEBHOOK_URL` environment variable to your public address. Otherwise n8n shows the wrong URL in the node.
- The maximum payload is 16 MB by default. Self-hosted instances can change this.

## Next steps

- [Run workflows on a schedule](https://viralistic.nl/help/n8n/schedules)
- [Error handling and alerts](https://viralistic.nl/help/n8n/error-handling)
- [Add forms to a static site](https://viralistic.nl/help/astro/forms)
