n8n Webhooks
A Webhook in n8n allows you to create a unique URL that can receive data from other applications and services. When a service sends an HTTP request (e.g., a POST request) to the webhook URL, it triggers your n8n workflow, allowing you to process the data sent.
Think of it as a dedicated endpoint for your workflow that listens for incoming data.
Setting Up a Webhook Trigger
- Add the Webhook Node: In your n8n workflow, add a “Webhook” node. It will be your starting trigger.
- Configure the Method: Select the HTTP method the webhook should listen for.
POSTis common for receiving data, butGETis also an option. - Get the URL: The webhook node will provide you with two URLs:
- Test URL: Use this for initial setup and testing. It allows you to send sample data to configure the rest of your workflow.
- Production URL: Use this in your live application once your workflow is activated. It’s designed to handle production traffic.
Example URLs:
- Test:
https://n8n.example.internal/webhook-test/ntfy - Production:
https://n8n.example.internal/webhook/ntfy
Testing the Webhook
You need to send a request to the Test URL to make n8n aware of the data structure it will receive. You can do this with tools like curl, Postman, or directly from the application that will be sending the data.
Using curl
To send a POST request with some data from your terminal, you can use the curl command.
# Command Explained:
# -d: Specifies the data to send in the request body.
# -X: Specifies the HTTP method (POST).
# The URL is your n8n webhook test URL.
curl -d "param1=value1¶m2=value2" -X POST https://n8n.example.internal/webhook-test/alertsAfter sending the test request, the Webhook node in the n8n UI will show the received data, allowing you to use it in subsequent nodes in your workflow.