Skip to content
Platform · Fly.io

Add e-signatures and clickwrap to a Fly.io app

To add e-signatures and clickwrap to a Fly.io app, run the esigncomply package in a Node.js image and store the secret key with fly secrets set. The app creates the session and confirms the record, and Managed Postgres keeps the pinned versions and the receipt for both Machines. Esign Comply seals each acceptance as an independent record.

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

$npm install esigncomply pg
Fly.io quickstart

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

Last updated

Run locally for Fly.io before publishing
server.js (excerpt)
// 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 Postgres, not in memory: the confirmation can reach the other Machine.
  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 });
Integrate with Fly.io

How do you integrate Esign Comply with Fly.io?

On Fly.io the server half is one Node.js image, built from the Dockerfile that Fly.io's generator writes. fly.toml names the port, the health check and the release command that creates the table. An app with a service runs on two Machines, and Fly Proxy stops idle ones, so the pinned versions go to Managed Postgres.

Fly Machines are fast-launching VMs, the basic compute unit of the Fly.io platform.

Source: Fly.io documentation, High availability: run multiple Machines, read on .
Where each part lives on Fly.io
  • Serverserver.js
  • fly.tomlfly.toml
  • Confirmserver.js
  • Stop signalserver.js

Run on 2026-11-26 in the image built from the Dockerfile that Fly.io's generator wrote for this code (@flydotio/dockerfile 0.7.15 with its cmd option, Node.js 24.22.1, Docker 25.0.18 with the classic builder), on PostgreSQL 17, with esigncomply 1.0.4, pg 8.23.1, the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode. The release command was run the way Fly.io runs it, in place of the image's command, and the same code was also started with Node.js 24.22.1 on the machine. fly.toml was written from Fly.io's configuration reference and was not validated, because fly config validate (flyctl 0.5.17) needs a login. The Fly.io settings are from Fly.io's documentation as of 2026-11-25. Nothing has been deployed to Fly.io yet.

Three steps

How does Esign Comply fit with Fly.io?

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

  1. 01
    An app secret holds the keySet ESIGNCOMPLY_API_KEY with fly secrets set. Fly.io stores secrets in an encrypted vault and injects them into every Machine of the app as environment variables. The SDK reads the key from process.env, and neither fly.toml nor the image contains it. Source: Fly.io documentation, Secrets and Fly Apps, read on .
  2. 02
    The app creates the sessionPOST /api/ceremony runs in your Node.js server on a Machine. It calls esc.sessions.create and returns the client token. The same server serves the signup page, and the browser SDK records the ceremony from the signer's device.
  3. 03
    Managed Postgres keeps the receiptfly mpg attach sets DATABASE_URL as a secret of the app, with the connection string of the cluster. The session route stores the pinned versions in a table there. The confirm route reads the record with the secret key, compares it with the row, and writes the record ID and the receipt into it. Source: Fly.io documentation, fly mpg attach, read on .
Fly.io setup

Where do the key, the preview hosts and the webhook go on Fly.io?

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

Secrets

fly secrets set updates each Machine of a deployed app, which restarts it. With --stage, the value waits for the next deploy. Set ESIGNCOMPLY_LIVE=true on the production app only, beside the live key: the server expects live records only there.

Source: Fly.io documentation, Secrets and Fly Apps, read on .

The app file and the release command

internal_port in fly.toml has to be the port the server listens on, on 0.0.0.0. Fly Proxy sends requests only to Machines that pass the service check, which the quickstart points at /health. The release command runs migrate.js in a temporary Machine before the others are updated.

Source: Fly.io documentation, App configuration (fly.toml), read on .

Review apps and test mode

A review app answers on pr-<PR number>-<repository owner>-<repository name>.fly.dev by default. A test key refuses a host it does not know: list the exact host under Domains in the Esign Comply dashboard as a test origin. Never list the shared suffix fly.dev.

Source: Fly.io documentation, Git Branch Preview Environments, read on .

The registered domain and the webhook

Register your custom domain and verify it with one DNS record. fly certs add attaches it to the app. A production app on its fly.dev host verifies with a file at /.well-known/esigncomply.txt. For the record.completed webhook, add a route to the server and register its production URL under Webhooks in the Esign Comply dashboard.

Source: Fly.io documentation, Custom domains, read on .

Read on : Fly.io documentation, Create an app with Fly Launch, Fly.io documentation, App configuration (fly.toml), Fly.io documentation, Secrets and Fly Apps, Fly.io documentation, App Availability and Resiliency, Fly.io documentation, Autostop/autostart Machines, Fly.io documentation, Health Checks, Fly.io documentation, The Machine Runtime Environment, Fly.io documentation, fly mpg attach, Fly.io documentation, Git Branch Preview Environments, Fly.io documentation, Custom domains.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a Fly.io app?

Paste this into Cursor, Claude Code or the AI coding tool that is open on your project. It names the packages that exist, where the secret key goes on Fly.io, what to build and what never to do, and it ends with the rules block for your project.

The rules block lives at /rules.md. Added to your project's instruction file, it makes every later session build signing and acceptance flows the same way. The prompt generator writes the long version, with your own document and profile IDs.

Pages for each AI tool
Prompt: Esign Comply clickwrap on Fly.io
Add Esign Comply clickwrap to my app on Fly.io: 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/fly-io.md (the steps and the tested code for Fly.io)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Fly.io 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 app secret ESIGNCOMPLY_API_KEY, set with "fly secrets set". Never put it in fly.toml, in the Dockerfile or in the image. Never print it.
- Listen on 0.0.0.0 on the internal_port of fly.toml. PORT is not among the variables Fly.io sets in a Machine.
- The image's command is ["node", "server.js"], not npm, so the process receives the stop signal itself. That signal is SIGINT unless fly.toml sets kill_signal: handle SIGINT and SIGTERM.
- An app with a service runs on two Machines, and Fly Proxy stops idle ones. Keep the pinned version IDs in Postgres (DATABASE_URL, set by "fly mpg attach"), never in a variable of the process. Create the table in the release_command of fly.toml.
- Expect live records only where the app secret ESIGNCOMPLY_LIVE is "true". A review app is another app with secrets of its own: give it the test key.
- 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: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
3 things to watch

What goes wrong when you add e-signatures on Fly.io?

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

  • 01

    The generated Dockerfile starts the app through npm

    Fly.io's generator wrote CMD [ "npm", "run", "start" ] for the quickstart, and Fly.io stops a Machine by sending SIGINT to the main process. In the test, that image was still running 15 seconds after SIGINT. Regenerated with --cmd '["node", "server.js"]', it closed the database pool and exited with code 0 in under a second.

    Source: Fly.io documentation, App configuration (fly.toml), read on .
  • 02

    Two Machines, and an idle one is stopped

    Fly.io creates two Machines for an app with a service, and with auto_stop_machines Fly Proxy stops them when the app is idle. Memory is not shared between Machines. In the test, two Node.js processes with the pinned versions in a Map ended in 409. With Postgres, a second container confirmed the record.

    Source: Fly.io documentation, App Availability and Resiliency, read on .
  • 03

    Fly.io does not hand the server a PORT

    PORT is not among the variables Fly.io's documentation lists for a Machine. The quickstart's server falls back to 3000, and internal_port in fly.toml has to be the same number. The server listens on 0.0.0.0, which is where Fly Proxy reaches it.

    Source: Fly.io documentation, The Machine Runtime Environment, read on .
Verifiable

What does Esign Comply record for a signature on Fly.io?

The same record on every stack and platform. Your Fly.io code creates the session and confirms the record, and the browser SDK reports what happened on the page. Esign Comply seals the result where your code cannot change it. The record itself is described on Evidence and verification.

  • Observed and asserted fields

    Every field is tagged. Observed is what the browser SDK and the API saw: the box unchecked at load, the tick from a trusted user event, the notice text, the terms version by hash, the server time. Asserted is what your app said, such as the user's email.

  • A signed receipt

    complete() returns a receipt signed with ES256, using keys you do not hold. Your server stores it next to the user, and GET /v1/records/{id}/receipt returns it again.

  • An external timestamp

    An outside authority timestamps the hash of every live record (RFC 3161), so the time on the record does not rest on your clock or on ours.

  • An offline verifier

    Each record has an evidence report (PDF) and an evidence package (ZIP). Anyone you send the package to checks the acceptance with the open-source esigncomply-verify, without an account.

Recordrec_Z4m8
simple · L1
RecordedWritten durably, receipt signed with ES256
TimestampedExternal RFC 3161 token over the record hash
AnchoredPublic anchor pending
Checkbox changed by a trusted user eventobserved
Terms of Service, version dv_3kT9observed
Server time 2026-11-21T15:03:20.291Zobserved
Signer email dana@example.orgasserted
record_hash sha256:5be7…example record

Questions about e-signatures on Fly.io

How does test mode work on Fly.io preview URLs?

A review app is a separate Fly.io app with a host of its own, by default pr-<PR number>-<repository owner>-<repository name>.fly.dev. A test key refuses that host until you list it under Domains as a test origin. On localhost a test key works with no setup.

Where should the receipt be stored on Fly.io?

In Managed Postgres, beside the signer ID and the record ID. The confirm route writes both once the record is confirmed. fly mpg attach gives the app DATABASE_URL, and the quickstart uses one row for the pinned versions and the receipt.

Why should Node.js be the main process of the Fly.io image?

Because Fly.io sends the stop signal to the main process of the image, SIGINT by default. In the test, the image that started the app through npm was still running 15 seconds after SIGINT, and after SIGTERM it exited with code 1. With node server.js as the command it exited with code 0 in under a second.

Does a Fly.io review app inherit the production key?

No. Fly.io's review apps are separate apps, created by a GitHub Action for each pull request, and a new app has no secrets. The workflow passes them in from GitHub secrets: give it the test key and the test IDs, and leave ESIGNCOMPLY_LIVE out.

Was fly.toml validated by Fly.io?

No. fly config validate needs a login, so the file was written from Fly.io's configuration reference as of November 25, 2026 and not validated. The code passed the conformance check in the image built from the Dockerfile Fly.io's generator wrote. Nothing has been deployed to Fly.io yet: fly launch, secrets, Managed Postgres and the fly.dev host are proven only by a deployment.

Run the signing flow on your Fly.io Machines. Leave the record to us.

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

Fly.io is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Fly.io is from Fly.io's documentation or from a test run, as marked, on . /fly-io.md is this page as Markdown.

Working with an AI tool? This page is also available as Markdown: /fly-io.md