# Add e-signatures and clickwrap to Google Cloud Run

> Add e-signatures and clickwrap to a Google Cloud Run service: the esigncomply package in Node.js, the key from Secret Manager, and Cloud SQL for the receipt.

Source: https://esigncomply.com/google-cloud-run

Platform · 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.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/google-cloud-run)

`npm install esigncomply pg`

[Google Cloud Run quickstart](https://esigncomply.com/docs/quickstart/google-cloud-run)

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

Last updated November 26, 2026

Run locally for Google Cloud Run before publishing

**Service**

server.js (excerpt)

```js
// 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 SQL socket**

store.js (excerpt)

```sql
// 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}`));
```

**Confirm**

server.js (excerpt)

```js
// 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 });
```

**Port and SIGTERM**

server.js (excerpt)

```js
// 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();
});
```

Integrate with Google Cloud Run

## 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](https://docs.cloud.google.com/run/docs/overview/what-is-cloud-run), read on November 25, 2026.

[Google Cloud Run quickstart](https://esigncomply.com/docs/quickstart/google-cloud-run) · [All platforms](https://esigncomply.com/platforms)

Where each part lives on Google Cloud Run

- **Service** · `server.js`
- **Cloud SQL socket** · `store.js`
- **Confirm** · `server.js`
- **Port and SIGTERM** · `server.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.

Three steps

## 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.

1. **Secret Manager holds the key**

   Store 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 from `process.env`. Source: [Cloud Run documentation, Configure secrets for services](https://docs.cloud.google.com/run/docs/configuring/services/secrets), read on November 25, 2026.

2. **The service creates the session**

   `POST /api/ceremony` runs in your Node.js service. It calls `esc.sessions.create` and returns the client token. The same service serves the signup page, and the browser SDK records the ceremony from the signer's device.

3. **Cloud SQL keeps the receipt**

   The 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](https://docs.cloud.google.com/sql/docs/postgres/connect-run), read on November 25, 2026.

Google Cloud Run setup

## 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](https://docs.cloud.google.com/run/docs/configuring/services/environment-variables), read on November 25, 2026.

### 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](https://docs.cloud.google.com/run/docs/container-contract), read on November 25, 2026.

### Previews and test mode

A revision deployed with `--no-traffic --tag` answers on `https://TAG---SERVICE_NAME-PROJECT_NUMBER.REGION.run.app`. 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](https://docs.cloud.google.com/run/docs/rollouts-rollbacks-traffic-migration), read on November 25, 2026.

### 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](https://docs.cloud.google.com/run/docs/mapping-custom-domains), read on November 25, 2026.

Read on November 25, 2026: [Cloud Run documentation, Container runtime contract](https://docs.cloud.google.com/run/docs/container-contract), [Cloud Run documentation, Deploy services from source code](https://docs.cloud.google.com/run/docs/deploying-source-code), [Google Cloud documentation, Building a Node.js application](https://docs.cloud.google.com/docs/buildpacks/nodejs), [Cloud Run documentation, Configure secrets for services](https://docs.cloud.google.com/run/docs/configuring/services/secrets), [Cloud Run documentation, Environment variables](https://docs.cloud.google.com/run/docs/configuring/services/environment-variables), [Cloud SQL documentation, Connect from Cloud Run](https://docs.cloud.google.com/sql/docs/postgres/connect-run), [Cloud Run documentation, Configure container health checks](https://docs.cloud.google.com/run/docs/configuring/healthchecks), [Cloud Run documentation, Known issues](https://docs.cloud.google.com/run/docs/known-issues), [Cloud Run documentation, Session affinity](https://docs.cloud.google.com/run/docs/configuring/session-affinity), [Cloud Run documentation, Rollouts and traffic migration](https://docs.cloud.google.com/run/docs/rollouts-rollbacks-traffic-migration), [Cloud Run documentation, Mapping custom domains](https://docs.cloud.google.com/run/docs/mapping-custom-domains).

Copy-paste prompt

## 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](https://esigncomply.com/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](https://esigncomply.com/product/prompt-generator) writes the long version, with your own document and profile IDs.

[Pages for each AI tool](https://esigncomply.com/build)

Prompt: Esign Comply clickwrap on Google Cloud Run

```
Add 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.md
```

3 things to watch

## What 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.

- **/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 `z`, and recommends avoiding all of them. `/healthz` is the usual name for a health route elsewhere. The quickstart's route is `/health`, in the server and in the startup probe.

  Source: [Cloud Run documentation, Known issues](https://docs.cloud.google.com/run/docs/known-issues), read on November 25, 2026.

- **INSTANCE_UNIX_SOCKET is the folder, not the socket file**

  Cloud Run mounts the Cloud SQL socket in `/cloudsql/INSTANCE_CONNECTION_NAME`, and `pg` adds the file name itself. In the test, the path of the socket file ended in `connect ENOTDIR`, with `.s.PGSQL.5432` twice in the path. An image started without the mount stopped with `connect ENOENT`.

  Source: [Cloud SQL documentation, Connect from Cloud Run](https://docs.cloud.google.com/sql/docs/postgres/connect-run), read on November 25, 2026.

- **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 `ESIGNCOMPLY_LIVE=true`. Run previews as a service of their own, with the test key and the test IDs.

  Source: [Cloud Run documentation, Configure secrets for services](https://docs.cloud.google.com/run/docs/configuring/services/secrets), read on November 25, 2026.

## 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.

- Quickstart

  **[Google Cloud Run quickstart](https://esigncomply.com/docs/quickstart/google-cloud-run)**

  Step by step, from install to your first sealed test record, with every file and the output of each step.

- Reference

  **[API reference](https://esigncomply.com/docs/api)**

  Every endpoint, field and error code. Sessions, records and documents are the three this page uses.

- Guide

  **[Server confirmation](https://esigncomply.com/docs/guides/server-confirmation)**

  The one place access is granted: what to compare, and the webhook that backs the check up.

Verifiable

## 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](https://esigncomply.com/product/evidence).

- **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.

[How sealing and verification work](https://esigncomply.com/product/evidence) · [Observed and asserted, in the docs](https://esigncomply.com/docs/concepts/observed-and-asserted) · [The offline verifier](https://esigncomply.com/docs/sdk/verify)

Record

`rec_Z4m8`

simple · L1

Recorded

Written durably, receipt signed with ES256

Timestamped

External RFC 3161 token over the record hash

Anchored

Public anchor pending

Checkbox changed by a trusted user event · observed

Terms of Service, version dv_3kT9 · observed

Server time 2026-11-21T15:03:20.291Z · observed

Signer email dana@example.org · asserted

record_hash sha256:5be7… · example record

## 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.

### Other platforms

- [AWS Lambda](https://esigncomply.com/aws-lambda)
- [Fly.io](https://esigncomply.com/fly-io)
- [Railway](https://esigncomply.com/railway)

### Stacks used with Google Cloud Run

- [Node.js](https://esigncomply.com/nodejs)
- [Express](https://esigncomply.com/express)
- [Next.js](https://esigncomply.com/nextjs)

[All platforms](https://esigncomply.com/platforms) · [All stacks](https://esigncomply.com/stacks) · [Clickwrap API](https://esigncomply.com/clickwrap) · [E-signature API](https://esigncomply.com/sign)

## Run the signing flow in your Cloud Run service. Leave the record to us.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/google-cloud-run)

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 November 25, 2026. `/google-cloud-run.md` is this page as Markdown.

---

Every page on esigncomply.com has a Markdown version at the same URL plus `.md` (the home page is `https://esigncomply.com/index.md`). https://esigncomply.com/llms.txt lists them.

---

Esign Comply is the e-signature API and clickwrap API for developers who build their own signing flow in their own UI: it supplies the ceremony rules as a generated prompt for AI coding tools, records events in direct browser ceremonies, and seals independent, verifiable evidence.
