Skip to content
Platform · Supabase

E-signatures and clickwrap with Supabase

To add e-signatures and clickwrap with Supabase, store the secret key as an Edge Function secret. One Edge Function creates the session with a plain fetch call, the browser SDK records the ceremony on your front end, and a second function confirms the record. Esign Comply seals it, and a Postgres table with row level security keeps the receipt.

Follow the quickstart and each signature is a valid electronic signature under the U.S. ESIGN Act, state UETA laws and New York's ESRA, and each clickwrap is built the way courts require: clear notice of the terms, an unmistakable act of assent, and a sealed record of both.

No package to install: Edge Functions call the REST API with fetch

Supabase quickstart

Free plan: 10 live signatures a month and a full test mode. No card required.

Last updated

Run locally for Supabase before publishing
supabase/functions/ceremony/index.ts
// supabase/functions/ceremony/index.ts
import { admin, corsHeaders, esc, signer } from "../_shared/esigncomply.ts";

// Step 4: create the session with the secret key. The browser gets the client token only.
Deno.serve(async (req) => {
  if (req.method === "OPTIONS") return new Response("ok", { headers: corsHeaders });

  const { ok, data: session } = await esc("/sessions", {
    method: "POST",
    headers: { "Idempotency-Key": `signup-${signer.external_id}-${crypto.randomUUID()}` },
    body: JSON.stringify({
      profile: Deno.env.get("ESIGNCOMPLY_PROFILE_ID"),
      signer,
      documents: [
        { document: Deno.env.get("ESIGNCOMPLY_TERMS_ID"), version: "current" },
        { document: Deno.env.get("ESIGNCOMPLY_PRIVACY_ID"), version: "current" },
      ],
      // The page lives on your front end's host, not on the function's: take it from the Origin header.
      context: { url: `${req.headers.get("origin")}/signup`, locale: "en-US", purpose: "account_signup" },
    }),
  });
  if (!ok) return Response.json({ error: session.error?.code }, { status: 502, headers: corsHeaders });

  // What this function pinned goes to Postgres: the confirm function runs in another worker.
  const { error } = await admin.from("acceptances").upsert({
    signer_id: signer.external_id,
    version_ids: session.documents.map((d: { version_id: string }) => d.version_id).sort(),
    record_id: null,
    receipt: null,
    accepted_at: null,
  });
  if (error) return Response.json({ error: "storage_failed" }, { status: 500, headers: corsHeaders });

  return Response.json(
    { clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents },
    { headers: corsHeaders },
  );
});
Integrate with Supabase

How do you integrate Esign Comply with Supabase?

On Supabase the server half is two Edge Functions. They run on Deno, so they call the REST API with fetch and no package. The front end has no server of its own, and it renders each pinned document in place: the content endpoint accepts the session's client token. A Postgres table keeps the pinned versions, then the receipt.

Edge Functions are serverless TypeScript functions, distributed globally at the edge, close to your users. They are developed using Deno.

Source: Supabase documentation, Edge Functions, read on .
Where each part lives on Supabase
  • Session functionsupabase/functions/ceremony/index.ts
  • Tablesupabase/migrations/20261123000000_acceptances.sql
  • Documents in the pagepublic/signup.html
  • Confirm functionsupabase/functions/confirm/index.ts

Run on 2026-11-26 on the Supabase Edge Runtime 1.79.1, PostgREST 16.5 and Postgres 17 images of the Supabase local stack, started on their own, with @supabase/supabase-js 2 (2.119.2 in the functions), the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode. The Supabase settings are from Supabase's documentation as of 2026-11-23. The code has not yet been deployed to a hosted Supabase project.

Three steps

How does Esign Comply fit with Supabase?

Each step uses a feature Supabase already has. The secret key stays on the server side of Supabase in all three.

  1. 01
    An Edge Function secret holds the keySet it with supabase secrets set ESIGNCOMPLY_API_KEY=... for the project, and in supabase/functions/.env for local runs. Functions read it with Deno.env.get. The publishable key in your front end never sees it. Source: Supabase documentation, Environment variables, read on .
  2. 02
    An Edge Function creates the sessionThe ceremony function sends POST /v1/sessions with the secret key and returns the client token. The browser SDK then records the ceremony on your front end, straight from the signer's device to the API.
  3. 03
    A Postgres table keeps the receiptThe confirm function reads the record and writes the record ID and the receipt into a table with row level security on and no policies. Only the Edge Functions write it, with the secret key client.
Supabase setup

Where do the key, the preview hosts and the webhook go on Supabase?

Four settings carry an Esign Comply integration on Supabase. What is said here about Supabase was read from its own documentation, and the quickstart has each command.

Secrets

supabase secrets set sets them for the project, and functions read a new secret at once, with no redeploy. A secret name cannot start with SUPABASE_. SUPABASE_URL and SUPABASE_SECRET_KEYS are injected into every function: you do not set them.

Source: Supabase documentation, Environment variables, read on .

CORS

The browser calls the functions from another origin, so each function answers the OPTIONS preflight and sends the CORS headers on every response. The quickstart imports corsHeaders from @supabase/supabase-js, as Supabase's guide shows.

Source: Supabase documentation, CORS, read on .

The registered domain and previews

The ceremony runs on your front end's host, not on the supabase.co address of the functions. Register the front end's domain with Esign Comply, and list the exact host of a front-end preview under Domains as a test origin. The session function takes context.url from the Origin header for that reason.

The signer and the webhook

With Supabase Auth, read the user from the request's JWT and send the user's ID as external_id. The identity is asserted by your app from the auth session, which is level L1. For the record.completed webhook, deploy a third function and register its URL under Webhooks in the Esign Comply dashboard.

Read on : Supabase documentation, Edge Functions, Supabase documentation, Environment variables, Supabase documentation, CORS, Supabase documentation, Edge Functions limits.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a Supabase app?

Paste this into Cursor, Claude Code or the AI coding tool that is open on your project. It names the packages that exist, where the secret key goes on Supabase, what to build and what never to do, and it ends with the rules block for your project.

The rules block lives at /rules.md. Added to your project's instruction file, it makes every later session build signing and acceptance flows the same way. The prompt generator writes the long version, with your own document and profile IDs.

Pages for each AI tool
Prompt: Esign Comply clickwrap on Supabase
Add Esign Comply clickwrap to my app on Supabase: a signup form where the user accepts the Terms of Service and the Privacy Notice with a checkbox and a button.

Read these first and follow them exactly. If something conflicts with existing code, or you are unsure how to implement a step, stop and ask. Do not invent API methods, packages or legal wording.
- https://esigncomply.com/docs/quickstart/supabase.md (the steps and the tested code for Supabase)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Supabase facts
- There is no Esign Comply package for Deno. Edge Functions call the REST API at https://esigncomply.com/v1 with fetch, Authorization: Bearer and the secret key. Do not install or invent a package.
- The secret key is an Edge Function secret: supabase secrets set ESIGNCOMPLY_API_KEY=... for the project, supabase/functions/.env for local runs. Read it with Deno.env.get. A secret name cannot start with SUPABASE_. Never print the key, and never put it in the front end.
- The browser calls the functions from another origin: answer the OPTIONS preflight and send the CORS headers on every response.
- Edge Functions on a supabase.co address cannot serve HTML, so the documents are not Edge Function pages. Render each pinned version in the page: the content endpoint accepts the session's client token.
- Keep the pinned version IDs, the record ID and the receipt in a Postgres table with row level security and no policies. Only the Edge Functions write it, with the secret key client.
- The page is on screen before the script has a session: render the checkbox disabled and enable it when observeAssent has resolved.

Build
1. Verify the key: GET /v1/usage with ESIGNCOMPLY_API_KEY. Stop if it fails.
2. Register the Terms of Service and the Privacy Notice as documents and publish one version of each from the documents in this project. If the project has none, register short sample documents and say so in your report. Never write or change the wording of the real documents. Create a profile: jurisdictions ["US-FED"], method "checkbox", assurance_level "L1".
3. Edge Function ceremony: POST /v1/sessions with an Idempotency-Key, upsert the signer ID and the pinned version IDs into the table, and return only clientToken, apiUrl and documents.
4. Browser: EsignComply.attach({ clientToken, apiUrl }). For each document, fetch GET {apiUrl}/documents/{document_id}/versions/{version_id}/content with the client token, inject the html unmodified into an element marked data-esc-document, and call presentDocument({ versionId, mode: "inline", container }). Then observeAssent({ region, checkbox, submit }) and complete() from the user's real click.
5. Edge Function confirm: GET /v1/records/{id} and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the row. Only then create the account, and store the record ID and the receipt in the row.

Never
- Never pre-check the box, auto-submit, or call .click() on the user's behalf.
- Never use "By continuing" or "By clicking below" wording. The notice names the button by its label and each document by its registered name.
- Never put the secret key, or any call that uses it, in code that reaches the browser.
- Never show "signed" or "accepted" before the Edge Function has confirmed the record.
- Never fall back to an acceptance with no record when a session is refused.

Check before you report success
- Run: npx esigncomply check --url http://localhost:3000/signup --callback https://YOUR-PROJECT.supabase.co/functions/v1/confirm
  Fix every finding marked "block". List every finding marked "warn".
- Report the files you created or changed, anything you did not implement and why, and the conformance summary.

Then add the rules block to this project's instruction file: https://esigncomply.com/rules.md
3 things to watch

What goes wrong when you add e-signatures on Supabase?

These are specific to Supabase. Each one was seen while the quickstart's code was run, or is in Supabase's own documentation.

  • 01

    Edge Functions cannot serve your document pages

    Supabase serves HTML from Edge Functions only on custom domains: on a supabase.co address a text/html response is rewritten to text/plain. So the documents are not function pages. The page fetches each pinned version with the session's client token and renders it in place, presented as inline.

    Source: Supabase documentation, Edge Functions limits, read on .
  • 02

    Every response needs the CORS headers

    The front end and the functions are on two origins. Answer the OPTIONS preflight, and send corsHeaders on error responses too: a refused call without them shows up in the browser as a CORS error and hides the real one. In the test run the preflight answered 200 with the headers.

  • 03

    Row level security on, no policies

    The table that keeps the pinned versions and the receipt has row level security enabled and no policies. In a test, an insert with the publishable key was refused by row level security, and the Edge Function's secret key client wrote the row.

Verifiable

What does Esign Comply record for a signature on Supabase?

The same record on every stack and platform. Your Supabase code creates the session and confirms the record, and the browser SDK reports what happened on the page. Esign Comply seals the result where your code cannot change it. The record itself is described on Evidence and verification.

  • Observed and asserted fields

    Every field is tagged. Observed is what the browser SDK and the API saw: the box unchecked at load, the tick from a trusted user event, the notice text, the terms version by hash, the server time. Asserted is what your app said, such as the user's email.

  • A signed receipt

    complete() returns a receipt signed with ES256, using keys you do not hold. Your server stores it next to the user, and GET /v1/records/{id}/receipt returns it again.

  • An external timestamp

    An outside authority timestamps the hash of every live record (RFC 3161), so the time on the record does not rest on your clock or on ours.

  • An offline verifier

    Each record has an evidence report (PDF) and an evidence package (ZIP). Anyone you send the package to checks the acceptance with the open-source esigncomply-verify, without an account.

Recordrec_Z4m8
simple · L1
RecordedWritten durably, receipt signed with ES256
TimestampedExternal RFC 3161 token over the record hash
AnchoredPublic anchor pending
Checkbox changed by a trusted user eventobserved
Terms of Service, version dv_3kT9observed
Server time 2026-11-21T15:03:20.291Zobserved
Signer email dana@example.orgasserted
record_hash sha256:5be7…example record

Questions about e-signatures on Supabase

How does test mode work on preview URLs with Supabase?

Test mode follows the host of your front end, not the functions. A test key works on localhost with no setup. For a preview of the front end on another host, list that exact host under Domains as a test origin, or the session is refused with domain_mismatch.

Where should the receipt be stored on Supabase?

In a Postgres table of your own, beside the signer ID and the record ID, written by the confirm function. Enable row level security and add no policies for it, so only the Edge Functions' secret key client can write it.

Can a Supabase Edge Function use the esigncomply package?

The quickstart does not use it. The server SDK is built for Node.js and Edge Functions run on Deno, so the functions call the REST API with fetch: one POST to create the session and one GET to read the record.

How is the signer identified with Supabase Auth?

By your app. The function reads the Supabase Auth user from the request's JWT and sends the user's ID as the signer's external_id. That is level L1: the identity is asserted by your application from its auth session.

Was this code run on a hosted Supabase project?

Not yet. The functions ran on the Edge Runtime, PostgREST and Postgres images of the Supabase local stack, started on their own, and the settings come from Supabase's documentation as of November 23, 2026. The CLI commands and the gateway's JWT check are proven only on a hosted project.

Keep the key in an Edge Function and the receipt in Postgres. Leave the record to us.

Free plan: 10 live signatures a month and a full test mode. No card required.

Supabase is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Supabase is from Supabase's documentation or from a test run, as marked, on . /supabase.md is this page as Markdown.

Working with an AI tool? This page is also available as Markdown: /supabase.md