Webhook Handling
Relevant source files
The following files were used as context for generating this wiki page:
- packages/nodes-base/nodes/Webhook/Webhook.node.json
- packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.json
- packages/frontend/editor-ui/src/constants.ts
- packages/nodes-base/nodes/HtmlExtract/test/workflow.dotNotation.json
- packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json
- packages/nodes-base/nodes/Mattermost/Mattermost.node.json
Webhook handling is a fundamental capability within n8n, enabling workflows to be triggered by external systems via HTTP requests. This allows for real-time data exchange and process automation initiated from virtually any service that can send a webhook. The core of this functionality is the Webhook node, which acts as a trigger, listening for incoming data.
Workflows that start with a Webhook node can perform any number of steps and can optionally send a response back to the calling service. This is facilitated by the RespondToWebhook node, which allows for customized responses to be sent at any point in the workflow execution. This mechanism is crucial for building powerful API endpoints and integrating n8n with services that require immediate feedback.
Core Components
The webhook system is primarily built around two key nodes that work in tandem to receive requests and send responses.
| Node Name | Type Name | Category | Description |
|---|---|---|---|
| Webhook | n8n-nodes-base.webhook | Development, Core Nodes | The main trigger node that provides a unique URL to listen for incoming HTTP webhook requests. |
| Respond to Webhook | n8n-nodes-base.respondToWebhook | Core Nodes, Utility | A helper node used to send a custom HTTP response back to the service that called the webhook. |
Sources: packages/nodes-base/nodes/Webhook/Webhook.node.json, packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.json
Webhook Node
The Webhook node is the entry point for external data. When added to a workflow, it generates a unique URL. Any HTTP POST or GET request sent to this URL will trigger the workflow's execution. It is categorized under "Development" and "Core Nodes" and has several aliases including "HTTP", "API", and "WH".
Sources: packages/nodes-base/nodes/Webhook/Webhook.node.json
RespondToWebhook Node
The RespondToWebhook node is used to conclude the webhook request-response cycle. It allows a workflow to send a custom response body, status code, and headers back to the original caller. This is essential for integrations that expect a specific response to confirm receipt or to provide data back.
Sources: packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.json
Webhook Data Flow
The following diagram illustrates the typical data flow when a webhook is triggered and a response is sent.
This diagram shows an external service sending an HTTP request to the n8n Webhook node, which triggers the workflow logic. The RespondToWebhook node is then used to send a response back to the external service.
Sources: packages/nodes-base/nodes/Webhook/Webhook.node.json, packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.json
Webhook Payload Structure
When a webhook is received, n8n parses the incoming HTTP request into a structured JSON object. A test workflow demonstrates this structure, which typically includes headers, parameters, and the request body.
{
"headers": {
"host": "n8n.mydomain.live",
"user-agent": "axios/1.2.1",
"content-length": "4405",
"accept": "application/json, text/plain, */*",
"content-type": "application/json",
"x-forwarded-for": "85.203.36.52"
},
"params": {},
"query": {},
"body": {
"html": "<html>...</html>"
}
}
Sources: packages/nodes-base/nodes/HtmlExtract/test/workflow.dotNotation.json:11-28
This structure provides the workflow with all the necessary information from the incoming request to perform its logic.
System Constants
The n8n frontend uses several constants to identify and manage webhook-related nodes and their behaviors within the editor UI.
| Constant | Value | Description |
|---|---|---|
WEBHOOK_NODE_TYPE | n8n-nodes-base.webhook | The unique type identifier for the Webhook node. |
RESPOND_TO_WEBHOOK_NODE_TYPE | n8n-nodes-base.respondToWebhook | The unique type identifier for the Respond to Webhook node. |
OPEN_URL_PANEL_TRIGGER_NODE_TYPES | [...] | An array that includes WEBHOOK_NODE_TYPE, indicating that this node type should display a URL panel in the UI. |
KEEP_AUTH_IN_NDV_FOR_NODES | [...] | An array that includes WEBHOOK_NODE_TYPE, specifying that the authentication section should remain visible in the node details view. |
Sources: packages/frontend/editor-ui/src/constants.ts:211, packages/frontend/editor-ui/src/constants.ts:255, packages/frontend/editor-ui/src/constants.ts:285-290, packages/frontend/editor-ui/src/constants.ts:548-556
Related Use Cases
The concept of webhooks is central to many n8n integrations. Documentation for other nodes, such as HttpRequest and Mattermost, often refers to webhooks as a key mechanism for building powerful automations. For example, the HttpRequest node can be used to call other webhooks, while Mattermost can be configured to send slash commands to n8n webhook URLs.
Sources: packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json, packages/nodes-base/nodes/Mattermost/Mattermost.node.json