# E-signatures and clickwrap with Supabase

> E-signatures and clickwrap with Supabase: an Edge Function creates the session with fetch, a second confirms it, and a Postgres table keeps the receipt.

Source: https://esigncomply.com/supabase

Platform · 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.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/supabase)

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

[Supabase quickstart](https://esigncomply.com/docs/quickstart/supabase)

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

Last updated November 26, 2026

Run locally for Supabase before publishing

**Session function**

`supabase/functions/ceremony/index.ts`

```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 },
  );
});
```

**Table**

`supabase/migrations/20261123000000_acceptances.sql`

```sql
-- supabase/migrations/20261123000000_acceptances.sql
create table public.acceptances (
  signer_id   text primary key,     -- signer.external_id sent to Esign Comply
  version_ids text[] not null,      -- the versions the session pinned
  record_id   text unique,          -- rec_..., set once the record is confirmed
  receipt     text,                 -- the signed receipt (JWS, ES256)
  accepted_at timestamptz
);

-- Row level security with no policies: the anon and authenticated roles read and write nothing.
-- Edge Functions use the service role, which bypasses row level security.
alter table public.acceptances enable row level security;
```

**Documents in the page**

public/signup.html (excerpt)

```html
// This page has no server of its own, so it renders each pinned version in place.
// The content endpoint accepts the session's client token for the versions of that session.
for (const [i, doc] of documents.entries()) {
  const response = await fetch(`${apiUrl}/documents/${doc.document_id}/versions/${doc.version_id}/content`, {
    headers: { Authorization: `Bearer ${clientToken}` },
  });
  const article = document.createElement("article");
  article.id = `doc-${i}`;
  article.dataset.escDocument = doc.version_id;
  article.innerHTML = (await response.json()).html; // sanitized by Esign Comply: inject it unmodified
  document.querySelector("#documents").append(article);
  await ceremony.presentDocument({ versionId: doc.version_id, mode: "inline", container: article });
```

**Confirm function**

`supabase/functions/confirm/index.ts`

```ts
// supabase/functions/confirm/index.ts
import { admin, corsHeaders, esc, signer } from "../_shared/esigncomply.ts";

const SEALED = ["recorded", "timestamped", "anchored"];

// Step 6: confirm the record with the secret key before the account exists.
Deno.serve(async (req) => {
  if (req.method === "OPTIONS") return new Response("ok", { headers: corsHeaders });

  const { recordId } = await req.json();
  const { ok, data: record } = await esc(`/records/${encodeURIComponent(String(recordId))}`);
  const { data: row } = await admin.from("acceptances").select("version_ids").eq("signer_id", signer.external_id).maybeSingle();

  const confirmed =
    ok &&
    row !== null &&
    SEALED.includes(record.status) &&
    record.livemode === (Deno.env.get("ESIGNCOMPLY_LIVE") === "true") &&
    record.signer.external_id === signer.external_id &&
    JSON.stringify(record.documents.map((d: { version_id: string }) => d.version_id).sort()) === JSON.stringify(row.version_ids);
  console.log(confirmed ? `confirmed ${record.id} (${record.status})` : "refused");
  if (!confirmed) return Response.json({ confirmed: false }, { status: 409, headers: corsHeaders });

  // Only now create the account. The record ID and the receipt stay in your own table.
  const { error } = await admin
    .from("acceptances")
    .update({ record_id: record.id, receipt: record.receipt, accepted_at: record.signed_at })
    .eq("signer_id", signer.external_id);
  // A receipt that was not stored is not confirmed: the page shows its "could not confirm" sentence.
  if (error) {
    console.error(`not stored: ${error.message}`);
    return Response.json({ error: "storage_failed" }, { status: 500, headers: corsHeaders });
  }
  return Response.json({ confirmed: true, recordId: record.id }, { 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](https://supabase.com/docs/guides/functions), read on November 23, 2026.

[Supabase quickstart](https://esigncomply.com/docs/quickstart/supabase) · [All platforms](https://esigncomply.com/platforms)

Where each part lives on Supabase

- **Session function** · `supabase/functions/ceremony/index.ts`
- **Table** · `supabase/migrations/20261123000000_acceptances.sql`
- **Documents in the page** · `public/signup.html`
- **Confirm function** · `supabase/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. **An Edge Function secret holds the key**

   Set 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](https://supabase.com/docs/guides/functions/secrets), read on November 23, 2026.

2. **An Edge Function creates the session**

   The `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. **A Postgres table keeps the receipt**

   The `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](https://supabase.com/docs/guides/functions/secrets), read on November 23, 2026.

### 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](https://supabase.com/docs/guides/functions/cors), read on November 23, 2026.

### 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 November 23, 2026: [Supabase documentation, Edge Functions](https://supabase.com/docs/guides/functions), [Supabase documentation, Environment variables](https://supabase.com/docs/guides/functions/secrets), [Supabase documentation, CORS](https://supabase.com/docs/guides/functions/cors), [Supabase documentation, Edge Functions limits](https://supabase.com/docs/guides/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](https://esigncomply.com/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](https://esigncomply.com/product/prompt-generator) writes the long version, with your own document and profile IDs.

[Pages for each AI tool](https://esigncomply.com/build)

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.

- **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](https://supabase.com/docs/guides/functions/limits), read on November 23, 2026.

- **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.

- **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.

## Where are the Supabase quickstart and the API reference?

Start with the quickstart: it carries every file this page excerpts, in the order you write them.

- Quickstart

  **[Supabase quickstart](https://esigncomply.com/docs/quickstart/supabase)**

  Step by step, from install to your first sealed test record, with every file and the output of each step.

- Reference

  **[API reference](https://esigncomply.com/docs/api)**

  Every endpoint, field and error code. Sessions, records and documents are the three this page uses.

- Long guide

  **[Clickwrap in Next.js and Supabase](https://esigncomply.com/guides/nextjs-supabase-clickwrap)**

  Supabase with a Next.js server instead of Edge Functions: the table, the server actions and the webhook, file by file.

- Guide

  **[Server confirmation](https://esigncomply.com/docs/guides/server-confirmation)**

  The one place access is granted: what to compare, and the webhook that backs the check up.

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](https://esigncomply.com/product/evidence).

- **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.

[How sealing and verification work](https://esigncomply.com/product/evidence) · [Observed and asserted, in the docs](https://esigncomply.com/docs/concepts/observed-and-asserted) · [The offline verifier](https://esigncomply.com/docs/sdk/verify)

Record

`rec_Z4m8`

simple · L1

Recorded

Written durably, receipt signed with ES256

Timestamped

External RFC 3161 token over the record hash

Anchored

Public anchor pending

Checkbox changed by a trusted user event · observed

Terms of Service, version dv_3kT9 · observed

Server time 2026-11-21T15:03:20.291Z · observed

Signer email dana@example.org · asserted

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.

### Other platforms

- [Vercel](https://esigncomply.com/vercel)
- [Netlify](https://esigncomply.com/netlify)
- [Cloudflare Workers](https://esigncomply.com/cloudflare-workers)

### Stacks used with Supabase

- [React](https://esigncomply.com/react)
- [Next.js](https://esigncomply.com/nextjs)
- [Python](https://esigncomply.com/python)

[All platforms](https://esigncomply.com/platforms) · [All stacks](https://esigncomply.com/stacks) · [Clickwrap API](https://esigncomply.com/clickwrap) · [E-signature API](https://esigncomply.com/sign)

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

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/supabase)

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 November 23, 2026. `/supabase.md` is this page as Markdown.

---

Every page on esigncomply.com has a Markdown version at the same URL plus `.md` (the home page is `https://esigncomply.com/index.md`). https://esigncomply.com/llms.txt lists them.

---

Esign Comply is the e-signature API and clickwrap API for developers who build their own signing flow in their own UI: it supplies the ceremony rules as a generated prompt for AI coding tools, records events in direct browser ceremonies, and seals independent, verifiable evidence.
