
Module 6 Lesson 3: Building Webhooks
Turn n8n into a server. Learn how to create custom HTTP endpoints that other apps can call, including how to respond with status codes and custom JSON.
Module 6 Lesson 3: Building Webhooks
A Webhook is usually a "Trigger" (Module 3). But in advanced n8n, a Webhook can be a Mini-API. You can make n8n receive a request, do some work, and then Respond back to the sender.
1. Webhook Settings
- HTTP Method: Usually
POST, but you can useGETif you want to make a simple URL that anyone can click. - Path: The unique name of your API (e.g.,
process-invoice). - Authentication: You can choose "None," "Basic Auth," or "Header Auth" to prevent strangers from triggering your workflow.
2. The "Respond to Webhook" Node
By default, n8n says "Workflow started" to anyone who calls a webhook.
If you want to send a custom answer:
- Add the "Respond to Webhook" node.
- Choose "Custom Response."
- Write your JSON:
{"status": "success", "order_id": 123}.
3. Test vs. Production URL
- Test URL: Only works while the n8n editor is OPEN and you have clicked "Execute Workflow."
- Production URL: Always active, but you must Save and Activate the workflow for it to work.
4. Why Use This?
- Custom Integrations: A 3rd party tool only sends data to a specific URL format? Create an n8n webhook to "Translate" it.
- Internal Tools: Create a button in your company's Intranet that calls an n8n webhook to generate a PDF report and returns the link to the browser.
Exercise: The API Creator
- Create a workflow with a Webhook node. Set the method to
GET. - Add a Respond to Webhook node.
- Set the response to:
{"message": "Hello from n8n!"}. - Execute the workflow and visit the Test URL in your browser. Did you see the JSON?
- Why would you want a webhook to require "Basic Auth"?
- Research: What is "Binary response" from a webhook? (Hint: Can you use n8n to serve an image?)
Summary
Webhooks allow you to stop being a "Consumer" of APIs and start being a "Provider." By turning your workflows into reachable endpoints, you can build custom tools and services that integrate perfectly into your company's existing ecosystem.
Next Lesson: High volume: Handling Pagination and Rate Limits.