Secure Webhook Endpoints with Query Parameter Validation - n8n Workflow

Implement basic security for your GET webhooks in n8n using a secret query parameter. Learn how this n8n workflow validates incoming requests and prevents unauthorized access.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users deploying simple webhooks from systems that lack native authentication (e.g., Google Sheets, basic HTML forms).
Developers and n8n specialists seeking reliable methods to secure an n8n trigger when advanced methods aren't available.


  • Anyone utilizing n8n templates and needing to ensure that only authorized calls execute their core n8n workflow logic.

Overview

While n8n offers powerful built-in authentication methods (like Basic Auth or JWT), some external services—such as simple buttons in Google Sheets or basic IoT devices—cannot support complex authorization headers. This crucial n8n workflow provides a solution by enforcing validation via a required query parameter, ensuring the security of your publicly exposed n8n trigger.

This method acts as a vital first line of defense. If the incoming request to the n8n node does not contain the correct predefined secret value (e.g., ?secret=abc123), the automation immediately halts the n8n workflow execution and returns an error, preventing unauthorized access and resource consumption. This simple security pattern is essential for transforming unsecured triggers into robust n8n templates ready for production use.

How it Works

This n8n workflow operates on a simple validation loop:


  1. Trigger Initiation: The process begins with the "Unprotected" Webhook n8n node, which listens for incoming HTTP requests (typically GET or POST) on its unique URL. This n8n trigger immediately captures all incoming data, including query parameters.

  2. Secret Check: The flow passes the request to the Secret valid? If n8n node. This node evaluates the query parameter payload ($json.query.secret). It checks if the provided secret value exactly matches the predetermined secure token (in this template, the placeholder value is 123).

  3. Success Path: If the secret validation is successful (True), the n8n workflow proceeds to the next steps, represented by the placeholder node Do whatever your workflow is supposed to do.

  4. Failure Path: If the secret validation fails (False), the n8n node routes the execution to the Validation Failed node. This Stop and Error n8n node immediately terminates the execution, sending an error response back to the caller and protecting the core n8n workflow logic from unauthorized execution.

Installation Guide

To deploy this security pattern using the provided n8n templates JSON, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON and import it directly into your n8n instance via the Workflows tab (New > Import from JSON).

  2. Activate the Webhook: Locate the "Unprotected" Webhook n8n node. Save the workflow and activate it to generate the unique webhook URL.

  3. Configure the Secret: Open the Secret valid? If n8n node. Crucially, change the Right Value from the default 123 to a long, complex, random secret key specific to your n8n workflow. This secret is the token required for all successful calls.

  4. Update the Caller: Configure your external service (e.g., Google Sheet button, external application) to call the generated webhook URL, always appending the query parameter: .../webhookid?secret=YOURNEWCOMPLEXSECRET.

  5. Final Test: Run a test call to ensure the n8n trigger works correctly only when the secret is present and valid.

Node Details

"Unprotected" Webhook (n8n trigger):
Function: Acts as the entry point for the n8n workflow, listening for external HTTP requests.
Key Configuration: Set to listen on a specified path. This n8n node captures all incoming request details, including query parameters, which are essential for validation.
Secret valid? (If n8n node):
Function: Implements the primary security check, branching the n8n workflow based on whether the required secret query parameter is present and correct.
Key Configuration: Checks the expression ={{ $json.query.secret }} against a defined static secret value (e.g., 123 in the template; users must update this).
Validation Failed (Stop and Error n8n node):
Function: Executes when the security check fails. It halts the n8n workflow and returns a descriptive error message to the calling service, preventing unauthorized execution of the downstream nodes.
Key Configuration: The errorMessage is set dynamically using expressions to identify the failed workflow: =The Webhook Secret was invalid in {{ $workflow.name }}.
Do whatever your workflow is supposed to do (No-Op n8n node):
* Function: A placeholder node indicating where the core business logic of the secured n8n workflow should be connected once validation is complete.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by

Featured*