# Add e-signatures and clickwrap on DigitalOcean App Platform

> Run a signup clickwrap on DigitalOcean App Platform with the esigncomply package in a Node.js service, the key as a SECRET in the app spec, and Postgres.

Source: https://esigncomply.com/docs/quickstart/digitalocean-app-platform

Last updated November 26, 2026

To add e-signatures and clickwrap on DigitalOcean App Platform, run the `esigncomply` package in a Node.js service and declare the secret key in the app spec as an encrypted `SECRET` variable. The service creates the session and confirms the record, and a managed PostgreSQL database keeps 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:

```text copy="Copy prompt" open="cursor"
Add Esign Comply clickwrap to my app on DigitalOcean App Platform: 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/digitalocean-app-platform.md (the steps and the tested code for DigitalOcean App Platform)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

DigitalOcean App Platform 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 secret key is the environment variable ESIGNCOMPLY_API_KEY, declared in .do/app.yaml with type: SECRET. Never write its value in the file: the deploy workflow fills it in from a repository secret, or it is typed into the control panel with Encrypt. Never print it.
- The service listens on 0.0.0.0 on the port in PORT (http_port, 8080 by default). Set run_command to "node server.js": the default of a Node.js component is npm start.
- A service can run several containers, each with its own ephemeral filesystem. Keep the pinned version IDs in the managed PostgreSQL database (DATABASE_URL from ${db.DATABASE_URL}), never in a variable of the process or in a file.
- Pass ${db.CA_CERT} as DATABASE_CA_CERT. Where it is set, remove sslmode from the URL and give pg ssl: { ca }: pg 8 lets sslmode in the URL replace the ssl option.
- Create the table in a job of kind PRE_DEPLOY with CREATE TABLE IF NOT EXISTS: it runs before every deployment.
- Handle SIGTERM: App Platform sends it to a container it replaces, then SIGKILL after grace_period_seconds.
- Expect live records only where ESIGNCOMPLY_LIVE is "true": the production app.
- Never push an image that doctl apps dev build made in a folder that holds .env: the build copies the whole folder.
- 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 Postgres, 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 Postgres. 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:8080/signup --callback http://localhost:8080/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 a Postgres database in Docker. Step 8 is the part that happens on App Platform.

## Before you start

- A test API key. [Create an account](https://esigncomply.com/signup) 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](https://esigncomply.com/docs/api/agent.md).
- 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 on the machine and on Node.js 24.15.0 in the image DigitalOcean's builder made.
- Docker, for a Postgres database on your machine.
- A DigitalOcean account, a GitHub repository and `doctl`, when you reach step 8. Steps 1 to 7 need none of them.
- `curl` and `jq` for steps 2 and 3.

## Step 1. Install

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

```bash
mkdir esigncomply-quickstart && cd esigncomply-quickstart
npm init -y && npm pkg set type=module scripts.start="node server.js" engines.node=24.x
npm install esigncomply pg
mkdir public
```

`npm pkg set type=module` matters: `esigncomply` is an ES module and `server.js` uses `import`. `engines.node` matters on App Platform: DigitalOcean's documentation says a Node.js component gets Node.js 22.x when the field is missing, and recommends naming the version. Commit `package-lock.json`: the build installs from it with `npm ci`.

## Step 2. Set the key

On your machine the key goes in `.env`, with the address of the local database. On App Platform both are environment variables of the app: the key is an encrypted variable, and the database component fills in `DATABASE_URL`. Neither is ever committed.

```bash
# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...
DATABASE_URL=postgres://postgres:local@127.0.0.1:5432/quickstart
```

```bash
printf 'node_modules\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:

```bash
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}'
```

```json
{
  "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`](https://esigncomply.com/docs/api/errors.md#invalid_api_key). The rules for handling keys are in [/auth.md](https://esigncomply.com/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`.

```bash
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:

```text
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](https://esigncomply.com/docs/conformance.md#cr-02) checks that it does. With your own documents, publish the text you already have and change the notice to match. See [Documents](https://esigncomply.com/docs/api/documents.md) and [Profiles](https://esigncomply.com/docs/api/profiles.md).

## Step 4. Create a session on the server

Start a Postgres database on your machine. It stands in for the managed database of step 8:

```bash
docker run -d --name esc-postgres -p 127.0.0.1:5432:5432 \
  -e POSTGRES_PASSWORD=local -e POSTGRES_DB=quickstart \
  public.ecr.aws/docker/library/postgres:17-alpine
```

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

```js file="store.js"
// store.js
import pg from "pg";

// App Platform fills both variables from the database component: ${db.DATABASE_URL} and ${db.CA_CERT} in .do/app.yaml.
const config = { connectionString: process.env.DATABASE_URL };
const ca = process.env.DATABASE_CA_CERT;
if (ca) {
  // DigitalOcean's connection strings can carry sslmode=require. pg 8 lets that parameter replace the ssl option,
  // so it comes off, and the certificate of the database is verified against the CA certificate DigitalOcean provides.
  const url = new URL(config.connectionString);
  url.searchParams.delete("sslmode");
  config.connectionString = url.href;
  config.ssl = { ca };
}
// The Postgres on your machine has no TLS: there DATABASE_CA_CERT is not set and the connection is plain.
const pool = new pg.Pool(config);
// When the database closes an idle connection, the pool emits an error. With no listener, Node.js exits.
pool.on("error", (error) => console.error(`postgres: ${error.message}`));

// One row per signer: the versions the session pinned, then the record and its receipt.
export async function migrate() {
  await pool.query(`
    CREATE TABLE IF NOT EXISTS esc_acceptances (
      signer_id    text PRIMARY KEY,
      version_ids  jsonb NOT NULL,
      record_id    text,
      receipt      text,
      confirmed_at timestamptz
    )`);
}

export async function savePinned(signerId, versionIds) {
  await pool.query(
    `INSERT INTO esc_acceptances (signer_id, version_ids) VALUES ($1, $2)
     ON CONFLICT (signer_id) DO UPDATE SET version_ids = EXCLUDED.version_ids`,
    [signerId, JSON.stringify(versionIds)],
  );
}

export async function getPinned(signerId) {
  const { rows } = await pool.query("SELECT version_ids FROM esc_acceptances WHERE signer_id = $1", [signerId]);
  return rows[0]?.version_ids ?? [];
}

export async function saveReceipt(signerId, recordId, receipt) {
  await pool.query("UPDATE esc_acceptances SET record_id = $2, receipt = $3, confirmed_at = now() WHERE signer_id = $1", [signerId, recordId, receipt]);
}

// For the health check: true when the database answers.
export async function ping() {
  return pool.query("SELECT 1").then(() => true, () => false);
}

export async function close() {
  await pool.end();
}
```

The state is in Postgres and not in a variable of the process, for a reason DigitalOcean documents: a service can be scaled to several containers, each container has a filesystem of its own, and containers are created and destroyed as the app is scaled and redeployed. The request that confirms a record can reach a container that never saw the session.

A second file creates the table. On App Platform it is the command of a job that runs before each deployment:

```js file="migrate.js"
// migrate.js: the PRE_DEPLOY job of .do/app.yaml. App Platform runs it before each deployment of the app.
import { close, migrate } from "./store.js";

// CREATE TABLE IF NOT EXISTS: the job runs before every deployment, so it must be safe to run again.
await migrate();
console.log("table esc_acceptances ready");
await 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.

```js file="server.js"
// 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, ping, 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 the production app only. A preview app holds the test key and gets "false".
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}`);

  // The health check of .do/app.yaml. App Platform stops sending traffic to a container that fails it.
  if (req.method === "GET" && url.pathname === "/health") {
    const ok = await ping();
    return json(res, ok ? 200 : 503, { ok });
  }

  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 database, not in memory: the next request can reach another container.
    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" });
  });
});

// App Platform sets PORT from http_port in the app spec, 8080 by default, and reaches the service on 0.0.0.0.
const port = Number(process.env.PORT ?? 8080);
server.listen(port, "0.0.0.0", () => console.log(`http://localhost:${port}/signup`));

// App Platform sends SIGTERM to a container it replaces, and SIGKILL once grace_period_seconds have passed.
let stopping = false;
process.on("SIGTERM", () => {
  if (stopping) return;
  stopping = true;
  server.close(() => close().finally(() => 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, the image was started with a database address nothing listened on: `POST /api/ceremony` answered `500`, `/health` answered `503`, 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:

```bash
node --env-file=.env migrate.js
node --env-file=.env server.js
```

```text
table esc_acceptances ready
http://localhost:8080/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.

```html file="public/signup.html"
<!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:8080/signup](http://localhost:8080/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:

```text
Account created. Record rec_uoJcrRDM7uj4qAfhhgAo
```

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 Postgres, and grants access only when four things hold: the status is `recorded`, `timestamped` or `anchored`; `livemode` is what this app 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 the production app only, the one app that holds the live key. Everywhere else it is not `true`, 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 and the receipt:

```text
confirmed rec_uoJcrRDM7uj4qAfhhgAo (recorded)
```

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

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

```json
{"confirmed":false}
```

In the test, two containers of the image ran side by side. The first created a session, and a second container that had created none confirmed the record: the pinned versions came from Postgres. A container started with `ESIGNCOMPLY_LIVE=true` refused the same test record with `409`.

See [Server confirmation](https://esigncomply.com/docs/guides/server-confirmation.md) 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.

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

The report for this page's code, run in the image DigitalOcean's builder made, shortened:

```text
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:8080/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_SCBaGDciku8Yc9QEU2hk  session ses_u6aRrBtrHgS2otmDZNXN, 5 events
  768x1024   record rec_Pu9t6FvxjNuEoGKnKZAY  session ses_6nodoWbkfwY4jWHUPssY, 5 events
  1440x900   record rec_BZDpKY0G0EHZgrAJ093s  session ses_BVNChEuwHyGhSubvAnQV, 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](https://esigncomply.com/docs/conformance.md), and every flag of the command is on the [CLI page](https://esigncomply.com/docs/sdk/cli.md).

## 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](https://esigncomply.com/docs/guides/domains.md).
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 App Platform. The settings below are from DigitalOcean's own documentation, read on November 26, 2026: [Reference for App Specification](https://docs.digitalocean.com/products/app-platform/reference/app-spec/), [How to Use Environment Variables](https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/), [How to Set Up and Manage Health Checks](https://docs.digitalocean.com/products/app-platform/how-to/manage-health-checks/), [How to Scale Apps](https://docs.digitalocean.com/products/app-platform/how-to/scale-app/), [How to Store Data](https://docs.digitalocean.com/products/app-platform/how-to/store-data/), [How to Manage Databases](https://docs.digitalocean.com/products/app-platform/how-to/manage-databases/), [How to Connect to PostgreSQL Database Clusters](https://docs.digitalocean.com/products/databases/postgresql/how-to/connect/), [How to Manage Cron Jobs and Deployment Jobs](https://docs.digitalocean.com/products/app-platform/how-to/manage-jobs/), [How to Manage Services](https://docs.digitalocean.com/products/app-platform/how-to/manage-services/), [How to Configure App Termination Settings](https://docs.digitalocean.com/products/app-platform/how-to/configure-termination/), [Node.js Buildpack](https://docs.digitalocean.com/products/app-platform/reference/buildpacks/nodejs/), [How to Create Apps](https://docs.digitalocean.com/products/app-platform/how-to/create-apps/), [How to Deploy using GitHub Actions](https://docs.digitalocean.com/products/app-platform/how-to/deploy-from-github-actions/), the [README of DigitalOcean's app_action](https://github.com/digitalocean/app_action), [How to Manage Domains](https://docs.digitalocean.com/products/app-platform/how-to/manage-domains/), [App Platform Limits](https://docs.digitalocean.com/products/app-platform/details/limits/), [How to Build Components Locally](https://docs.digitalocean.com/products/app-platform/how-to/build-locally/) and [doctl apps spec validate](https://docs.digitalocean.com/reference/doctl/reference/apps/spec/validate/). The workflow and the `doctl apps create` command in this step need an account and were not run for this page.

**The app spec.** One file describes the app: the web service, a job, the database and the variables. Save it as `.do/app.yaml`, the path `doctl apps dev build` and DigitalOcean's GitHub Action read by default, and put your own repository in the two `repo` fields:

```yaml file=".do/app.yaml"
# .do/app.yaml: the app spec. One web service, one job that runs before each deployment, one managed PostgreSQL database.
name: esigncomply-quickstart
services:
  - name: web
    github:
      repo: your-account/your-repository
      branch: main
    environment_slug: node-js
    run_command: node server.js
    http_port: 8080
    instance_count: 2
    instance_size_slug: apps-s-1vcpu-1gb
    health_check:
      http_path: /health
jobs:
  - name: migrate
    kind: PRE_DEPLOY
    github:
      repo: your-account/your-repository
      branch: main
    environment_slug: node-js
    run_command: node migrate.js
databases:
  - name: db
    engine: PG
    production: true
    cluster_name: signup-db
# App-level variables reach every component. The first five values are filled in by the deploy workflow from
# the secrets of the repository, so this file never holds the key.
envs:
  - key: ESIGNCOMPLY_API_KEY
    scope: RUN_TIME
    type: SECRET
    value: ${ESIGNCOMPLY_API_KEY}
  - key: ESIGNCOMPLY_PROFILE_ID
    scope: RUN_TIME
    value: ${ESIGNCOMPLY_PROFILE_ID}
  - key: ESIGNCOMPLY_TERMS_ID
    scope: RUN_TIME
    value: ${ESIGNCOMPLY_TERMS_ID}
  - key: ESIGNCOMPLY_PRIVACY_ID
    scope: RUN_TIME
    value: ${ESIGNCOMPLY_PRIVACY_ID}
  - key: ESIGNCOMPLY_LIVE
    scope: RUN_TIME
    value: ${ESIGNCOMPLY_LIVE}
  - key: DATABASE_URL
    scope: RUN_TIME
    value: ${db.DATABASE_URL}
  - key: DATABASE_CA_CERT
    scope: RUN_TIME
    value: ${db.CA_CERT}
```

`doctl apps spec validate --schema-only .do/app.yaml` checks the file with no access token and no network. In the test it printed the spec back and exited with code 0. It refused a misspelt field (`unknown field "http_prot"`) and a number written as a word. It accepted `kind: BEFORE`, `type: HIDDEN`, a component named `Web_Service` and a reference to a database that is not in the file, so it is a check of field names and types and nothing more. Without `--schema-only` the command sends the spec to DigitalOcean and needs an access token: that was not run.

**The key.** `type: SECRET` makes `ESIGNCOMPLY_API_KEY` an encrypted variable. DigitalOcean's reference says the value is encrypted on first submission, and that later submissions should carry the encrypted value. The file on this page never holds the key: it holds the reference `${ESIGNCOMPLY_API_KEY}`, and DigitalOcean's GitHub Action replaces it from the environment of the workflow when it deploys. Store the live key, the live IDs and the DigitalOcean token as secrets of the repository:

```yaml
# .github/workflows/deploy.yml
name: Deploy to App Platform

on:
  push:
    branches: [main]

permissions:
  contents: read

jobs:
  deploy-app:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Deploy the app
        uses: digitalocean/app_action/deploy@v2
        env:
          ESIGNCOMPLY_API_KEY: ${{ secrets.ESIGNCOMPLY_LIVE_API_KEY }}
          ESIGNCOMPLY_PROFILE_ID: ${{ secrets.ESIGNCOMPLY_LIVE_PROFILE_ID }}
          ESIGNCOMPLY_TERMS_ID: ${{ secrets.ESIGNCOMPLY_LIVE_TERMS_ID }}
          ESIGNCOMPLY_PRIVACY_ID: ${{ secrets.ESIGNCOMPLY_LIVE_PRIVACY_ID }}
          ESIGNCOMPLY_LIVE: "true"
        with:
          token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
```

This is the workflow of DigitalOcean's documentation with five variables added. The action creates the app from `.do/app.yaml` on the first run and applies changes to the file on later runs. Without GitHub Actions, create the app with `doctl apps create --spec .do/app.yaml`, then type the five values under Settings in the control panel, the key with **Encrypt** selected. DigitalOcean's documentation notes that an encrypted variable is decrypted in the running container, so team members who can open the app's console can read it.

**The port, the run command and the stop signal.** `http_port` is the port the service listens on, and App Platform adds `PORT` with the same number unless you set one. DigitalOcean's documentation says the service must bind to `0.0.0.0`, not to `localhost`, and `server.js` does. `run_command` replaces the default of a Node.js component, which is `npm start`. In the image built for this page, the default process was `npm start`, with Node.js as its child. Stopped with `SIGTERM`, that container exited with code 1 and `npm error signal SIGTERM`. Started with `node server.js`, Node.js was process 1, closed the server and the database pool, and exited with code 0 in a fraction of a second, also when the signal arrived twice. App Platform sends `SIGTERM` to a container it replaces and `SIGKILL` after `grace_period_seconds`, 120 by default.

**Containers and the health check.** `instance_count: 2` runs two containers, and the app spec reference allows up to 250. `health_check.http_path` turns the check into an HTTP request to `/health`. With no path, App Platform only checks that the port accepts a TCP connection. `/health` answers `503` when the database does not, and DigitalOcean describes the health check as the probe that decides whether a container receives traffic.

**The database and TLS.** Create the cluster first, on the Databases page of the control panel, and put its name in `cluster_name`: the app spec reference says a database with `production: true` needs it. `${db.DATABASE_URL}` and `${db.CA_CERT}` are bindable variables that App Platform fills in from the database component named `db`. DigitalOcean's documentation says its connection details set `sslmode` to `require` by default, which encrypts the connection and does not verify the server, and that the CA certificate is what verifies it.

`pg` 8 does not read `sslmode=require` that way. Against a local Postgres that accepts TLS connections only, with a certificate signed by a private authority, `pg` 8.23.1 refused a URL ending in `sslmode=require` with `unable to verify the first certificate`. It refused it again with `ssl: { ca }` passed beside the URL: the parameter in the URL replaced the option. With the parameter removed and `ssl: { ca }` kept, as `store.js` does, it connected over TLS 1.3 with the certificate verified. A CA certificate that had not signed the server's certificate was refused. What the two variables hold on App Platform is proven only by a deployment.

**The job.** `kind: PRE_DEPLOY` makes `migrate` a job that runs before each deployment of the app, so the table is there before the new code is. The job has the same source as the service and the same app-level variables. In the test, the job's image ran twice against the same database and exited with code 0 both times. Against the TLS-only database it exited with code 1 without the CA certificate and with code 0 with it.

**Previews and test mode.** App Platform's documentation describes one way to preview a pull request: a GitHub Actions workflow in which the same action runs with `deploy_pr_preview: "true"` and deploys an app of its own for each pull request, and a second workflow that deletes that app when the pull request closes. In that workflow, give the action the test key, the test IDs and `ESIGNCOMPLY_LIVE: "false"`. The action's documentation says it derives the app name from the pull request, takes domains and alerts out of the spec, and points the repository references at the branch of the pull request. It does not say that it changes `databases`. To keep a preview off the production cluster, point the action's `app_spec_location` input at a second spec in which the database has no `production` and no `cluster_name`. The app spec reference says a new dev database is then provisioned for the app.

Each preview app answers on a host of its own under `ondigitalocean.app`, and a test key refuses a host it does not know with [`domain_mismatch`](https://esigncomply.com/docs/api/errors.md#domain_mismatch). List the exact host under Domains in the dashboard, or with the API:

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

List exact hosts, up to 25, and take a host off the list when its pull request closes. An entry also covers its subdomains, so never list the shared suffix `ondigitalocean.app`.

**The production domain.** Go live on a domain you own. Add it on the Networking tab of the app or in `domains` of the spec, then register it with Esign Comply and verify it with one DNS record. You cannot add DNS records under `ondigitalocean.app`, and file verification is offered only for a fixed list of platform suffixes, which does not include `ondigitalocean.app`. A live key accepts browser calls from the registered domain only, so redirect the starter domain to yours: DigitalOcean's page on domains shows the ingress rule for it, which matches the placeholder `${STARTER_DOMAIN}`. See [Register a domain](https://esigncomply.com/docs/guides/domains.md).

**The image, on your machine.** `doctl apps dev build` builds a component in Docker, and DigitalOcean's documentation says it uses the same buildpack build process as App Platform:

```bash
doctl apps dev build web
doctl apps dev build migrate
docker run --rm --network host --env-file .env --entrypoint launcher migrate:dev node migrate.js
docker run --rm --network host --env-file .env -e PORT=8080 --entrypoint launcher web:dev node server.js
```

Four things were seen in the test, with doctl 2.10.0:

1. The build copies the folder it runs in into the image, files that Git ignores included. Built in the project folder, the image held `.env`, with the key, in `/workspace`. Built in a copy of the folder without `.env`, it did not. DigitalOcean's page describes pushing local builds to a container registry: build in a fresh clone, and never push an image built in your working folder.
2. The command stops without an access token (`access token is required`) and outside a Git repository (`could not find git worktree`). With a placeholder in place of the token and the API address set to a closed local port, it built both components from `.do/app.yaml`, so the build itself called no DigitalOcean API. It printed `ignoring SECRET variable ESIGNCOMPLY_API_KEY`.
3. The images do not carry `run_command`. Both `web:dev` and `migrate:dev` start `npm start` by default, so the `docker run` line that doctl prints for the job starts the server. The commands above pass the run commands of the spec to the launcher of the image.
4. A second build of a component failed at the export step with `singleton connection already in use` while the image of the first build existed, four times out of four, also with `--no-cache`. After `docker rmi web:dev` it built again.

With `engines.node` set to `24.x` the builder installed Node.js 24.15.0, and with the field missing, Node.js 22.22.2. The builder image listed version 0.342.5 of the Node.js buildpack, and DigitalOcean's documentation names another version for the platform, so the exact Node.js version of a deployed app is proven only by a deployment.

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` or `invalid_api_key` on a preview app.** The key did not reach the app. In a test, the image started with an empty key answered `502` with `missing_api_key`, and with the text `${ESIGNCOMPLY_API_KEY}` of the spec left as it is, `502` with `invalid_api_key`. Give the preview workflow the test key in its `env`. See [`missing_api_key`](https://esigncomply.com/docs/api/errors.md#missing_api_key) and [`invalid_api_key`](https://esigncomply.com/docs/api/errors.md#invalid_api_key).
- **`domain_mismatch` on an `ondigitalocean.app` host.** The host is not a test origin of your domain, or the app holds the live key on a host that is not your registered domain. Add the exact host under Domains in the dashboard, and use the test key there. Test keys work on `localhost` with no setup. See [`domain_mismatch`](https://esigncomply.com/docs/api/errors.md#domain_mismatch) and [Test mode](https://esigncomply.com/docs/guides/test-mode.md).
- **The job fails with `unable to verify the first certificate`.** The URL of the database asks for TLS and `pg` could not verify the certificate: `DATABASE_CA_CERT` is empty, or it holds a certificate that did not sign the server's. Check that the variable is `${db.CA_CERT}` and that the database component is named `db`. The opposite message, `The server does not support SSL connections`, means the variable is set on a machine whose Postgres has no TLS: take it out of `.env`.
- **`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 in the same image showed why: two got `429` with `Retry-After: 1` and passed on the next attempt. See [`rate_limit_exceeded`](https://esigncomply.com/docs/api/errors.md#rate_limit_exceeded) and [Retries and timeouts](https://esigncomply.com/docs/sdk/node.md#retries-and-timeouts).

## Questions about the App Platform quickstart

### Why does store.js remove sslmode from the URL?

Because `pg` 8 lets `sslmode` in the URL replace the `ssl` option. In the test, a URL ending in `sslmode=require` was refused by a TLS-only Postgres with a privately signed certificate, with and without `ssl: { ca }`. With the parameter removed and the CA certificate passed, the connection was verified.

### Why is the run command node server.js and not npm start?

So that Node.js is the process that receives the signal. In the image built for this page, the default process was `npm start`, and a stopped container exited with code 1 and an npm error. With `node server.js` as process 1 it closed the server and the pool and exited with code 0.

### Does the local build need a DigitalOcean account?

Not in the test. `doctl apps dev build` stops when it has no access token, and a placeholder was enough: with the API address set to a closed local port, doctl 2.10.0 built both components from the spec. DigitalOcean's page lists an authenticated doctl as a prerequisite, and the commands that create or change an app need an account.

### What does doctl apps spec validate check without an account?

Field names and types. With `--schema-only`, doctl 2.10.0 refused a misspelt field and a number written as a word, and accepted a wrong `kind`, a wrong `type`, a component name with capitals and a reference to a database that is not in the file. The full check sends the spec to DigitalOcean and was not run.

### Was this quickstart deployed to App Platform?

Not yet. The code ran in the images DigitalOcean's builder made, as two web containers and the job, against Postgres containers with and without TLS. The encrypted variable, the bindable database variables, the job before a deployment, health checks, the GitHub Action, previews and the `ondigitalocean.app` host are proven only by a deployment.

## Next steps

- [E-signatures and clickwrap on DigitalOcean App Platform](https://esigncomply.com/digitalocean-app-platform): how the pieces fit on this platform, with the things to watch for.
- [Register a domain](https://esigncomply.com/docs/guides/domains.md): DNS and file verification, statuses, and test origins.
- [Server confirmation](https://esigncomply.com/docs/guides/server-confirmation.md): the checks in step 6 and the `record.completed` webhook.
- [Add e-signatures and clickwrap with Node.js](https://esigncomply.com/docs/quickstart/nodejs.md): the same server without a database.
- [All quickstarts](https://esigncomply.com/docs/quickstart.md#quickstarts-by-stack-and-platform).
