Add e-signatures and clickwrap to Google Cloud Run
To add e-signatures and clickwrap to a Google Cloud Run service, run the esigncomply package in Node.js and pass the secret key from Secret Manager as an environment variable. The service creates the session and confirms the record, and Cloud SQL keeps the pinned versions and the receipt for every instance. 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 pgFree plan: 10 live signatures a month and a full test mode. No card required.
Last updated
// 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 Cloud SQL, not in memory: the confirmation can reach another instance. 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 });
// Cloud Run mounts the Cloud SQL instance as a Unix socket in /cloudsql/<connection name>. // pg takes that folder as the host and adds the name of the socket file itself. // On your machine there is no socket, and DB_HOST is the address of a local Postgres. const pool = new pg.Pool({ host: process.env.INSTANCE_UNIX_SOCKET ?? process.env.DB_HOST, // /cloudsql/project:region:instance user: process.env.DB_USER, password: process.env.DB_PASS, database: process.env.DB_NAME, }); // 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}`));
// 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 && 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 });
// Cloud Run sets PORT and sends requests to 0.0.0.0 on that port: 8080 unless you change it. const port = Number(process.env.PORT ?? 8080); server.listen(port, "0.0.0.0", () => console.log(`${process.env.K_REVISION ?? "local"} listening on ${port}`)); // Cloud Run sends SIGTERM, then stops the instance 10 seconds later. Finish the open requests, close the pool, exit. process.on("SIGTERM", () => { server.close(() => close().finally(() => process.exit(0))); server.closeIdleConnections(); });
How do you integrate Esign Comply with Google Cloud Run?
On Cloud Run the server half is one Node.js service. gcloud run deploy --source builds it with Google Cloud's buildpacks, and a Procfile makes Node.js the main process. The service listens on the port in PORT. Requests from one visitor can reach different instances, so the pinned versions go to Cloud SQL, over a Unix socket.
Cloud Run is a fully managed application platform for running your code, function, or container on top of Google's highly scalable infrastructure.
Source: Cloud Run documentation, What is Cloud Run, read on .- Serviceserver.js
- Cloud SQL socketstore.js
- Confirmserver.js
- Port and SIGTERMserver.js
Run on 2026-11-26 in the image that Google Cloud's buildpacks built from this code (pack 0.40.11 with the builder gcr.io/buildpacks/builder, Node.js 24.22.1 on Ubuntu 24.04), started under Cloud Run's container contract (PORT, K_SERVICE, K_REVISION, SIGTERM) with PostgreSQL 17 on a Unix socket mounted in /cloudsql, 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 was also started with Node.js 24.22.1 on the machine against PostgreSQL 17 over TCP. The Cloud Run settings are from Google Cloud's documentation as of 2026-11-25, and the gcloud commands on this page were not run. Nothing has been deployed to Cloud Run yet.
How does Esign Comply fit with Google Cloud Run?
Each step uses a feature Google Cloud Run already has. The secret key stays on the server side of Google Cloud Run in all three.
- 01Secret Manager holds the keyStore the key as a secret in Secret Manager and pass it to the service as the environment variable
ESIGNCOMPLY_API_KEY. Cloud Run resolves it when an instance starts, and Google recommends pinning the secret to a version. The SDK reads the key fromprocess.env. Source: Cloud Run documentation, Configure secrets for services, read on . - 02The service creates the session
POST /apiruns in your Node.js service. It calls/ceremony esc.sessions.createand returns the client token. The same service serves the signup page, and the browser SDK records the ceremony from the signer's device. - 03Cloud SQL keeps the receiptThe session route stores the pinned versions in a table in Cloud SQL for PostgreSQL, reached through the Unix socket Cloud Run mounts in
/cloudsql. 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: Cloud SQL documentation, Connect from Cloud Run, read on .
Where do the key, the preview hosts and the webhook go on Google Cloud Run?
Four settings carry an Esign Comply integration on Google Cloud Run. What is said here about Google Cloud Run was read from its own documentation, and the quickstart has each command.
Variables and secrets
--update-secrets passes the key and the database password, and --set-env-vars sets the rest. --set-env-vars replaces the whole list of variables, so name every one each time. A new revision automatically gets the variables and secrets of the service unless the deploy command changes them.
Source: Cloud Run documentation, Environment variables, read on .
The port, the probe and the stop signal
The container has to listen on 0.0.0.0, on the port in PORT. Without a probe of your own, Cloud Run only checks that the port accepts a TCP connection: the quickstart sets a startup probe on /health. Before it shuts an instance down, Cloud Run sends SIGTERM, then SIGKILL 10 seconds later.
Source: Cloud Run documentation, Container runtime contract, read on .
Previews and test mode
A revision deployed with --no-traffic --tag answers on https:/. 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 run.app.
Source: Cloud Run documentation, Rollouts and traffic migration, read on .
The registered domain and the webhook
Go live on a domain you own, verified with one DNS record: the file method is offered only for a fixed list of platform suffixes, and run.app is not one of them. For the record.completed webhook, add a route to the service and register its production URL under Webhooks in the Esign Comply dashboard.
Source: Cloud Run documentation, Mapping custom domains, read on .
Read on : Cloud Run documentation, Container runtime contract, Cloud Run documentation, Deploy services from source code, Google Cloud documentation, Building a Node.js application, Cloud Run documentation, Configure secrets for services, Cloud Run documentation, Environment variables, Cloud SQL documentation, Connect from Cloud Run, Cloud Run documentation, Configure container health checks, Cloud Run documentation, Known issues, Cloud Run documentation, Session affinity, Cloud Run documentation, Rollouts and traffic migration, Cloud Run documentation, Mapping custom domains.
What prompt adds Esign Comply clickwrap to a Google Cloud Run 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 Google Cloud Run, 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 toolAdd Esign Comply clickwrap to my app on Google Cloud Run: 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/google-cloud-run.md (the steps and the tested code for Cloud Run)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)
Cloud Run 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 a secret in Secret Manager, passed to the service as the environment variable ESIGNCOMPLY_API_KEY, pinned to a version. Never put it in the image or in a plain environment variable. Never print it.
- Listen on 0.0.0.0 on the port in PORT, which Cloud Run sets (8080 unless changed). Handle SIGTERM: Cloud Run stops the instance 10 seconds later.
- Start the server from a Procfile ("web: node server.js"), not through npm.
- Requests from one visitor can reach different instances. Keep the pinned version IDs in Cloud SQL, never in a variable of the process. Cloud Run mounts the Cloud SQL socket in /cloudsql/INSTANCE_CONNECTION_NAME: give pg that folder as the host.
- Do not use URL paths that end in z, such as /healthz: Cloud Run reserves some of them.
- Expect live records only where ESIGNCOMPLY_LIVE is "true". A new revision inherits the variables and secrets of the service.
- 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.mdWhat goes wrong when you add e-signatures on Google Cloud Run?
These are specific to Google Cloud Run. Each one was seen while the quickstart's code was run, or is in Google Cloud Run's own documentation.
- 01
/healthz is a reserved kind of path on Cloud Run
Google's known issues page says you cannot use some URL paths that end in
Source: Cloud Run documentation, Known issues, read on .z, and recommends avoiding all of them./healthzis the usual name for a health route elsewhere. The quickstart's route is/health, in the server and in the startup probe. - 02
INSTANCE_UNIX_SOCKET is the folder, not the socket file
Cloud Run mounts the Cloud SQL socket in
Source: Cloud SQL documentation, Connect from Cloud Run, read on ./cloudsql, and/INSTANCE_CONNECTION_NAME pgadds the file name itself. In the test, the path of the socket file ended inconnect ENOTDIR, with.s.PGSQL.5432twice in the path. An image started without the mount stopped withconnect ENOENT. - 03
A tagged revision starts with the live key
Google's documentation says a new revision automatically gets the configuration of the service unless you change it. A preview deployed as a tagged revision of the production service therefore holds the live key and
Source: Cloud Run documentation, Configure secrets for services, read on .ESIGNCOMPLY_LIVE=true. Run previews as a service of their own, with the test key and the test IDs.
Where are the Google Cloud Run quickstart and the API reference?
Start with the quickstart: it carries every file this page excerpts, in the order you write them.
- QuickstartGoogle Cloud Run quickstartStep by step, from install to your first sealed test record, with every file and the output of each step.Open
- ReferenceAPI referenceEvery endpoint, field and error code. Sessions, records and documents are the three this page uses.Open
- GuideServer confirmationThe one place access is granted: what to compare, and the webhook that backs the check up.Open
What does Esign Comply record for a signature on Google Cloud Run?
The same record on every stack and platform. Your Google Cloud Run 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, andGET /v1returns it again./records /{id} /receipt 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.
Questions about e-signatures on Google Cloud Run
How does test mode work on Google Cloud Run preview URLs?
A tagged revision and a preview service each answer on a run.app host of their own, which a test key refuses until you list that exact host under Domains as a test origin. A tagged URL is not a subdomain of the service's host, so list it as well. On localhost a test key works with no setup.
Where should the receipt be stored on Google Cloud Run?
In Cloud SQL, beside the signer ID and the record ID. The confirm route writes both once the record is confirmed. The quickstart uses one row in a PostgreSQL table for the pinned versions and the receipt, reached through the socket in /cloudsql.
Does the service need a Dockerfile?
No. gcloud run deploy --source builds a folder without a Dockerfile with Google Cloud's buildpacks. In the test build, pack with Google's builder installed Node.js 24.22.1 and took node server.js from the Procfile, and the conformance check passed in that image.
Can the production service run on its run.app URL?
Not with a live key. A live key works only on your registered domain, and a run.app host cannot be verified: you cannot add DNS records under it, and it is not on the list of suffixes that verify with a file. Put a domain you own in front of the service.
Was this code deployed to Cloud Run?
Not yet. The code ran in the image Google Cloud's buildpacks built, under Cloud Run's container contract, with Postgres on a Unix socket in /cloudsql. The Cloud Run settings come from Google Cloud's documentation as of November 25, 2026. The gcloud commands, Secret Manager, Cloud SQL and revisions are proven only by a deployment.
Run the signing flow in your Cloud Run service. Leave the record to us.
Free plan: 10 live signatures a month and a full test mode. No card required.
Google Cloud Run is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Google Cloud Run is from Google Cloud Run's documentation or from a test run, as marked, on . /google-cloud-run.md is this page as Markdown.