# Add e-signatures and clickwrap to an app on Netlify

> Add e-signatures and clickwrap to an app on Netlify: Netlify Functions create and confirm the session, the key is a site variable, Blobs keeps the state.

Source: https://esigncomply.com/netlify

Platform · Netlify

To add e-signatures and clickwrap to an app on Netlify, store the secret key as a site environment variable, with the live key in the production context only. Netlify Functions create the session and confirm the record, and Netlify Blobs keeps what the session pinned. Esign Comply seals the record, and your database 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/netlify)

`npm install esigncomply @netlify/blobs && npm install --save-dev netlify-cli`

[Netlify quickstart](https://esigncomply.com/docs/quickstart/netlify)

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

Last updated November 26, 2026

Run locally for Netlify before publishing

**Session function**

`netlify/functions/ceremony.mjs`

```js
// netlify/functions/ceremony.mjs
import { ceremonies, DOCUMENTS, esc, signer } from "../lib/esigncomply.mjs";

// Step 4: create the session with the secret key. The browser gets the client token only.
export default async (req) => {
  const { data: session, error } = await esc.sessions.create(
    {
      profile: process.env.ESIGNCOMPLY_PROFILE_ID,
      signer,
      documents: [
        { document: DOCUMENTS.terms, version: "current" },
        { document: DOCUMENTS.privacy, version: "current" },
      ],
      // The origin the browser reports: localhost, a Deploy Preview or your production domain.
      context: { url: `${req.headers.get("origin") ?? new URL(req.url).origin}/signup`, locale: "en-US", purpose: "account_signup" },
    },
    { idempotencyKey: `signup-${signer.external_id}-${crypto.randomUUID()}` },
  );
  if (error) return Response.json({ error: error.code }, { status: 502 });

  await ceremonies().setJSON(signer.external_id, session.documents.map((d) => d.version_id).sort());
  return Response.json({ clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents });
};

export const config = { path: "/api/ceremony", method: "POST" };
```

**Shared module**

`netlify/lib/esigncomply.mjs`

```js
// netlify/lib/esigncomply.mjs
import { getStore } from "@netlify/blobs";
import { EsignComply } from "esigncomply";

// Functions read variables with process.env. The SDK reads ESIGNCOMPLY_API_KEY itself.
export const esc = new EsignComply();

export const SEALED = ["recorded", "timestamped", "anchored"];
export const DOCUMENTS = {
  terms: process.env.ESIGNCOMPLY_TERMS_ID,
  privacy: process.env.ESIGNCOMPLY_PRIVACY_ID,
};

// The signer. In your app this is the signed-in user, or the account you are about to create.
export const signer = {
  external_id: "user_7c1d",
  email: "dana@example.org",
  name: "Dana Whitfield",
  class: "consumer",
  country: "US",
  region: "US-CA",
};

// Two functions do not share memory. What the session pinned goes to Netlify Blobs,
// read with strong consistency so the confirmation sees it at once.
export const ceremonies = () => getStore({ name: "ceremonies", consistency: "strong" });
```

**Confirm function**

`netlify/functions/confirm.mjs`

```js
// netlify/functions/confirm.mjs
import { ceremonies, esc, SEALED, signer } from "../lib/esigncomply.mjs";

// Step 6: confirm the record with the secret key before the account exists.
export default async (req, context) => {
  const { recordId } = await req.json();
  const { data: record, error } = await esc.records.get(String(recordId));
  const expected = await ceremonies().get(signer.external_id, { type: "json" });
  const confirmed =
    !error &&
    expected !== null &&
    SEALED.includes(record.status) &&
    // Only the production deploy holds the live key and accepts live records.
    record.livemode === (context.deploy.context === "production") &&
    record.signer.external_id === signer.external_id &&
    JSON.stringify(record.documents.map((d) => d.version_id).sort()) === JSON.stringify(expected);
  console.log(confirmed ? `confirmed ${record.id} (${record.status})` : "refused");
  if (!confirmed) return Response.json({ confirmed: false }, { status: 409 });
  // Only now create the account, and store record.id and record.receipt with it.
  return Response.json({ confirmed: true, recordId: record.id });
};

export const config = { path: "/api/signup/confirm", method: "POST" };
```

Integrate with Netlify

## How do you integrate Esign Comply with Netlify?

On Netlify the server half is three functions under `netlify/functions`, each with a path of its own. They read the key with `process.env`, and the confirm function reads its deploy context from `context.deploy.context`. Two functions share no memory, so the pinned versions go to Netlify Blobs, opened with strong consistency.

A function is a file in your project that contains server-side code for responding to an event.

Source: [Netlify documentation, Functions overview](https://docs.netlify.com/build/functions/overview/), read on November 23, 2026.

[Netlify quickstart](https://esigncomply.com/docs/quickstart/netlify) · [All platforms](https://esigncomply.com/platforms)

Where each part lives on Netlify

- **Session function** · `netlify/functions/ceremony.mjs`
- **Shared module** · `netlify/lib/esigncomply.mjs`
- **Confirm function** · `netlify/functions/confirm.mjs`

Run on 2026-11-26 with Netlify CLI 27.20.1 (netlify dev, offline), @netlify/blobs 11.1.10, esigncomply 1.0.4, the browser SDK script build and the conformance check from esigncomply 1.0.4 on Node.js 24.22.1, against the API in test mode. The Netlify settings are from Netlify's documentation as of 2026-11-23. The code has not yet been run on a Netlify deploy.

Three steps

## How does Esign Comply fit with Netlify?

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

1. **A site environment variable holds the key**

   Set `ESIGNCOMPLY_API_KEY` in the Netlify UI or with `netlify env:set`, with a different value per deploy context: the live key for production, the test key for Deploy Previews, branch deploys and local development. Source: [Netlify documentation, Environment variables overview](https://docs.netlify.com/build/environment-variables/overview/), read on November 23, 2026.

2. **A Netlify Function creates the session**

   `netlify/functions/ceremony.mjs` calls `esc.sessions.create` and answers at `/api/ceremony`, the path its `config` names. A second function serves the document pages, and the browser SDK records the ceremony from the signer's device.

3. **The confirm function checks the deploy context**

   `netlify/functions/confirm.mjs` reads the pinned versions from Netlify Blobs and expects a live record only when `context.deploy.context` is `production`. Your database keeps the record ID and the receipt. Source: [Netlify documentation, Functions API reference](https://docs.netlify.com/build/functions/api/), read on November 23, 2026.

Netlify setup

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

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

### Environment variables

Set them in the UI or with `netlify env:set ESIGNCOMPLY_API_KEY <value> --context production --secret`. Variables declared in `netlify.toml` are not available to functions, and a change needs a new build and deploy to take effect. Locally, `netlify dev` reads `.env`.

Source: [Netlify documentation, Environment variables and functions](https://docs.netlify.com/build/functions/environment-variables/), read on November 23, 2026.

### Deploy Previews and test mode

A test key refuses a host it does not know. Each pull request gets a host of the form `deploy-preview-<number>--<site-name>.netlify.app`: list the host of the preview you are testing under Domains in the Esign Comply dashboard as a test origin. Never list the shared suffix `netlify.app`.

Source: [Netlify documentation, Deploy Previews](https://docs.netlify.com/deploy/deploy-types/deploy-previews/), read on November 23, 2026.

### The registered domain

Register your custom domain and verify it with one DNS record. A production site on a `netlify.app` host verifies with a file instead: put the token in `public/.well-known/esigncomply.txt`.

### The webhook endpoint

Add a function for the `record.completed` webhook and register its production URL under Webhooks in the Esign Comply dashboard. It backs the confirmation up when the browser closes before your function hears about the record.

Read on November 23, 2026: [Netlify documentation, Functions overview](https://docs.netlify.com/build/functions/overview/), [Netlify documentation, Environment variables overview](https://docs.netlify.com/build/environment-variables/overview/), [Netlify documentation, Environment variables and functions](https://docs.netlify.com/build/functions/environment-variables/), [Netlify documentation, Functions API reference](https://docs.netlify.com/build/functions/api/), [Netlify documentation, Netlify Blobs](https://docs.netlify.com/build/data-and-storage/netlify-blobs/), [Netlify documentation, Deploy Previews](https://docs.netlify.com/deploy/deploy-types/deploy-previews/).

Copy-paste prompt

## What prompt adds Esign Comply clickwrap to a Netlify 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 Netlify, 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 Netlify

```
Add Esign Comply clickwrap to my site on Netlify: 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/netlify.md (the steps and the tested code for Netlify)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Netlify facts
- Packages (the only ones that exist): esigncomply (server) and @esigncomply/browser. Without a bundler, load the browser SDK from https://esigncomply.com/sdk/v1/esigncomply.js.
- Server calls live in Netlify Functions under netlify/functions, each with export const config = { path }. Functions read variables with process.env.
- The secret key is the site environment variable ESIGNCOMPLY_API_KEY, set in the Netlify UI or with netlify env:set. Variables declared in netlify.toml do not reach functions. Never print the key.
- Two functions share no memory. Keep the pinned version IDs in Netlify Blobs with strong consistency, or in the database.
- Expect live records only when context.deploy.context is "production".
- 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. Function ceremony (path /api/ceremony): create the session with esc.sessions.create and an Idempotency-Key, save the signer ID and the pinned version IDs in server-owned state, and return only clientToken, apiUrl and documents.
4. Function legal (path /legal/:slug): render the registered version from esc.documents.versions.getContent inside <article data-esc-document>, unmodified.
5. Browser: EsignComply.attach({ clientToken, apiUrl }), presentDocument for each link, observeAssent({ region, checkbox, submit }), then complete() from the user's real click.
6. Function confirm (path /api/signup/confirm): read the record with esc.records.get and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the server-owned state. Only then create the account.

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 server 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:8888/signup --callback http://localhost:8888/api/signup/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 Netlify?

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

- **Variables in netlify.toml do not reach functions**

  Netlify's documentation says so, and the local run showed it: a variable declared under `[build.environment]` was not set inside a function, while the ones from `.env` were. Set the key in the UI or with `netlify env:set`.

  Source: [Netlify documentation, Environment variables and functions](https://docs.netlify.com/build/functions/environment-variables/), read on November 23, 2026.

- **Netlify Blobs is eventually consistent by default**

  Updates can take up to 60 seconds to reach every edge location, and the confirmation reads what another function wrote a moment earlier. Open the store with `consistency: "strong"`, as the quickstart does.

  Source: [Netlify documentation, Netlify Blobs](https://docs.netlify.com/build/data-and-storage/netlify-blobs/), read on November 23, 2026.

- **The deploy context is not production under netlify dev**

  In the local run `context.deploy.context` was `dev`, so the confirm function expected test records. It is `production` on the production deploy only, which is the one context that holds the live key.

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

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

- Quickstart

  **[Netlify quickstart](https://esigncomply.com/docs/quickstart/netlify)**

  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.

- 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 Netlify?

The same record on every stack and platform. Your Netlify 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 Netlify

### How does test mode work on Netlify Deploy Previews?

A test key works on a Deploy Preview once the preview's host is listed as a test origin of your domain. Give the preview contexts the test key and add the exact `netlify.app` host under Domains. Without the entry the session is refused with `domain_mismatch`.

### Where should the receipt be stored on Netlify?

In your own database, beside the user, with the record ID. The quickstart keeps only the pinned version IDs in Netlify Blobs, which is state for one ceremony. The confirm function is the place to write the receipt.

### Can the key live in netlify.toml?

No. Netlify's documentation says variables declared in `netlify.toml` are not available to functions, and a key in that file would be committed. Set it in the Netlify UI or with `netlify env:set`, and mark it as secret.

### Can I try it without a Netlify account?

Yes. `netlify dev --offline` ran the three functions, the static page and a local Blobs store with no account in the test, on Netlify CLI 27.20.1. You need a site on Netlify to set variables per deploy context and to deploy.

### Was this code run on a Netlify deploy?

Not yet. It was run with `netlify dev --offline`, and the Netlify settings come from Netlify's documentation as of November 23, 2026. Variables per deploy context, Blobs on the hosted platform and file verification on a `netlify.app` host are proven only by a deploy.

### Other platforms

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

### Stacks used with Netlify

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

[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)

## Put the key in a Netlify Function. Leave the record to us.

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

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

Netlify is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Netlify is from Netlify's documentation or from a test run, as marked, on November 23, 2026. `/netlify.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.
