Skip to content
Platform · Heroku

Add e-signatures and clickwrap to a Heroku app

To add e-signatures and clickwrap to a Heroku app, run the esigncomply package in a Node.js web dyno and keep the secret key in a config var. The dyno creates the session and confirms the record, and Heroku Postgres keeps the pinned versions and the receipt, because dynos share nothing. 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
Heroku quickstart

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

Last updated

Run locally for Heroku 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 router can send the confirmation to another dyno.
  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 Heroku

How do you integrate Esign Comply with Heroku?

On Heroku the server half is one web dyno started from a Procfile. Heroku sets PORT, sends SIGTERM before it stops a dyno, and runs node migrate.js in the release phase before each release is deployed. Dynos share no files and the routers pick one at random, so the pinned versions go to Heroku Postgres.

Heroku lets you deploy, run and manage apps written in Ruby, Node.js, Java, Python, Clojure, Scala, Go, PHP and .NET.

Source: Heroku Dev Center, How Heroku Works, read on .
Where each part lives on Heroku
  • Web dynoserver.js
  • Release phasemigrate.js
  • Confirmserver.js
  • Postgres storestore.js

Run on 2026-11-26 in the image that Heroku's Cloud Native Buildpacks built from this code (pack 0.40.11 with the builder heroku/builder:24, heroku/nodejs 5.9.2 and heroku/procfile 4.2.4, Node.js 26.13.1 on Ubuntu 24.04), started the way a web dyno is (PORT, DYNO, the web and release process types of the Procfile, SIGTERM) with PostgreSQL 17.12 in a container in place of Heroku Postgres, 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 same code also ran under heroku local (Heroku CLI 11.14.0) and under Node.js 24.22.1 on the machine. The Heroku settings are from Heroku's documentation as of that date, the heroku commands in step 8 were not run, and app.json was not read by Heroku. Nothing has been deployed to Heroku yet.

Three steps

How does Esign Comply fit with Heroku?

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

  1. 01
    A config var holds the keySet ESIGNCOMPLY_API_KEY with heroku config:set or in the app's Settings tab. Heroku exposes config vars to the dyno as environment variables, and the SDK reads the key from process.env. Each app has its own config vars, so the live key exists in the production app only. Source: Heroku Dev Center, Configuration and Config Vars, read on .
  2. 02
    The web dyno creates the sessionweb: node server.js in the Procfile is the one process type that receives HTTP traffic from Heroku's routers. POST /api/ceremony calls esc.sessions.create there and returns the client token. The same dyno serves the signup page, and the browser SDK records the ceremony from the signer's device. Source: Heroku Dev Center, The Procfile, read on .
  3. 03
    Heroku Postgres keeps the receiptThe session route stores the pinned versions in a table in Heroku Postgres, which the dyno reaches through DATABASE_URL. 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. The release phase command creates the table. Source: Heroku Dev Center, Provisioning Heroku Postgres, read on .
Heroku setup

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

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

Config vars

Each Heroku app has its own values: the production app holds the live key, the live IDs and ESIGNCOMPLY_LIVE=true, every other app the test key and the test IDs. Heroku's documentation says setting or removing a config var restarts the app and creates a new release. On your machine the values go in .env, which heroku local reads and Git never sees.

Source: Heroku Dev Center, Configuration and Config Vars, read on .

The Procfile and the release phase

release: node migrate.js runs in a one-off dyno whenever a new release is created, and Heroku does not deploy a release whose command fails. Start the web process with node server.js: Heroku sends SIGTERM to every process of a dyno and SIGKILL 30 seconds later. In the test the process closed its pool and exited with code 0.

Source: Heroku Dev Center, Release Phase, read on .

Review apps and test mode

Review apps need an app.json in the repository, and Heroku injects the pipeline's Review app config vars into each one: put the test key there. Each review app answers on a host of its own under herokuapp.com. List that exact host under Domains in the Esign Comply dashboard as a test origin, never the shared suffix.

Source: Heroku Dev Center, Review Apps, read on .

The registered domain and the webhook

Add your custom domain with heroku domains:add, then register it and verify it with one DNS record. Heroku's documentation says the herokuapp.com domain always remains active, so redirect it to your domain. A production app on its herokuapp.com host verifies with a file at /.well-known/esigncomply.txt. For the record.completed webhook, add a route to the app and register its production URL under Webhooks in the Esign Comply dashboard.

Source: Heroku Dev Center, Custom Domain Names for Apps, read on .

Read on : Heroku Dev Center, Configuration and Config Vars, Heroku Dev Center, The Procfile, Heroku Dev Center, Release Phase, Heroku Dev Center, Dynos, Heroku Dev Center, Dyno Restarts, Heroku Dev Center, Dyno Startup Behavior, Heroku Dev Center, Dyno Shutdown Behavior, Heroku Dev Center, HTTP Routing, Heroku Dev Center, Connecting to Heroku Postgres, Heroku Dev Center, Provisioning Heroku Postgres, Heroku Dev Center, Review Apps, Heroku Dev Center, app.json Schema, Heroku Dev Center, Custom Domain Names for Apps, Heroku Dev Center, Managing Buildpacks, Heroku Dev Center, Node.js Support Reference, Heroku Dev Center, Running Apps Locally.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a Heroku 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 Heroku, 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 Heroku
Add Esign Comply clickwrap to my app on Heroku: 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/heroku.md (the steps and the tested code for Heroku)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Heroku 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 config var ESIGNCOMPLY_API_KEY, set on each Heroku app. Never commit it, never put it in app.json, never print it. For review apps it goes under Review app config vars in the pipeline's settings.
- The Procfile names the processes: "web: node server.js" and "release: node migrate.js". Listen on the port in PORT and name no host in listen(): Fir expects [::], Cedar the port.
- Dynos share no memory and no files, and the router picks a web dyno at random. Keep the pinned version IDs in Heroku Postgres (DATABASE_URL), never in a variable of the process or in a file.
- Heroku Postgres requires TLS. Leave the ssl option out of the code and set the config var PGSSLMODE=no-verify on Heroku. Do not set it on a machine whose Postgres has no TLS.
- The release command runs before every new release, a config var change included: it must be safe to run again (CREATE TABLE IF NOT EXISTS).
- Handle SIGTERM: Heroku sends it to every process of a dyno and kills what is left 30 seconds later.
- Expect live records only where the config var ESIGNCOMPLY_LIVE is "true": the production app.
- 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 Heroku?

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

  • 01

    Heroku Postgres requires TLS, and pg does not turn it on

    Heroku's documentation says Heroku Postgres requires SSL connections, and shows rejectUnauthorized: false or the config var PGSSLMODE=no-verify for Node.js. In the test, pg 8.23.1 with neither was refused by a TLS-only Postgres with no pg_hba.conf entry ... no encryption, and the release command exited with code 1. With PGSSLMODE=no-verify it connected over TLS 1.3. The same variable failed against a local Postgres without TLS.

    Source: Heroku Dev Center, Connecting to Heroku Postgres, read on .
  • 02

    A config var change runs the release command again

    Heroku's documentation says setting a config var creates a new release, and that the release command runs whenever a new release is created. So migrate.js runs more often than you deploy. In the test the release process of the image ran twice against the same database and exited with code 0 both times, because the table is created with IF NOT EXISTS.

    Source: Heroku Dev Center, Release Phase, read on .
  • 03

    Naming 0.0.0.0 in listen() leaves IPv6 unanswered

    Heroku's documentation says a web dyno of a Fir app must bind on IPv6, [::]:$PORT, within 60 seconds of startup, and a Cedar app to $PORT. In the test a server that named 0.0.0.0 in listen() answered on IPv4 only. With no host named, Node.js answered on 127.0.0.1 and on [::1]. The quickstart passes the port and nothing else.

    Source: Heroku Dev Center, Dyno Startup Behavior, read on .
Verifiable

What does Esign Comply record for a signature on Heroku?

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

How does test mode work on Heroku review apps?

Each review app gets a host of its own under herokuapp.com, random by default, which a test key refuses until you list that exact host under Domains as a test origin. Put the test key under Review app config vars in the pipeline's settings: Heroku injects those into every review app. On localhost a test key works with no setup.

Where should the receipt be stored on Heroku?

In Heroku Postgres, beside the signer ID and the record ID. The confirm route writes both once the record is confirmed. Heroku's documentation says each dyno has its own ephemeral filesystem, discarded when the dyno restarts, so a file is no place for it.

Why does the quickstart set PGSSLMODE and pass no ssl option?

So the same code runs on Heroku and on your machine. Heroku Postgres requires TLS, and Heroku documents both the ssl object and the config var PGSSLMODE=no-verify. In the test both connected over TLS to a TLS-only Postgres, and both failed against a local Postgres without TLS. A config var can differ from app to app.

Does a config var change run the release phase?

Yes. Heroku's documentation says a change to a config var creates a new release, and the release command runs for it, unless the change comes from an add-on's config vars. The quickstart's command creates the table only if it does not exist: run twice in the test, it exited with code 0 both times.

What was run with Heroku's own tools, and what was not?

Heroku's builder heroku/builder:24 built the image with pack, its web and release processes ran in Docker against a Postgres container, and heroku local from CLI 11.14.0 recorded a signature. Nothing was deployed: config vars, the release phase, the routers, review apps, Heroku Postgres and custom domains on Heroku are proven only by a deployment.

Run the signing flow in your Heroku app. Leave the record to us.

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

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

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