Library / Security & Compliance
Security & Compliance
Secure a Public Webhook with Auth and Validation
When a request hits the webhook, it checks the authorization header and required fields, then replies with 200, 400 or 401 accordingly.
What it does
## 🔐 Secure Webhook – Summary *This workflow protects a public webhook with authentication and payload validation.* --- #### 🧩 Why use it? - ✅ Ensure only trusted clients can call your workflow (via Bearer token). - ✅ Validate that all expected fields are present in the request body. - ✅ Return helpful and consistent JSON responses (200, 400, 401). --- #### ⚙️ How it works: 1. Webhook – Entry point for external POST requests. 2. Configuration – Defines config.bearerToken and config.requiredFields. 3. Check Authorization Header – Compares incoming Bearer token with config. 4. 401 Unauthorized – Returned if the token is missing or incorrect. 5. Has required fields? – JS code checks for required fields in the request body. 6. 400 Bad Request – Returned if any required field is missing. 7. Create Response & 200 OK – Returns a custom success message. --- #### 🛠 Setup Instructions: - Set your desired Bearer token in config.bearerToken. - For each required field, set a key in config.requiredFields *(e.g., config.requiredFields.message)*. *👉 The value doesn't matter, only the keys are checked.* - Replace the Add workflow nodes here node with your own workflow logic. - Edit the Create Response node to build your response. --- 📌 *Great for building secure, reusable webhook endpoints for APIs, forms, or 3rd-party services.*
The steps
- Check Authorization Header
- 401 Unauthorized
- 200 OK
- Configuration
- Webhook
- Has required fields?
- Check Valid Request
- 400 Bad Request
- Create Response
- Add workflow nodes here
- Error Handler
- Stopanderror 1
- Stopanderror 2
- Stopanderror 3
31 steps in total.
Similar automations
Security & ComplianceSecure a Webhook with Authentication and Payload Checks10 stepsData Sync & ETLFind Microsoft 365 SMTP AUTH senders with Microsoft Graph, OpenAI and Google Sheets20 stepsBuilding Blocks & UtilitiesLook Up Public Holidays via Webhook with Nager.Date3 stepsForms & SurveysTriage Public Form Submissions with a Claude RAG Agent11 steps