Skip to content
DocsMenu

Add e-signatures and clickwrap on AWS Lambda

View as Markdown

Open this page inChatGPTClaudeCursor

To add e-signatures and clickwrap on AWS Lambda, bundle the esigncomply package with a Node.js handler written as an ES module. The secret key is a function environment variable, an HTTP API or a function URL sends each request to the handler, and a DynamoDB table 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:

Add Esign Comply clickwrap to my app on AWS Lambda: 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/aws-lambda.md (the steps and the tested code for AWS Lambda)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

AWS Lambda facts
- Packages (the only ones that exist): esigncomply (server) and @esigncomply/browser. Bundle esigncomply in the deployment package. It is an ES module: write the handler as index.mjs, or set "type": "module". require("esigncomply") fails on the Lambda runtime.
- The handler receives payload format 2.0 events from an HTTP API or a function URL: event.rawPath, event.requestContext.http.method, event.headers, event.body.
- The secret key is the function environment variable ESIGNCOMPLY_API_KEY, passed as a NoEcho parameter of the template. Never commit it. Never print it.
- Two invocations can run in two execution environments. Keep the pinned version IDs in DynamoDB, never in a variable outside the handler.
- sam local start-api passes only the variables the template declares. Declare every variable the handler reads.
- 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. Handler, POST /api/ceremony: create the session with esc.sessions.create and an Idempotency-Key, save the signer ID and the pinned version IDs in DynamoDB, and return only clientToken, apiUrl and documents.
4. Handler, 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. Handler, POST /api/signup/confirm: read the record with esc.records.get and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the item in DynamoDB. Only then create the account, and store the record ID and the receipt in the same item.

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

The rest of this page is the same integration by hand, in eight steps. Steps 1 to 7 run on your machine with Docker and the AWS SAM CLI. Step 8 is the part that happens on AWS.

Before you start

  • A test API key. Create an account 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.
  • Nothing else from Esign Comply. Test mode works on localhost with no card and no domain, and the Free plan includes it in full.
  • Docker and the AWS SAM CLI. SAM runs the handler on the Lambda runtime image on your machine. This page was run with SAM CLI 1.155.2.
  • Node.js 20.19 or later for npm and the conformance check. The function itself runs on the nodejs22.x runtime.
  • An AWS account, when you reach step 8. Steps 1 to 7 need none.
  • curl and jq for steps 2, 3 and 4.

Step 1. Install

Install the server package into the function's folder. It travels in the deployment package: the Lambda runtime includes the AWS SDK, not this package.

mkdir esigncomply-quickstart && cd esigncomply-quickstart
npm init -y && npm pkg set type=module
npm install esigncomply

Step 2. Set the key

On your machine the key goes in .env, which the shell commands on this page read. On Lambda it is an environment variable of the function. The template in step 4 takes it as a parameter marked NoEcho, so it is never printed and never committed.

# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...

Load the file into your shell for the commands in steps 2, 3 and 7, then check that the key works:

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}'
{
  "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. The rules for handling keys are in /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.

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:

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, then load the file into your shell again. 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 checks that it does. With your own documents, publish the text you already have and change the notice to match. See Documents and Profiles.

Step 4. Create a session on the server

The SAM template declares the function, the HTTP API in front of it, the table, and every environment variable the handler reads:

# template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Esign Comply signup clickwrap on AWS Lambda

Parameters:
  EsignComplyApiKey:
    Type: String
    NoEcho: true # the secret key: never printed, never committed
  EsignComplyProfileId:
    Type: String
  EsignComplyTermsId:
    Type: String
  EsignComplyPrivacyId:
    Type: String
  EsignComplyLive:
    Type: String
    Default: "false" # "true" on the production stack only
    AllowedValues: ["true", "false"]

Resources:
  SignupFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: .
      Handler: index.handler
      Runtime: nodejs22.x
      Timeout: 15
      Environment:
        Variables:
          ESIGNCOMPLY_API_KEY: !Ref EsignComplyApiKey
          ESIGNCOMPLY_API_URL: "" # empty: the SDK uses the API host of the key's region
          ESIGNCOMPLY_PROFILE_ID: !Ref EsignComplyProfileId
          ESIGNCOMPLY_TERMS_ID: !Ref EsignComplyTermsId
          ESIGNCOMPLY_PRIVACY_ID: !Ref EsignComplyPrivacyId
          ESIGNCOMPLY_LIVE: !Ref EsignComplyLive
          ACCEPTANCES_TABLE: !Ref AcceptancesTable
          DYNAMODB_ENDPOINT: "" # set only for DynamoDB Local
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref AcceptancesTable
      Events:
        Http:
          Type: HttpApi # every path and method, as payload format 2.0

  # What each session pinned, then the record ID and the receipt.
  AcceptancesTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: signer_id
        Type: String

Outputs:
  SignupUrl:
    Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/signup"

The handler is one ES module. An HTTP API, like a function URL, sends each HTTP request as one event in payload format 2.0, and the handler routes on event.rawPath. POST /api/ceremony creates the session and returns three values to the browser: the client token, the API URL and the pinned documents.

// index.mjs
import { readFile } from "node:fs/promises";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand, PutCommand, UpdateCommand } from "@aws-sdk/lib-dynamodb";
import { EsignComply } from "esigncomply";

// Created once per execution environment and reused while Lambda keeps it warm.
// The key comes from the function's environment variables: the SDK reads ESIGNCOMPLY_API_KEY itself.
const esc = new EsignComply();
// DYNAMODB_ENDPOINT is set only for DynamoDB Local on your machine. On AWS it is empty.
const db = DynamoDBDocumentClient.from(new DynamoDBClient(process.env.DYNAMODB_ENDPOINT ? { endpoint: process.env.DYNAMODB_ENDPOINT } : {}));

const TABLE = process.env.ACCEPTANCES_TABLE ?? "esigncomply-acceptances";
const SEALED = ["recorded", "timestamped", "anchored"];
// Test records everywhere except the function that has ESIGNCOMPLY_LIVE set to "true": production.
const LIVE = process.env.ESIGNCOMPLY_LIVE === "true";
const DOCUMENTS = {
  terms: process.env.ESIGNCOMPLY_TERMS_ID,
  privacy: process.env.ESIGNCOMPLY_PRIVACY_ID,
};

// 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 json = (statusCode, body) => ({ statusCode, headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
const html = (body) => ({ statusCode: 200, headers: { "content-type": "text/html; charset=utf-8" }, body });

// A function URL sends each HTTP request as one event (payload format 2.0) and expects one response object.
export const handler = async (event) => {
  const method = event.requestContext.http.method;
  const path = event.rawPath;

  if (method === "GET" && path === "/signup") {
    return html(await readFile(new URL("./signup.html", import.meta.url), "utf8"));
  }

  // The document pages: each one renders a registered version, unmodified.
  if (method === "GET" && path.startsWith("/legal/")) {
    const documentId = DOCUMENTS[path.slice("/legal/".length)];
    if (!documentId) return json(404, { error: "not_found" });
    const { data, error } = await esc.documents.versions.getContent(documentId, event.queryStringParameters?.v ?? "current");
    if (error) return json(404, { error: error.code });
    return html(`<!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 (method === "POST" && path === "/api/ceremony") {
    const origin = event.headers.origin ?? `https://${event.requestContext.domainName}`;
    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" },
        ],
        context: { url: `${origin}/signup`, locale: "en-US", purpose: "account_signup" },
      },
      { idempotencyKey: `signup-${signer.external_id}-${crypto.randomUUID()}` },
    );
    if (error) return json(502, { error: error.code });

    // Two invocations can run in two execution environments, so what this one pinned goes to DynamoDB.
    await db.send(new PutCommand({ TableName: TABLE, Item: { signer_id: signer.external_id, version_ids: session.documents.map((d) => d.version_id).sort() } }));
    return json(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 (method === "POST" && path === "/api/signup/confirm") {
    const text = event.isBase64Encoded ? Buffer.from(event.body ?? "", "base64").toString() : (event.body ?? "{}");
    const { recordId } = JSON.parse(text);
    const { data: record, error } = await esc.records.get(String(recordId));
    const { Item: row } = await db.send(new GetCommand({ TableName: TABLE, Key: { signer_id: signer.external_id }, ConsistentRead: true }));
    const confirmed =
      !error &&
      row !== undefined &&
      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(row.version_ids);
    console.log(confirmed ? `confirmed ${record.id} (${record.status})` : "refused");
    if (!confirmed) return json(409, { confirmed: false });

    // Only now create the account. The record ID and the receipt stay in your own table.
    await db.send(
      new UpdateCommand({
        TableName: TABLE,
        Key: { signer_id: signer.external_id },
        UpdateExpression: "SET record_id = :id, receipt = :receipt, accepted_at = :at",
        ExpressionAttributeValues: { ":id": record.id, ":receipt": record.receipt, ":at": record.signed_at },
      }),
    );
    return json(200, { confirmed: true, recordId: record.id });
  }

  return json(404, { error: "not_found" });
};

The client and the DynamoDB client are created outside the handler, so a warm execution environment reuses them. The pinned versions are not kept there: two invocations can run in two execution environments, and Lambda ends each one after a while. They go to DynamoDB.

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.

On your machine the table lives in DynamoDB Local. Start it on a Docker network and create the table with this script, run on the Lambda image, which already has the AWS SDK:

// create-table.mjs
import { CreateTableCommand, DynamoDBClient } from "@aws-sdk/client-dynamodb";
const db = new DynamoDBClient({});
const out = await db.send(new CreateTableCommand({
  TableName: "esigncomply-acceptances",
  AttributeDefinitions: [{ AttributeName: "signer_id", AttributeType: "S" }],
  KeySchema: [{ AttributeName: "signer_id", KeyType: "HASH" }],
  BillingMode: "PAY_PER_REQUEST",
}));
console.log("table", out.TableDescription.TableName, out.TableDescription.TableStatus);
docker network create esc-local
docker run -d --name dynamodb --network esc-local \
  public.ecr.aws/aws-dynamodb-local/aws-dynamodb-local:latest -jar DynamoDBLocal.jar -inMemory -sharedDb
docker run --rm --network esc-local \
  -e AWS_ENDPOINT_URL_DYNAMODB=http://dynamodb:8000 -e AWS_REGION=us-east-1 \
  -e AWS_ACCESS_KEY_ID=local -e AWS_SECRET_ACCESS_KEY=local \
  -e NODE_PATH=/var/runtime/node_modules -v "$PWD":/var/task:ro \
  --entrypoint node public.ecr.aws/lambda/nodejs:22 /var/task/create-table.mjs
table esigncomply-acceptances ACTIVE

sam local start-api takes the function's variables from a JSON file. Write it from the variables in your shell, so the key is typed once:

jq -n '{SignupFunction: {
  ESIGNCOMPLY_API_KEY: env.ESIGNCOMPLY_API_KEY,
  ESIGNCOMPLY_API_URL: (env.ESIGNCOMPLY_API_URL // ""),
  ESIGNCOMPLY_PROFILE_ID: env.ESIGNCOMPLY_PROFILE_ID,
  ESIGNCOMPLY_TERMS_ID: env.ESIGNCOMPLY_TERMS_ID,
  ESIGNCOMPLY_PRIVACY_ID: env.ESIGNCOMPLY_PRIVACY_ID,
  ACCEPTANCES_TABLE: "esigncomply-acceptances",
  DYNAMODB_ENDPOINT: "http://dynamodb:8000"
}}' > env.json   # never commit this file

Then start the local API:

sam local start-api --env-vars env.json --docker-network esc-local --warm-containers EAGER
Mounting /path/to/esigncomply-quickstart as /var/task:ro,delegated, inside runtime container
 * Running on http://127.0.0.1:3000

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 signup.html, beside the handler: the function serves it at /signup, so the page, the document pages and the two routes share one origin.

<!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:3000/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. A box ticked before that fails CR-01. In a test with the session request held back, a click on the box did nothing. The button stays disabled until the box is ticked. Tick it, click Create account, and the page shows a line such as:

Account created. Record rec_dCgns1Qb21DZK1m0ANa6

Step 6. Confirm the record on the server

The result of complete() was delivered to the browser, so the handler does not trust it. POST /api/signup/confirm in index.mjs reads the record with the secret key and the item from DynamoDB with a consistent read, and grants access only when four things hold: the status is recorded, timestamped or anchored; livemode is what this stack 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.

The function logs one line for each confirmation:

INFO	confirmed rec_dCgns1Qb21DZK1m0ANa6 (anchored)

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

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

See Server confirmation 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.

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

The report for this page's code behind sam local start-api, shortened:

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

Ceremonies
  390x844    record rec_dCgns1Qb21DZK1m0ANa6  session ses_tjVnfi6jPiFo2NC71jrB, 5 events
  768x1024   record rec_3gVVUx4W8KeDD3xc12gK  session ses_BVndnShZtvnKJqpivZsC, 5 events
  1440x900   record rec_StnX0QPnaQZ4tEYQjF4t  session ses_khDd9FC1c744htwu5JVn, 5 events

Summary: 0 block, 0 warn, 27 pass.

A second run of the same handler on the runtime image, with function URL events sent to the runtime emulator, ended with the same summary.

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, and every flag of the command is on the CLI page.

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.
  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 deploy the stack. The settings below are from AWS's own documentation, checked on November 24, 2026: Lambda environment variables, Invoking Lambda function URLs, the Lambda execution environment, Lambda with Node.js, sam local start-api and sam deploy.

The stack. sam deploy deploys the template with AWS CloudFormation, and --guided asks for each parameter. Deploy two stacks: a test stack with the test key and the test IDs, and a production stack with the live key, the live IDs and EsignComplyLive set to true.

sam deploy --guided --stack-name esigncomply-quickstart-test
sam deploy --guided --stack-name esigncomply-quickstart

On AWS the table is the one the template declares, and DYNAMODB_ENDPOINT stays empty. The stack prints the address of the signup page as SignupUrl.

The key. Change it by deploying the stack again with a new parameter value. aws lambda update-function-configuration --environment replaces the whole set of variables of a function, so a call that names one variable removes the others. AWS recommends AWS Secrets Manager over environment variables for API keys: if your account already uses it, read the key from there when the execution environment starts.

Test mode on the test stack. An HTTP API answers on https://<api-id>.execute-api.<region>.amazonaws.com, and a function URL on https://<url-id>.lambda-url.<region>.on.aws. A test key refuses a host it does not know with domain_mismatch. List the exact host of the test stack under Domains in the dashboard, or with the API:

curl -X PATCH https://esigncomply.com/v1/domains/dom_4Kx9 \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" -H "Content-Type: application/json" \
  -d '{ "test_origins": ["a1b2c3d4e5.execute-api.us-east-1.amazonaws.com"] }'

In a test against the API, a session for that host was refused before the entry existed and accepted after it, and the host of another API stayed refused.

The production domain. Go live on a domain you own. You cannot add a DNS record under amazonaws.com or on.aws, and the file method is offered only for a fixed list of platform suffixes that includes neither. Put your own domain in front of the production stack, register it with Esign Comply and verify it with one DNS record. See Register a domain.

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

  • ERR_REQUIRE_ESM when the function starts. The handler is a CommonJS file that calls require("esigncomply"). The package is an ES module, and on the Lambda Node.js 22 runtime image that call failed with this error. Name the handler index.mjs, or set "type": "module" in package.json, and use import.
  • missing_api_key or invalid_api_key under sam local start-api. A variable in env.json reaches the function only when the template declares it. In a test, a variable that was in env.json and not in the template never arrived. Declare every variable under Environment, and name the function in env.json by its logical ID, SignupFunction. See missing_api_key.
  • domain_mismatch on the test stack. The host of the HTTP API or the function URL is not a test origin of your domain. Add the exact host under Domains in the dashboard. Test keys work on localhost with no setup. See domain_mismatch.
  • 429 when the handler reads the record. The handler needs no retry loop: the esigncomply package waits for the time in Retry-After and tries again, up to twice, inside the invocation. In the test, four confirmations sent at once for one record all answered 200. On the runtime image one of those invocations lasted 1.19 seconds and the other three under 0.2 seconds. Four reads sent at once through the package showed why: two got 429 with Retry-After: 1 and passed on the next attempt. See rate_limit_exceeded and Retries and timeouts.

Questions about the AWS Lambda quickstart

Why is the Lambda handler an ES module?

Because esigncomply is an ES module with no CommonJS build. On the Lambda Node.js 22 runtime image, a CommonJS handler that called require("esigncomply") failed with ERR_REQUIRE_ESM. A handler named index.mjs, or one beside a package.json with "type": "module", imports it directly.

Why DynamoDB and not a variable in the function?

Because a variable lives in one execution environment. Lambda can run two invocations in two environments and ends each environment after a while, so the confirmation can land where the session was never seen. The quickstart reads the item with a consistent read.

Does the same handler work behind a function URL?

Yes. AWS documents that function URL events follow the same schema as payload format 2.0 of API Gateway. The handler on this page passed the conformance check twice on the runtime image: behind sam local start-api, and with function URL events sent straight to the runtime emulator.

Why does env.json repeat the variable names of the template?

Because sam local start-api passes a function only the variables its template declares. env.json supplies the values for your machine, keyed by the function's logical ID. In a test, a variable that appeared only in env.json never reached the handler.

Was this quickstart deployed to AWS?

Not yet. The handler ran on the Lambda Node.js 22 runtime image with DynamoDB Local, and the template passed sam validate --lint and served the local API. sam deploy, the IAM policy, the hosted table and the API's address are proven only by a deployment to an AWS account.

Next steps

Run on 2026-11-26 on the Lambda Node.js 22 runtime image (Node.js 22.23.5, AWS SDK 3.1105.0) with DynamoDB Local, once behind sam local start-api (SAM CLI 1.155.2, with --no-memory-limit on the test machine) and once with function URL events sent to the runtime emulator, with esigncomply 1.0.4 and the conformance check from esigncomply 1.0.4, against the API in test mode. The AWS settings are from AWS's documentation as of 2026-11-24. The stack has not yet been deployed to AWS.

Last updated · API version 2026-11-21