AutomationFlowsGeneral › n8n Webhook Template with Error Handling

n8n Webhook Template with Error Handling

Original n8n title: Template — Webhook with Error Handling

TEMPLATE — Webhook with Error Handling. Webhook trigger; 4 nodes.

Webhook trigger★★★★☆ complexity4 nodes
General Trigger: Webhook Nodes: 4 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "TEMPLATE \u2014 Webhook with Error Handling",
  "nodes": [
    {
      "parameters": {
        "path": "YOUR-WEBHOOK-PATH",
        "httpMethod": "POST",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "tmpl-0001-0001-0001-000000000001",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// ============================================\n// YOUR WORK GOES HERE\n// ============================================\n// Replace this node with your actual logic,\n// or keep it as a Code node and edit the JS.\n//\n// The webhook payload is available at:\n//   $input.first().json.body    (POST body)\n//   $input.first().json.query   (query params)\n//   $input.first().json.headers (request headers)\n//\n// IMPORTANT: This node has onError: continueErrorOutput\n// which means errors route to the Error Response path\n// instead of crashing the workflow.\n// ============================================\n\nconst input = $input.first().json;\n\nreturn [{\n  json: {\n    result: 'Replace this with your actual logic',\n    received: input.body || {}\n  }\n}];"
      },
      "id": "tmpl-0001-0001-0001-000000000002",
      "name": "Your Work Here",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        300,
        0
      ],
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { success: true, data: $json, timestamp: $now.toISO() } }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "tmpl-0001-0001-0001-000000000003",
      "name": "Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        600,
        -100
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { success: false, error: $json.error || 'Unknown error', workflow: $workflow.name, timestamp: $now.toISO() } }}",
        "options": {
          "responseCode": 500
        }
      },
      "id": "tmpl-0001-0001-0001-000000000004",
      "name": "Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        600,
        150
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Your Work Here",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your Work Here": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

TEMPLATE — Webhook with Error Handling. Webhook trigger; 4 nodes.

Source: https://github.com/Pvragon/n8n-restish-cli/blob/b80e6f76d8ea3d8a96c0826e2d3ffdcf87a97e81/templates/webhook-with-error-handling.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

A clean, extensible REST-style API routing template for n8n webhooks with up to 3 path levels. Serves API routes via Webhooks with path variables Normalizes incoming requests into "global" REQUEST and

General

PUQ Docker NextCloud deploy. Uses respondToWebhook, stickyNote, httpRequest, ssh. Webhook trigger; 44 nodes.

HTTP Request, Ssh
General

puq-docker-immich-deploy. Uses respondToWebhook, ssh, stickyNote. Webhook trigger; 35 nodes.

Ssh
General

Analyze_email_headers_for_IPs_and_spoofing__3. Uses stickyNote, respondToWebhook, itemLists, httpRequest. Webhook trigger; 35 nodes.

Item Lists, HTTP Request
General

puq-docker-n8n-deploy. Uses respondToWebhook, ssh, stickyNote. Webhook trigger; 34 nodes.

Ssh