Secure API Endpoint with Bearer Token Authentication and Field Validation
A reusable and production-ready n8n workflow that secures public webhooks using Bearer Token authentication and dynamic request validation.
β¨ What It Does
Verifies Bearer Token**
Compares the Authorization header with a configured secret token.
Validates Required Fields**
Checks that all expected fields are present in the incoming request body.
Returns Standardized JSON Responses**
401 Unauthorized if token is missing or invalid
400 Bad Request if required fields are missing
200 OK with a custom success payload
π€ Who Itβs For
Developers exposing n8n workflows as APIs No-code/low-code builders integrating with external forms or tools Anyone needing simple authentication and validation on incoming webhooks
π‘ Why Use It
π Secure: Prevents unauthorized access to your public workflows π§Ό Clean: Centralized configuration for token and required fields βοΈ Flexible: Easy to extend and customize for any use case
π Setup Instructions
Configure Values in the Configuration Node
Set your secret token:
config.bearerToken = YOUR_TOKEN
Define required request fields by key:
Example:
config.requiredFields.message = true;
config.requiredFields.email = true;
β
Only the keys matter β values can be anything.
Plug in Your Business Logic
Replace the "Add workflow nodes here" with your own logic.
Customize the Success Response
Edit the Create Response node to shape your success payload.
π§ͺ Use Cases
Securing public form submissions Creating internal API endpoints Validating data from external services
π Use this as a base for building secure, API-style workflows in n8n.
π Hello! I'm Audun / xqus
If my n8n workflows saved you time or sparked ideas, consider sending a little support my way. It helps me keep building cool stuff β and maybe grab a coffee β along the way!
Related Templates
AI Email Classifier & Auto-Delete for Gmail (SPAM/OFFER Cleaner)
This workflow is designed for freelancers, solopreneurs, and business owners who receive a high volume of irrelevant mes...
Generate Food Recipes from Gmail & Form Requests with Ollama & Llama 3.2
This n8n template demonstrates how to create an intelligent food recipe assistant that accepts requests via Gmail and we...
Automatic News Summarization & Email Digest with GPT-4, NewsAPI and Gmail
π° AI News Digest Agent: Auto News Summarizer & Email Newsletter Create an intelligent news curation system that automat...
π Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments