This n8n workflow creates a secure, authenticated webhook endpoint designed for handling incoming API requests, validating access tokens and required fields, and returning standardized responses. It is ideal for safeguarding webhook endpoints for APIs, forms, or third-party integrations.
The workflow begins with a webhook node that listens for POST requests on a specified URL. When a request is received, the workflow first checks if the ‘Authorization’ header contains a valid Bearer token, comparing it with a configured token (‘config.bearerToken’). If the token is invalid or missing, it responds immediately with a 401 Unauthorized message.
Next, the workflow verifies that all required fields, defined in the configuration (‘config.requiredFields’), are present in the request body. This validation is handled by JavaScript code in a code node. If any required fields are missing, a 400 Bad Request response is returned.
If the request passes both authentication and validation, the workflow proceeds to process the request further, which is represented here by a placeholder node. Finally, it responds with a success message (‘Success! Workflow completed.’) and a 200 OK status.
Supporting nodes include sticky notes for setup instructions and error handling, making it easy to customize and extend this secure webhook for various API integrations. This workflow ensures only trusted clients can trigger actions while providing clear feedback for errors or success.
Reviews
There are no reviews yet.