Skip to main content

🗲 Creating a Secure Webhook - MUST HAVE

Workflow preview

Workflow preview
100%
🗲 Creating a Secure Webhook - MUST HAVE preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

How it works This workflow demonstrates a fundamental pattern for securing a webhook by requiring an API key. It acts as a gatekeeper, checking for a valid key in the request header before allowing...

Best for

  • SecOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.set, n8n-nodes-base.if, n8n-nodes-base.stickynote, n8n-nodes-base.respondtowebhook, n8n-nodes-base.webhook, n8n-nodes-base.httprequest, n8n-nodes-base.filter, n8n-nodes-base.splitout

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Lucas Peyrin.

Original n8n.io source

1.1 Workflow description

Title
🗲 Creating a Secure Webhook - MUST HAVE
Workflow name
🗲 Creating a Secure Webhook - MUST HAVE

How it works

This workflow demonstrates a fundamental pattern for securing a webhook by requiring an API key. It acts as a gatekeeper, checking for a valid key in the request header before allowing the request to proceed.

  1. Incoming Request: The Secured Webhook node receives an incoming POST request. It expects an API key to be sent in the x-api-key header.
  2. API Key Verification:
    • The Check API Key node takes the key from the incoming request's header.
    • It then makes an internal HTTP request to a second webhook (Get API Key) which acts as a mock database.
    • This second webhook retrieves a list of registered API keys (from the Registered API Keys node) and filters it to find a match for the key that was provided.
  3. Conditional Response:
    • If a match is found, the API Key Identified node routes the execution to the "success" path, returning a 200 OK response with the identified user's ID.
    • If no match is found, it routes to the "unauthorized" path, returning a 401 Unauthorized error.

This pattern separates the public-facing endpoint from the data source, which is a good security practice.

Set up steps

Setup time: ~2 minutes

This workflow is designed to be a self-contained example.

  1. Set up Credentials: This workflow uses "Header Auth" for its internal communication. Go to Credentials and create a new Header Auth credential. You can use any name and value (e.g., Name: X-N8N-Auth, Value: my-secret-password). Select this credential in all four webhook/HTTP Request nodes.
  2. Add Your API Keys: Open the Registered API Keys node. This is your mock database. Edit the array to include the user_id and api_key pairs you want to authorize.
  3. Activate the workflow.
  4. Test it: Use the Test Secure Webhook node to send a request.
    • Try it with a valid key from your list to see the success response.
    • Change the x-api-key header to an invalid key to see the 401 Unauthorized error.

For Production: Replace the mock database part of this workflow (the Get API Key webhook and Registered API Keys node) with a real database node like Supabase, Postgres, or Baserow to look up keys.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Registered API Keys

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 2 - API Key Identified

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Respond to Webhook (success)

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 5 - Respond to Webhook (unauthorized)

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 6 - Secured Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 7 - Check API Key

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 8 - Find API Key

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 9 - Get API Key

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 10 - Split Out Users

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 11 - Test Secure Webhook

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note12

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow 🗲 Creating a Secure Webhook - MUST HAVE
Complexity advanced
Nodes 16
Categories SecOps
Author Lucas Peyrin
Published 24 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/5174/5174.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does 🗲 Creating a Secure Webhook - MUST HAVE do?

How it works This workflow demonstrates a fundamental pattern for securing a webhook by requiring an API key. It acts as a gatekeeper, checking for a valid key in the request header before allowing...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your SecOps use case.