Skip to content
DocsMenu

Add e-signatures and clickwrap with PocketBase

View as Markdown

Open this page inChatGPTClaudeCursor

To add e-signatures and clickwrap with PocketBase, extend the one binary with JavaScript in pb_hooks. Two routes call the REST API with PocketBase's own $http.send, and the secret key stays in the environment of the process. A collection with locked API rules keeps the pinned versions and the receipt. 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 PocketBase app: 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/pocketbase.md (the steps and the tested code for PocketBase)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

PocketBase facts
- There is no Esign Comply package for PocketBase. The hooks in pb_hooks run in PocketBase's embedded JavaScript engine, not in Node.js: no fetch, no setTimeout, no npm package that needs Node.js. Call the REST API with $http.send. In the browser, load the SDK from https://esigncomply.com/sdk/v1/esigncomply.js.
- The secret key is the environment variable ESIGNCOMPLY_API_KEY of the PocketBase process, read with $os.getenv. PocketBase loads no .env file. Never put the key in pb_public, in a collection or in a migration. Never print it.
- Every handler runs in a scope of its own and cannot see variables of its file. Put shared code in pb_hooks/esc.js and load it with require(`${__hooks}/esc.js`) inside each handler.
- Routes with routerAdd: GET /signup, GET /legal/{slug}, POST /api/ceremony, POST /api/signup/confirm. Never register a path PocketBase already serves under /api/: the server stops when it loads the hook.
- Keep the pinned version IDs and the receipt in a collection created by a migration in pb_migrations, with all five API rules null. Read its json field with getString() and JSON.parse, never with get().
- One PocketBase instance, one pb_data folder. A second instance with its own data cannot confirm a session of the first.
- 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 sends POST /v1/sessions with an Idempotency-Key, saves the signer ID and the pinned version IDs in the collection, and returns only clientToken, apiUrl and documents.
4. Server: GET /legal/terms and /legal/privacy render the html of GET /v1/documents/{id}/versions/{version}/content 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 GET /v1/records/{id} and requires: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the row in the collection. 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:8090/signup --callback http://localhost:8090/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 the PocketBase executable and nothing else. Step 8 is the part that happens on your server.

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.
  • The PocketBase executable, from the download links of its documentation. This page was run on version 0.42.3.
  • No Node.js for the app. The conformance check in step 7 is a Node.js tool and needs Node.js 20.19 or later.
  • curl and jq for steps 2 and 3.

Step 1. Install

There is nothing to install with a package manager. Put the pocketbase executable in a new folder and make the three folders it reads:

mkdir esigncomply-quickstart && cd esigncomply-quickstart
# unzip the pocketbase executable into this folder
mkdir pb_hooks pb_migrations pb_public

There is no Esign Comply package for PocketBase, and the Node.js package cannot be used: PocketBase's documentation says the hooks run in an embedded JavaScript engine that is not a Node.js or browser environment, and that only CommonJS modules load. In the test with version 0.42.3, fetch, setTimeout, URL and crypto were undefined inside a handler, require("node:crypto") failed with No such built-in module, and require("esigncomply") failed with Invalid module. The hooks call the REST API with PocketBase's own HTTP helper instead, and the browser loads the SDK from a script tag.

Step 2. Set the key

The key goes in the environment of the PocketBase process. Keep it in .env on your machine and load the file into the shell that starts PocketBase: PocketBase loads no .env file itself. In the test, an instance started in the folder that holds .env, without loading it, answered missing_api_key.

# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...
printf 'pb_data\n.env\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, then load the file into your shell again. 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

Three files make the server half. The first is a migration: PocketBase applies each new file of pb_migrations when it starts. It creates the collection that holds the versions a session pinned, and later the record and its receipt.

// pb_migrations/1795000000_create_esc_acceptances.js: applied once, when PocketBase starts.
migrate(
  (app) => {
    const collection = new Collection({
      type: "base",
      name: "esc_acceptances",
      // All five API rules are null, which PocketBase calls locked: the Web API answers only a superuser.
      // The hooks do not go through the Web API, so they read and write the collection all the same.
      listRule: null,
      viewRule: null,
      createRule: null,
      updateRule: null,
      deleteRule: null,
      fields: [
        { name: "signer_id", type: "text", required: true },
        { name: "version_ids", type: "json", required: true },
        { name: "record_id", type: "text" },
        { name: "receipt", type: "text" },
        { name: "confirmed_at", type: "date" },
      ],
      indexes: ["CREATE UNIQUE INDEX idx_esc_acceptances_signer ON esc_acceptances (signer_id)"],
    });
    app.save(collection);
  },
  (app) => {
    app.delete(app.findCollectionByNameOrId("esc_acceptances"));
  },
);

The second file is what the routes share: the signer, the document IDs and one function that calls the REST API.

// pb_hooks/esc.js: what the routes share. A handler cannot see variables of main.pb.js, so each one loads this with require().
// There is no Esign Comply package for the hooks: the REST API is called with PocketBase's own HTTP helper.
const API = $os.getenv("ESIGNCOMPLY_API_URL") || "https://esigncomply.com/v1";

module.exports = {
  // The signer. In your app this is the signed-in user, or the account you are about to create.
  signer: {
    external_id: "user_7c1d",
    email: "dana@example.org",
    name: "Dana Whitfield",
    class: "consumer",
    country: "US",
    region: "US-CA",
  },
  documents: {
    terms: $os.getenv("ESIGNCOMPLY_TERMS_ID"),
    privacy: $os.getenv("ESIGNCOMPLY_PRIVACY_ID"),
  },
  sealed: ["recorded", "timestamped", "anchored"],
  // "true" in production only. Every other instance holds the test key and leaves it unset.
  live: $os.getenv("ESIGNCOMPLY_LIVE") === "true",

  // One call to the REST API with the secret key, which stays in the environment of the PocketBase process.
  // $http.send waits for the whole response and throws on a timeout or a network error.
  call: function (method, path, body, idempotencyKey) {
    const headers = { Authorization: "Bearer " + $os.getenv("ESIGNCOMPLY_API_KEY"), "Content-Type": "application/json" };
    if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
    const request = { url: API + path, method: method, headers: headers, body: body ? JSON.stringify(body) : "", timeout: 15 };
    let res = $http.send(request);
    // Nothing retries for you here. On 429 wait for the seconds in Retry-After, 1 at least and 5 at most,
    // and send the same request again, twice at most. Nothing else is retried.
    for (let attempt = 1; res.statusCode === 429 && attempt < 3; attempt++) {
      const wait = res.headers["Retry-After"] ? Number(res.headers["Retry-After"][0]) : 1;
      sleep(1000 * Math.min(Math.max(wait || 1, 1), 5));
      res = $http.send(request);
    }
    return { status: res.statusCode, data: res.json };
  },
};

It is a module of its own because of how PocketBase runs hooks. Its documentation says each handler is serialized and executed in an isolated context, with no access to variables declared outside it, and names require() inside the handler as the way to share code. In the test, a constant declared at the top of a hooks file was undefined inside a route, and a route that used it answered 400.

When the API answers 429, call waits for the seconds in Retry-After, 1 at least and 5 at most, and sends the same request again, up to twice. The hooks have no setTimeout, so the wait is PocketBase's sleep(). It holds that one request: in the test, page requests sent while confirmations waited were answered in under 0.01 seconds.

The third file holds the routes. POST /api/ceremony creates the session and returns three values to the browser: the client token, the API URL and the pinned documents.

// pb_hooks/main.pb.js
/// <reference path="../pb_data/types.d.ts" />

// The signup page is a file in pb_public. PocketBase serves it at /signup.html, and this route serves it at /signup.
routerAdd("GET", "/signup", (e) => {
  return e.fileFS($os.dirFS(__hooks + "/../pb_public"), "signup.html");
});

// The document pages: each one renders a registered version, unmodified.
routerAdd("GET", "/legal/{slug}", (e) => {
  const esc = require(`${__hooks}/esc.js`);
  const documentId = esc.documents[e.request.pathValue("slug")];
  if (!documentId) return e.json(404, { error: "not_found" });
  const version = e.request.url.query().get("v") || "current";
  const res = esc.call("GET", "/documents/" + documentId + "/versions/" + encodeURIComponent(version) + "/content");
  if (res.status !== 200) return e.json(404, { error: res.data.error.code });
  return e.html(200, '<!doctype html><meta charset="utf-8"><article data-esc-document="' + res.data.version_id + '">' + res.data.html + "</article>");
});

// Step 4: create the session with the secret key. The browser gets the client token only.
routerAdd("POST", "/api/ceremony", (e) => {
  const esc = require(`${__hooks}/esc.js`);
  // The page that runs the ceremony: the origin the browser reports, plus its path.
  const origin = e.request.header.get("Origin") || "http://" + e.request.host;
  const res = esc.call(
    "POST",
    "/sessions",
    {
      profile: $os.getenv("ESIGNCOMPLY_PROFILE_ID"),
      signer: esc.signer,
      documents: [
        { document: esc.documents.terms, version: "current" },
        { document: esc.documents.privacy, version: "current" },
      ],
      context: { url: origin + "/signup", locale: "en-US", purpose: "account_signup" },
    },
    "signup-" + esc.signer.external_id + "-" + $security.randomString(24),
  );
  if (res.status !== 201) return e.json(502, { error: res.data.error.code });

  // One row per signer, in a collection whose API rules are locked: only the hooks and a superuser read it.
  const collection = e.app.findCollectionByNameOrId("esc_acceptances");
  let row;
  try {
    row = e.app.findFirstRecordByData("esc_acceptances", "signer_id", esc.signer.external_id);
  } catch (_) {
    row = new Record(collection);
    row.set("signer_id", esc.signer.external_id);
  }
  row.set("version_ids", res.data.documents.map((d) => d.version_id).sort());
  e.app.save(row);
  return e.json(200, { clientToken: res.data.client_token, apiUrl: res.data.api_url, documents: res.data.documents });
});

// Step 6: confirm the record with the secret key before the account exists.
routerAdd("POST", "/api/signup/confirm", (e) => {
  const esc = require(`${__hooks}/esc.js`);
  const recordId = String(e.requestInfo().body.recordId || "missing");
  const res = esc.call("GET", "/records/" + encodeURIComponent(recordId));
  const record = res.data;

  let row = null;
  let expected = [];
  try {
    row = e.app.findFirstRecordByData("esc_acceptances", "signer_id", esc.signer.external_id);
    // get() on a json field returns the bytes of the JSON text, so read it as a string and parse it.
    expected = JSON.parse(row.getString("version_ids"));
  } catch (_) {}

  const confirmed =
    res.status === 200 &&
    esc.sealed.indexOf(record.status) >= 0 &&
    record.livemode === esc.live &&
    record.signer.external_id === esc.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 e.json(409, { confirmed: false });

  // Only now create the account. The record ID and the receipt go in the same row.
  row.set("record_id", record.id);
  row.set("receipt", record.receipt);
  row.set("confirmed_at", new DateTime());
  e.app.save(row);
  return e.json(200, { confirmed: true, recordId: record.id });
});

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.

Load the key into the shell and start PocketBase:

set -a; . ./.env; set +a
./pocketbase serve
Server started at http://127.0.0.1:8090
> Dashboard: http://127.0.0.1:8090/_/
> REST API:  http://127.0.0.1:8090/api/

The first start also prints a link that creates the first superuser. PocketBase reloads the hooks when a file in pb_hooks changes.

PocketBase let the hooks own all five paths. In the test, /signup, /legal/terms, /legal/privacy, /api/ceremony and /api/signup/confirm were answered by the routes above, and the system routes under /api/ went on working. PocketBase's documentation suggests a prefix such as /api/myapp/ for your own routes, to avoid collisions with system routes. A collision is not subtle: a hook that registered GET /api/health, a path PocketBase has, stopped the server with pattern "GET /api/health" conflicts with pattern "GET /api/health".

A handler that throws does not stop the server. In the test, a POST with a body cut short and a session route whose API address nothing listened on were both answered 400 with PocketBase's own message, Something went wrong while processing your request., and the next request was served. The console showed nothing. The request logs, which the dashboard shows, listed the request with its error.

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 pb_public/signup.html. PocketBase serves that folder as static files, so the page answers at /signup.html, and the first route of main.pb.js serves the same file at /signup: in the test a file other.html answered at /other.html and not at /other.

<!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:8090/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_JPETgLqm6dXjCbZqxCoo

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 main.pb.js reads the record with the secret key and the pinned versions from the collection, and grants access only when four things hold: the status is recorded, timestamped or anchored; livemode is what this instance 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.

The pinned versions are read with getString() and JSON.parse. In the test, get() on the json field returned an array of 15 numbers, the bytes of the stored text, and not the two IDs it held.

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

PocketBase prints one line for each confirmation, and the row then holds the record ID, the receipt and the time:

2026/11/26 11:59:13 confirmed rec_JPETgLqm6dXjCbZqxCoo (recorded)

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

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

In the test, PocketBase was stopped and started again, and it confirmed the record from the row in pb_data. A second instance with a data folder of its own refused a record whose session the first had created, with 409. An instance started with ESIGNCOMPLY_LIVE=true refused a 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. The checker is a Node.js command line tool, so it needs Node.js 20.19 or later, in a folder of its own:

mkdir -p esc-check && cd esc-check
npm init -y && npm install esigncomply playwright
npx playwright install chromium
npx esigncomply check --url http://localhost:8090/signup --callback http://localhost:8090/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:8090/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_bQWbfRaN1h9iAL7ugTqZ  session ses_g6ocvVE2ej8aeiLrDCHd, 5 events
  768x1024   record rec_FrpYJ6NAZ4qhFsmpWj1j  session ses_yAgutFXxH6FRBdir7unF, 5 events
  1440x900   record rec_UqH0ceiLrTAWWkp4RMST  session ses_kQtZPnEVdP1jHSE3ykVC, 5 events

Summary: 0 block, 0 warn, 27 pass.

PocketBase 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 the server. The settings below are from PocketBase's own documentation, read on November 26, 2026: Introduction, Extend with JavaScript, Overview, Routing, Sending HTTP requests, Migrations, Collection operations, Record operations, API rules and filters, Going to production and the FAQ. None of the production setup below was run for this page.

One server. PocketBase's FAQ says there is no hosted PocketBase, and that it scales only on a single server. The data is the pb_data folder beside the executable, so the server needs a disk that persists. The pinned versions and the receipts are in that folder: copy it or use the backups in the dashboard, as the production guide describes. The test above is the reason not to run two instances: the second one had no row for a session the first created.

The key. Set ESIGNCOMPLY_API_KEY, the three IDs and ESIGNCOMPLY_LIVE=true in the environment of the process that starts PocketBase. The production guide runs PocketBase as a systemd service: the variables belong in the environment of that service, in a file only its user can read. Nothing under pb_public is private, and pb_migrations is meant to be committed, so the key goes in neither.

TLS and the domain. The production guide starts PocketBase with ./pocketbase serve yourdomain.com, which issues a Let's Encrypt certificate for that domain, or puts it behind a reverse proxy. Register the same domain with Esign Comply and verify it with one DNS record. In live mode context.url must be inside it, and the session route builds that URL from the Origin header of the request.

Who can read the collection. The migration leaves all five API rules null. PocketBase's documentation calls that locked: the action can be performed only by a superuser, and the rules are ignored for superusers. In the test, a guest and a signed-in user of the users collection got 403 with Only superusers can perform this action. on list and create, and a superuser read the row, receipt included. The dashboard at /_/ shows the same rows to every superuser. The production guide recommends restricting superusers to specific IP addresses, and lists MFA for them as an option.

Migrations. PocketBase applies new files of pb_migrations when it starts, and its documentation says they are safe to commit. In the test a new data folder got the collection on the first start. A change you make to the collection in the dashboard writes a new migration file, which the documentation calls automigrate: commit it with the hooks.

Previews and test mode. PocketBase has no preview deployments of its own. A preview is another PocketBase process on another host, with a pb_data folder of its own and the test key. 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. See Test mode.

Updates. PocketBase's documentation says full backward compatibility is not guaranteed before version 1.0.0. Read its changelog before you replace the executable, and run the check from step 7 again afterwards.

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 from the session route. PocketBase was started without the key in its environment. It loads no .env file: run set -a; . ./.env; set +a in the shell that starts it, or set the variable in the service. In the test the route answered 502 with this code. See missing_api_key.
  • 429 when the confirm route reads the record. call in esc.js waits for the seconds in Retry-After, 1 at least and 5 at most, and sends the same request again, up to twice. Nothing else is retried. In the test, four confirmations sent at once all answered 200, two of them a second later than the others. Six at once all answered 200 too, two of them after two waits. Against a stand-in that always answered 429 with Retry-After: 30, the session route made three calls five seconds apart and answered 502. See rate_limit_exceeded. When the route answers 409 for a real record, the cause is a pb_data folder that is not the one the session was created in.
  • A route answers 400 with Something went wrong while processing your request. The handler threw: a variable from outside the handler, a body that is not JSON, or an API address that does not answer. The console shows nothing. Open Logs in the dashboard at /_/, where the request is listed with its error.

Questions about the PocketBase quickstart

Is there an Esign Comply package for PocketBase?

No. The hooks run in PocketBase's embedded JavaScript engine, which its documentation says is not a Node.js environment. In the test with version 0.42.3, fetch and setTimeout were undefined and require("esigncomply") failed. The routes call the REST API with $http.send, and the browser loads the SDK from a script tag.

Why does every route call require()?

Because a handler cannot see the variables of its own file. PocketBase's documentation says each handler runs in an isolated context and names require() inside the handler as the way to share code. In the test a constant declared at the top of the file was undefined inside a route.

How do the hooks read the secret key?

With $os.getenv("ESIGNCOMPLY_API_KEY"), from the environment of the PocketBase process. PocketBase loads no .env file: in the test an instance started beside one, without loading it, answered missing_api_key. A variable that is not set reads as an empty string.

Can two PocketBase instances share the work?

No. PocketBase's FAQ says it scales only on a single server, and the data is one pb_data folder. In the test, a second instance with a data folder of its own refused a record whose session the first had created, with 409.

Was this quickstart run on a production server?

Not yet. It ran with the prebuilt PocketBase 0.42.3 executable on one machine, over plain HTTP on localhost. The certificate that serve issues for a domain, a reverse proxy, the systemd service, backups and updates are from PocketBase's documentation and are proven only on a real server.

Next steps

Run on 2026-11-26 with the prebuilt PocketBase 0.42.3 executable for Linux x64, started with --dir, --hooksDir, --migrationsDir and --publicDir pointing at the folders of this project, with no Node.js and no package in the project, and with the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode. A second instance with a data folder of its own was tried, the collection was read as a superuser, as a signed-in user and as a guest, and the JavaScript engine of the hooks was probed in the same version. Everything ran on one machine over plain HTTP on localhost. TLS, a domain, a reverse proxy, backups and updates of PocketBase are from its documentation as of that date and were not run.

Last updated · API version 2026-11-21