Skip to content
DocsMenu

Add e-signatures and clickwrap with Turso

View as Markdown

Open this page inChatGPTClaudeCursor

To add e-signatures and clickwrap with Turso, run the esigncomply package in a Node.js server and keep the pinned versions and the receipt in a Turso database through @libsql/client. The database URL and its auth token are two secrets of your host, beside the API key. Esign Comply seals each acceptance as an independent record.

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

Paste this prompt into Cursor, Claude Code or another AI coding tool to have it build the same integration:

Add Esign Comply clickwrap to my app with a Turso database: 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/turso.md (the steps and the tested code for Turso)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Turso facts
- Packages (the only ones that exist): esigncomply (server, Node.js 20.19 or later, an ES module) and @esigncomply/browser. Without a bundler, load the browser SDK from https://esigncomply.com/sdk/v1/esigncomply.js. The database client is Turso's @libsql/client, for a libSQL database on Turso Cloud.
- Three secrets on the host: ESIGNCOMPLY_API_KEY, TURSO_DATABASE_URL and TURSO_AUTH_TOKEN. Never commit them, never print them. The local server of turso dev asks for no token.
- createClient({ url, authToken }) with the remote URL. No file: URL and no embedded replica for this table when more than one instance of the server runs: another instance reads its own copy.
- SQLite has no JSON type and no timestamp type. JSON.stringify the version IDs and JSON.parse them on read. Store the time as an ISO string. Never pass an array or a Date as an argument: the client stores "a,b" and a number of milliseconds, with no error.
- Write with one statement or with client.batch(). Never hold client.transaction() open across the call to Esign Comply: an interactive transaction times out after 5 seconds and blocks other writers until then.
- Give each preview a database of its own (turso db create NAME --from-db PRODUCTION) with a token of its own, and the test key.
- Expect live records only where ESIGNCOMPLY_LIVE is "true": 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. Server: POST /api/ceremony creates the session with esc.sessions.create and an Idempotency-Key, saves the signer ID and the pinned version IDs in the Turso database, and returns only clientToken, apiUrl and documents.
4. Server: GET /legal/terms and /legal/privacy 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. Server: POST /api/signup/confirm reads the record with esc.records.get and requires: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the row in the database. Only then create the account, and store the record ID and the receipt in the same 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 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:3000/signup --callback http://localhost:3000/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

The rest of this page is the same integration by hand, in eight steps. Steps 1 to 7 run on your machine with Node.js and the local server of the Turso CLI. Step 8 is the part that happens on Turso Cloud and on your host.

Before you start

  • A test API key. Create an account with your email, no card, then choose Create test key in the dashboard. The key is shown once and starts with esc_test_. An AI agent with an agent token creates it with POST /v1/agent/api-keys: see the agent account API.
  • Nothing else from Esign Comply. Test mode works on localhost with no card and no domain, and the Free plan includes it in full.
  • Node.js 20.19 or later, which the esigncomply package requires. This page was run on Node.js 24.22.1.
  • The Turso CLI and sqld, the libSQL server, on your PATH. turso dev starts sqld and the CLI does not include it: the libSQL repository lists a prebuilt binary, a Homebrew formula and a container image.
  • A Turso account, when you reach step 8. Steps 1 to 7 need none, and no login.
  • curl and jq for steps 2 and 3.

Step 1. Install

Install the server package and Turso's client in a new folder. The page loads the browser SDK from a script tag, so there is nothing to bundle.

mkdir esigncomply-quickstart && cd esigncomply-quickstart
npm init -y && npm pkg set type=module scripts.start="node server.js"
npm install esigncomply @libsql/client
mkdir public

npm pkg set type=module matters: esigncomply is an ES module and server.js uses import. Turso's documentation names four TypeScript packages. @libsql/client is the one for a remote libSQL database, which is what turso db create makes by default and what turso dev serves.

Step 2. Set the key

On your machine the key goes in .env, with the address of the local database. On your host there are three secrets: the key, the database URL and the database's auth token. None of them is ever committed.

# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...
TURSO_DATABASE_URL=http://127.0.0.1:8080
printf 'node_modules\n.env\n*.db\n*.db-*\n' > .gitignore

Load the file into your shell for the commands in steps 2, 3 and 7, then check that the key works:

set -a; . ./.env; set +a
curl -s ${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}/usage \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" | jq '{plan_name, test_events}'
{
  "plan_name": "Free",
  "test_events": {
    "used_this_month": 0,
    "quota_per_month": 500
  }
}

A 401 means the key is wrong or revoked: see invalid_api_key. The rules for handling keys are in /auth.md.

Step 3. Register a document version

Every record pins the exact version of each document by hash, so the documents are registered first. This block registers a Terms of Service and a Privacy Notice with one version each, and creates a profile: the Federal pack, a checkbox with a button, level L1. It is the same for every stack and needs curl and jq.

ESC=${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}
KEY="Authorization: Bearer $ESIGNCOMPLY_API_KEY"
JSON="Content-Type: application/json"

# Two sample documents, one version each.
TERMS=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Terms of Service","type":"terms"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$TERMS/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Terms of Service\n\nThese are sample terms for a test."},"material_change":true}' \
  | jq -r .id; sleep 1
PRIVACY=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Privacy Notice","type":"privacy_notice"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$PRIVACY/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Privacy Notice\n\nThis is a sample privacy notice for a test."}}' \
  | jq -r .id; sleep 1

# A profile: Federal pack, checkbox plus button, L1.
PROFILE=$(curl -s $ESC/profiles -H "$KEY" -H "$JSON" \
  -d '{"name":"Signup","jurisdictions":["US-FED"],"method":"checkbox","assurance_level":"L1"}' | jq -r .id)

printf 'ESIGNCOMPLY_PROFILE_ID=%s\nESIGNCOMPLY_TERMS_ID=%s\nESIGNCOMPLY_PRIVACY_ID=%s\n' "$PROFILE" "$TERMS" "$PRIVACY"

It prints the two version IDs, then three lines with your own IDs:

dv_YiWs9cmWoVSGp7ALPeZS
dv_bAYeA7QigKUH0iLhPpV7
ESIGNCOMPLY_PROFILE_ID=prof_SPVEgBT8a8Ror3mJ8M99
ESIGNCOMPLY_TERMS_ID=doc_bDgYFndAoC8tkeYibAVy
ESIGNCOMPLY_PRIVACY_ID=doc_mb2hnWKS0Qa7SKtucDW9

Add the three lines to .env. The pauses keep the script under the Free plan's 2 requests per second. Keep the names Terms of Service and Privacy Notice: the notice on your page names each document by its registered name, and rule CR-02 checks that it does. With your own documents, publish the text you already have and change the notice to match. See Documents and Profiles.

Step 4. Create a session on the server

Start the local database in a second terminal. It needs no account and no login:

turso dev --db-file local.db
sqld listening on port 8080.
Use the following URL to configure your libSQL client SDK for local development:

    http://127.0.0.1:8080

By default, no auth token is required when sqld is running locally. If you want to require authentication, use --auth-jwt-key-file to specify a file containing the JWT key.

Using database file local.db.

Without --db-file, Turso's documentation says the changes are lost when the server stops.

One module holds everything that touches the database: the versions a session pinned, and later the record and its receipt.

// store.js
import { createClient } from "@libsql/client";

// Two secrets on your host: the URL of the Turso database and its auth token. `turso dev` asks for no token.
// The URL names the remote database, never a file: every instance of the server then reads the same rows.
const db = createClient({ url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN });

// One row per signer: the versions the session pinned, then the record and its receipt.
// SQLite has no JSON type and no timestamp type: both columns are text.
export async function migrate() {
  // A batch is one implicit transaction in a single request: both statements apply, or neither does.
  await db.batch(
    [
      `CREATE TABLE IF NOT EXISTS esc_acceptances (
        signer_id    TEXT PRIMARY KEY,
        version_ids  TEXT NOT NULL,
        record_id    TEXT,
        receipt      TEXT,
        confirmed_at TEXT
      )`,
      "CREATE UNIQUE INDEX IF NOT EXISTS esc_acceptances_record ON esc_acceptances (record_id)",
    ],
    "write",
  );
}

export async function savePinned(signerId, versionIds) {
  // JSON.stringify here: the client takes an array as an argument without an error and stores "a,b".
  await db.execute({
    sql: `INSERT INTO esc_acceptances (signer_id, version_ids) VALUES (?, ?)
          ON CONFLICT (signer_id) DO UPDATE SET version_ids = excluded.version_ids`,
    args: [signerId, JSON.stringify(versionIds)],
  });
}

export async function getPinned(signerId) {
  const { rows } = await db.execute({ sql: "SELECT version_ids FROM esc_acceptances WHERE signer_id = ?", args: [signerId] });
  // The column comes back as a string, so parse it.
  return rows.length ? JSON.parse(rows[0].version_ids) : [];
}

export async function saveReceipt(signerId, recordId, receipt) {
  // One statement, no transaction held open. The time is an ISO string: a Date would be stored as milliseconds.
  await db.execute({
    sql: "UPDATE esc_acceptances SET record_id = ?, receipt = ?, confirmed_at = ? WHERE signer_id = ?",
    args: [recordId, receipt, new Date().toISOString(), signerId],
  });
}

export function close() {
  db.close();
}

Three lines of that file are there because of what the test showed with @libsql/client 0.18.0:

  • The URL is the remote database. With two embedded replicas of one database, standing in for two instances of the server, the first wrote a row and read it back. The second read no row, three seconds later as well, until it called sync(). With two file: URLs nothing was shared at all. The confirm route can run on another instance than the session route, so it reads the database itself.
  • JSON.stringify for the version IDs. An array passed as an argument was stored as the text dv_1,dv_2 and an object as [object Object], both with no error. A JSON string came back as a string, with typeof text in SQLite, and json_extract read it.
  • An ISO string for the time. A Date passed as an argument landed in the text column as 1795665600000.0. CURRENT_TIMESTAMP returned 2026-11-26 04:06:26, which is UTC with no zone in it: JavaScript read the same kind of value five hours off with TZ=America/New_York.

A second file creates the table and its index in one batch:

// migrate.js: creates the table. Run it once for each database, and in the release step of your host.
import { close, migrate } from "./store.js";

// IF NOT EXISTS in both statements: running it again changes nothing.
await migrate();
console.log("table esc_acceptances ready");
close();

The server creates the session in POST /api/ceremony and returns three values to the browser: the client token, the API URL and the pinned documents.

// server.js
import { createServer } from "node:http";
import { readFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { EsignComply } from "esigncomply";
import { close, getPinned, savePinned, saveReceipt } from "./store.js";

// The secret key stays in this process. The SDK reads the environment variable ESIGNCOMPLY_API_KEY itself.
const esc = new EsignComply();

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

const DOCUMENTS = {
  terms: process.env.ESIGNCOMPLY_TERMS_ID,
  privacy: process.env.ESIGNCOMPLY_PRIVACY_ID,
};
const SEALED = ["recorded", "timestamped", "anchored"];
// "true" in production only. Previews and staging hold the test key and leave it unset.
const LIVE = process.env.ESIGNCOMPLY_LIVE === "true";

function json(res, status, body) {
  res.writeHead(status, { "Content-Type": "application/json" });
  res.end(JSON.stringify(body));
}

async function body(req) {
  let text = "";
  for await (const chunk of req) text += chunk;
  return text ? JSON.parse(text) : {};
}

async function handle(req, res) {
  const url = new URL(req.url, `http://${req.headers.host}`);

  if (req.method === "GET" && url.pathname === "/signup") {
    res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
    return res.end(await readFile(new URL("./public/signup.html", import.meta.url)));
  }

  // The document pages: each one renders a registered version, unmodified.
  if (req.method === "GET" && url.pathname.startsWith("/legal/")) {
    const documentId = DOCUMENTS[url.pathname.slice("/legal/".length)];
    if (!documentId) return json(res, 404, { error: "not_found" });
    const { data, error } = await esc.documents.versions.getContent(documentId, url.searchParams.get("v") ?? "current");
    if (error) return json(res, 404, { error: error.code });
    res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
    return res.end(`<!doctype html><meta charset="utf-8"><article data-esc-document="${data.version_id}">${data.html}</article>`);
  }

  // Step 4: create the session with the secret key. The browser gets the client token only.
  if (req.method === "POST" && url.pathname === "/api/ceremony") {
    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 page that runs the ceremony: the origin the browser reports, plus its path.
        context: { url: `${req.headers.origin ?? url.origin}/signup`, locale: "en-US", purpose: "account_signup" },
      },
      { idempotencyKey: `signup-${signer.external_id}-${randomUUID()}` },
    );
    if (error) return json(res, 502, { error: error.code });
    // In the Turso database, not in memory: the confirmation can reach another instance of this server.
    await savePinned(signer.external_id, session.documents.map((d) => d.version_id).sort());
    return json(res, 200, { clientToken: session.client_token, apiUrl: session.api_url, documents: session.documents });
  }

  // Step 6: confirm the record with the secret key before the account exists.
  if (req.method === "POST" && url.pathname === "/api/signup/confirm") {
    const { recordId } = await body(req);
    const { data: record, error } = await esc.records.get(String(recordId));
    const expected = await getPinned(signer.external_id);
    const confirmed =
      !error &&
      SEALED.includes(record.status) &&
      record.livemode === LIVE &&
      record.signer.external_id === signer.external_id &&
      expected.length > 0 &&
      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 json(res, 409, { confirmed: false });
    // Only now create the account. The record ID and the receipt go in the same row.
    await saveReceipt(signer.external_id, record.id, record.receipt);
    return json(res, 200, { confirmed: true, recordId: record.id });
  }

  json(res, 404, { error: "not_found" });
}

// A route that throws must not end the process: answer 500 and keep serving.
const server = createServer((req, res) => {
  handle(req, res).catch((error) => {
    console.error(`${req.method} ${req.url}: ${error.message}`);
    if (!res.headersSent) json(res, 500, { error: "server_error" });
  });
});

const port = Number(process.env.PORT ?? 3000);
server.listen(port, () => console.log(`http://localhost:${port}/signup`));

// Hosts send SIGTERM before they stop a process: finish the open requests, close the database client, exit.
let stopping = false;
process.on("SIGTERM", () => {
  if (stopping) return;
  stopping = true;
  server.close(() => {
    close();
    process.exit(0);
  });
  server.closeIdleConnections();
});

The signer is a fixed test person here. In your app it is the signed-in user or the account you are about to create.

Every route runs inside handle, and the server answers 500 when one throws. In the test, with a database address nothing listened on, POST /api/ceremony answered 500, the signup page still answered 200, and the process kept running. A POST with a body cut short was answered 500 as well.

Create the table, then start the server:

node --env-file=.env migrate.js
node --env-file=.env server.js
table esc_acceptances ready
http://localhost:3000/signup

Step 5. Attach the ceremony in the browser

The browser SDK renders nothing. It observes the checkbox, the notice, the links and the button you built, and reports each step from the signer's browser straight to Esign Comply. Save the page as public/signup.html: the server sends it at /signup, so the page, the document pages and the two routes share one origin.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Create account</title>
    <style>
      body { font: 16px/1.5 system-ui, sans-serif; max-width: 480px; margin: 48px auto; padding: 0 20px; }
      a { color: #0b57d0; text-decoration: underline; }
      button { font: inherit; padding: 10px 16px; }
    </style>
  </head>
  <body>
    <h1>Create account</h1>
    <form id="signup">
      <div id="assent">
        <!-- The page is on screen before the script has a session, so the box stays disabled until the SDK watches it. -->
        <label><input id="agree" type="checkbox" disabled /> I agree to the Terms of Service and Privacy Notice</label>
        <p>
          By checking the box and clicking Create account, you agree to the
          <a id="tos-link" href="/legal/terms">Terms of Service</a> and acknowledge the
          <a id="privacy-link" href="/legal/privacy">Privacy Notice</a>.
        </p>
        <button id="create-account" type="submit" disabled>Create account</button>
      </div>
      <p id="message" role="alert"></p>
    </form>

    <script src="https://esigncomply.com/sdk/v1/esigncomply.js"></script>
    <script type="module">
      const agree = document.querySelector("#agree");
      const submit = document.querySelector("#create-account");
      const message = document.querySelector("#message");

      // Your server creates the session and returns only the client token and the pinned documents.
      const response = await fetch("/api/ceremony", { method: "POST" });
      const { clientToken, apiUrl, documents } = await response.json();

      const ceremony = await EsignComply.attach({ clientToken, apiUrl });
      ceremony.on("change", ({ remainingSteps }) => {
        submit.disabled = remainingSteps.some((step) => step !== "signature.applied");
      });

      // Point each link at the exact version this session pinned, then report it.
      const links = [document.querySelector("#tos-link"), document.querySelector("#privacy-link")];
      for (const [i, link] of links.entries()) {
        link.search = "?v=" + documents[i].version_id;
        await ceremony.presentDocument({ versionId: documents[i].version_id, mode: "hyperlink", link });
      }
      await ceremony.observeAssent({
        region: document.querySelector("#assent"), // notice, links, checkbox, button
        checkbox: agree,
        submit,
      });
      agree.disabled = false; // the SDK watches the box from here on. Only the user ticks it.

      document.querySelector("#signup").addEventListener("submit", async (event) => {
        event.preventDefault();
        try {
          const result = await ceremony.complete(); // the signing act, from the signer's own click
          // The result came to the browser. Your server confirms the record before anything is granted.
          const confirmed = await fetch("/api/signup/confirm", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ recordId: result.recordId }),
          });
          message.textContent = confirmed.ok
            ? `Account created. Record ${result.recordId}`
            : "We could not confirm whether your acceptance was recorded. Please wait while we check.";
        } catch (error) {
          message.textContent = error.message;
        }
      });
    </script>
  </body>
</html>

Open http://localhost:3000/signup. The checkbox starts unchecked and disabled: the page is on screen before the script has a session, and the script enables the box once the SDK observes it. The button stays disabled until the box is ticked. Tick it, click Create account, and the page shows:

Account created. Record rec_QgFcPc5VMSM7XBBRsasP

One page load sent one POST /api/ceremony.

Step 6. Confirm the record on the server

The result of complete() was delivered to the browser, so your server does not trust it. POST /api/signup/confirm in server.js reads the record with the secret key and the pinned versions from the database, and grants access only when four things hold: the status is recorded, timestamped or anchored; livemode is what this deployment expects; the signer is the one the session was created for; and the document versions are exactly the ones it pinned. This step is never optional.

ESIGNCOMPLY_LIVE is true in production only, the one environment that holds the live key. Everywhere else it is not set, so test records are accepted and live records are not.

The server logs one line for each confirmation, and the row then holds the record ID, the receipt and the time:

confirmed rec_QgFcPc5VMSM7XBBRsasP (recorded)

A record ID that was made up is refused with status 409:

curl -s -X POST http://localhost:3000/api/signup/confirm \
  -H "Content-Type: application/json" -d '{"recordId":"rec_made_up"}'
{"confirmed":false}

In the test, two instances of the server ran on one turso dev database. The first created a session, and a second instance that had created none confirmed the record: the pinned versions came from the database. An instance started with ESIGNCOMPLY_LIVE=true refused the same test record with 409.

See Server confirmation for the webhook that backs this route up when the browser closes early.

Step 7. Check the result

Open the dashboard and choose Records. The test record is there with what was observed, what was asserted, and its evidence report, watermarked TEST.

Then run the conformance check against the page. It opens the page in headless Chromium at three window sizes, signs as a visitor would, and tries four things that must be refused. One of them posts a made-up record ID to your confirm route.

npm install --save-dev playwright
npx playwright install chromium
npx esigncomply check --url http://localhost:3000/signup --callback http://localhost:3000/api/signup/confirm

The report for this page's code, shortened:

Violations that must be refused
  REFUSED   Submit with the checkbox untouched      No record was made.
  REFUSED   Completion from another origin          The API answered 403 domain_mismatch.
  REFUSED   Programmatic click                      No record was made.
  REFUSED   Forged success posted to your callback  http://localhost:3000/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_wtB7o9EM9o1gEP1ULMAR  session ses_5Um8ZUFKBfuwVXwa7Qpj, 5 events
  768x1024   record rec_Bpj3e9WkFWfQiKE9nq90  session ses_86wbhdbPEcdJWgJZTjem, 5 events
  1440x900   record rec_e612Pi4ZaWxdLgS4F2Pv  session ses_eZ6ybTjtCTTeqn050hE8, 5 events

Summary: 0 block, 0 warn, 27 pass.

The server logged a confirmed line for each of the three records.

Fix every finding marked block and read every finding marked warn. Each one names the rule the screen missed, the measurement and the fix. In test mode a finding never stops a record from being sealed, so read the report. The rules are on Conformance rules, and every flag of the command is on the CLI page.

Step 8. Go live

Going live takes three steps on the Esign Comply side. There is no plan to choose and no checkout: the Free plan records 10 live signatures a month.

  1. Register your production domain and verify it. See Register a domain.
  2. Add your organization's legal name, country and address under Go live in the dashboard.
  3. Create a live key. It is shown once and starts with esc_live_.

Test and live share nothing, so create the documents and the profile again with the live key, or copy them to live from the dashboard, and use the live IDs in production.

Then set up Turso Cloud. The settings below are from Turso's own documentation, read on November 26, 2026: Turso Cloud, Turso SDKs, TypeScript reference, Authentication, Authorization, Local Development, Embedded Replicas, Branching, SQL over HTTP reference, db create, db show, db tokens create and Build and run sqld. The turso db commands in this step need an account and were not run for this page.

The database. Create it, read its URL and create a token:

turso db create signup
turso db show signup --url
turso db tokens create signup

Turso's documentation says Turso Cloud hosts two engines. turso db create makes a libSQL database, the one @libsql/client is for. With --tursodb it makes a database of the newer Turso engine, which the documentation marks as an early preview on Turso Cloud and which takes another package, @tursodatabase/serverless. This page was run with libSQL only.

The two secrets. Set TURSO_DATABASE_URL and TURSO_AUTH_TOKEN where your host keeps secrets, beside ESIGNCOMPLY_API_KEY. The URL has the form libsql://[DB-NAME]-[ORG-NAME].turso.io. Turso's documentation says a token from turso db tokens create grants full access and never expires unless you pass --expiration, and that --read-only restricts it. This server writes, so a read-only token is the wrong one.

The token was checked on the local server: turso dev --auth-jwt-key-file makes it ask for one. With no token, with an expired token and with a token signed by another key, the client failed with SERVER_ERROR: Server returned HTTP status 401, and the session route answered 500. With a valid token the session was created and the record confirmed. A read-only token got 403 on the first write.

Several instances. Keep url on the remote database. Turso's documentation describes embedded replicas, a local file that syncs with the database: reads are served from the file, writes go to the remote primary, and other replicas see new data when they call sync() or at the next sync period. That is the behaviour the test in step 4 showed, and it is why this table is read remotely: a session pinned on one instance has to be visible to the next request on any other.

Transactions. Over HTTP there are two kinds. client.batch() sends the statements in one request as one implicit transaction: in the test, a batch whose second statement failed left no row behind. client.transaction() keeps a transaction open across requests, and Turso's documentation says it locks the database for writing, with a 5 second window to complete. In the test, a write transaction left open for 7 seconds failed at commit with TRANSACTION_TIMEOUT, its insert was gone, and a write from a second client waited 5.1 seconds. The confirm route calls Esign Comply first and writes with one statement afterwards, so no transaction is open during the call.

The table. Run node migrate.js with the two Turso variables set, once for each database and in the release step of your host. Both statements use IF NOT EXISTS: run twice in the test, it ended with exit code 0 both times.

Previews and test mode. Turso's documentation describes branching: turso db create NAME --from-db signup creates a separate database from an existing one, and it suggests one for each pull request, created through the Platform API. A branch needs a token of its own or a group token, schema changes are not merged back for you, and you delete the branch yourself. Give each preview the URL and token of its branch and the test key. The preview's host is your host's, and a test key refuses a host it does not know with domain_mismatch. List the exact host under Domains in the dashboard, or with the API:

curl -X PATCH https://esigncomply.com/v1/domains/dom_4Kx9 \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" -H "Content-Type: application/json" \
  -d '{ "test_origins": ["preview.example.dev"] }'

List exact hosts, up to 25, and take a host off the list when its preview is gone.

The production domain. Turso serves the database, not your pages, so the domain you register with Esign Comply is the one your host serves the signup page on. Verify it with one DNS record. See Register a domain.

In live mode context.url must be inside your registered domain, and browser calls are accepted only from it. By default a live signature with a finding at Block level is recorded and you are told at once which rule failed. Turn on blocking, on the dashboard's Conformance page, and it is refused before it is sealed. Run the check from step 7 until no finding is at Block level before you switch keys.

Troubleshooting

  • missing_api_key on a preview. The Esign Comply key is not among the secrets of that environment. In a test, the server started with an empty key and the session route answered 502 with this code. Set the test key where the preview reads its secrets. See missing_api_key.
  • domain_mismatch on a preview host. The host is not a test origin of your domain. Add the exact host under Domains in the dashboard. Test keys work on localhost with no setup. See domain_mismatch and Test mode.
  • SERVER_ERROR: Server returned HTTP status 401 in the server log. The database refused the auth token: it is missing, expired or made for another database. Create one with turso db tokens create and set TURSO_AUTH_TOKEN. Status 403 means the token is read-only. Could not start libsql-server from turso dev means sqld is not on your PATH.
  • 429 when the confirm route reads the record. The route needs no retry loop: the esigncomply package waits for the time in Retry-After and tries again, up to twice. In the test, four confirmations sent at once for one record all answered 200, two of them a second later than the others. Four reads sent at once through the package showed why: two got 429 with Retry-After: 1 and passed on the next attempt. See rate_limit_exceeded and Retries and timeouts.

Questions about the Turso quickstart

Which Turso package does the server use?

@libsql/client, Turso's client for a remote libSQL database. Turso's documentation lists three more packages: two for local databases of the Turso engine, and @tursodatabase/serverless for a remote database of that engine, which it marks as an early preview on Turso Cloud. This page was run with @libsql/client 0.18.0.

Does turso dev need a Turso account?

Not in the test. Turso CLI 1.0.34 ran turso dev with no login and printed the local URL. It starts sqld, the libSQL server, which has to be on your PATH: without it the command printed Could not start libsql-server. Every turso db command on this page needs an account and was not run.

Why does the server not use an embedded replica?

Because another instance would read its own copy. In the test with two embedded replicas, the second saw no row until it called sync(), three seconds after the first had written it. The confirm route must see what the session route pinned, so both read the remote database.

Why are the version IDs stored as text?

Because SQLite has no JSON type, and the client does not convert for you. In the test an array passed as an argument was stored as dv_1,dv_2 with no error. The code stores JSON.stringify of the sorted IDs and parses the string when it reads the row.

Was this quickstart run on Turso Cloud?

Not yet. The code ran against the local server that turso dev starts, with and without an auth token, as two instances on one database. Creating a database, its URL and tokens, branches for previews and the behaviour of the hosted database are proven only on Turso Cloud.

Next steps

Run on 2026-11-26 with Node.js 24.22.1, esigncomply 1.0.4, @libsql/client 0.18.0, the browser SDK script build and the conformance check from esigncomply 1.0.4, as two instances of the server on one database served by turso dev (Turso CLI 1.0.34 starting libsql-server 0.24.32, SQLite 3.45.1), with no Turso account and no login, against the API in test mode. A second turso dev started with --auth-jwt-key-file checked the auth token, and embedded replicas, batches and interactive transactions were tried against the same local server. The Turso Cloud settings are from Turso's documentation as of that date, and the turso db commands in step 8 were not run. No Turso Cloud database has been used yet.

Last updated · API version 2026-11-21