Multi-Level Document Approval and Audit System using Supabase & Gmail - n8n Workflow

Automate sophisticated multi-level document approval processes using this n8n workflow template, leveraging Supabase as the backend database and Gmail for secure, tokenized approval links. Track every step with audit logs.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Technical teams and developers utilizing Supabase as their primary backend database.

  • Organizations requiring formal, auditable, multi-level document approval hierarchies.

  • Users looking for advanced n8n workflow examples incorporating secure webhook callbacks and conditional branching logic.

Overview

Managing internal document approvals, such as contracts or policies, often requires complex, multi-tiered workflows. This sophisticated n8n workflow template solves this challenge by providing a robust, automated approval system. When a document is submitted via an n8n trigger form, the system stores the file in Supabase storage and initiates the first approval level defined in your workflowlevels table. The core value of this n8n workflow is its ability to handle conditional progression: if approved, it automatically identifies and routes the document to the next required approver level; if rejected, the process terminates immediately. Furthermore, every action, including submission, approval requests, and final decisions, is meticulously recorded in an auditlogs table, ensuring full compliance and traceability. This comprehensive n8n template significantly reduces manual overhead for document processing.

How it Works

This n8n workflow operates in two distinct phases: initiation and execution.

Phase 1: Initiation via Form Trigger


  1. Submission: The process begins with an n8n trigger, specifically an n8n Form Trigger. A user uploads a document and provides metadata.

  2. Storage: The document file is uploaded to Supabase Storage, and the metadata (title, status) is saved into the documents table using a Supabase n8n node.

  3. Level 1 Setup: The n8n workflow fetches the configuration for Level 1 approval from the workflowlevels table.

  4. Approver Identification: It retrieves the corresponding approvers' emails based on the required roleid from the users table.

  5. Tokenization & Record Creation: A unique token is generated using the Crypto n8n node for security. A record is created in the approvals table, linking the document, approver, and the unique token.

  6. Notification: A Gmail n8n node sends an email containing secure webhook links (Approve/Reject) embedded with the unique token.

  7. Auditing: An audit log entry is created to confirm the approval request was sent.

Phase 2: Approval Execution via Webhook


  1. Response: The process resumes when an approver clicks an approval link, triggering the Webhook n8n trigger.

  2. Validation: The workflow fetches the approval record using the received token via a Supabase n8n node and updates the approval status.

  3. Decision Branching: The checkrejectorapprove If n8n node evaluates the decision:

If Rejected: The workflow terminates the process. The document status is set to 'Rejected' in the documents table, and an audit log is created.
If Approved: The workflow determines the next step. It fetches the current level details and queries for the next sequential level (get
nextlevel).

  1. Progression vs. Completion: The islast_level If n8n node checks if a subsequent level exists:

Next Level Exists: The process loops, initiating the token generation, record creation, and email sending steps for the next group of approvers.
No Next Level: The document is fully approved. The documents table status is updated to 'Approved', and a final audit log is recorded, concluding this powerful n8n workflow.

Installation Guide

To deploy this high-functioning n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and import it directly into your n8n instance.

  2. Supabase Credentials: You require two types of Supabase credentials linked to the n8n nodes:

API Credential: Used by all Supabase nodes for CRUD operations on tables (documents, approvals, auditlogs, workflowlevels, users).
Storage Configuration: Update the URL templates in the uploadtosupabasestorage and fetchfiletoreview nodes with your specific Supabase Project ID and bucket name.

  1. Gmail Credentials: Set up OAuth2 credentials for the Gmail n8n node to enable sending approval emails.

  2. Database Schema: Ensure your Supabase project contains the required tables (roles, users, documents, workflowlevels, approvals, auditlogs) exactly as described in the sticky note within the n8n workflow JSON.

  3. Webhook URLs: Crucially, update the webhook URL paths within the Gmail n8n node messages. Replace http://localhost:5678/webhook-test/approve?token=... with the live URL of your n8n instance. Remember to remove /webhook-test if running in production mode.

Node Details

This n8n workflow utilizes several key n8n nodes to manage the logic and data:

Form Trigger (startapprovalform): This is the initial n8n trigger. It provides a simple web form interface for users to submit the document title, description, and the required PDF file.
Supabase Node (Multiple Instances): This essential n8n node handles all database interactions. Operations include insert (saving documents, approvals, audit logs) and get/getAll (fetching workflow levels and user roles).
Key Configuration: Used extensively for filtering (e.g., matching token, levelnumber, or roleid) to ensure data integrity across the approval stages.
HTTP Request Node (uploadtosupabasestorage): Used to securely push the submitted document file directly into your designated Supabase Storage bucket. This uses binary data mapping.
Crypto Node (createuuidtoken / generateuuid): A vital security n8n node that generates unique, one-time tokens. These tokens are used in the approval links to securely identify the approval record when the webhook is triggered.
Gmail Node (sendemail / sendemaibylevel): Sends rich HTML emails containing the secure, tokenized Approve/Reject links necessary to continue the n8n workflow execution.
Webhook Node (Webhook): Acts as the execution n8n trigger for the approval decision callback. It captures the query parameters token and decision from the clicked link.
If Node (checkrejectorapprove / islast_level): These core logic n8n nodes control the flow. They check if the decision was 'approved' and determine if the current level is the final stage before proceeding or concluding the n8n workflow.

Related n8n Workflows

Free

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

I am a Principal Software Engineer based in Ireland with a deep passion for AI and emerging technologies. With extensive experience in designing and implementing scalable software solutions, I focus on leveraging artificial intelligence to solve real-world problems. I enjoy exploring innovative applications of AI, from intelligent automation to data-driven insights, and I’m dedicated to building systems that are both efficient and impactful.

Featured*