Skip to content
Platform · AWS Lambda

Add e-signatures and clickwrap to an AWS Lambda app

To add e-signatures and clickwrap to an AWS Lambda app, bundle the esigncomply package with a Node.js handler written as an ES module and store the secret key as a function environment variable. The handler creates the session and confirms the record, and a DynamoDB table keeps the receipt. 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
AWS Lambda quickstart

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

Last updated

Run locally for AWS Lambda before publishing
index.mjs (excerpt)
// 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 });
Integrate with AWS Lambda

How do you integrate Esign Comply with AWS Lambda?

On Lambda the server half is one handler. An HTTP API or a function URL sends it each request as an event in payload format 2.0, and it routes on event.rawPath. The esigncomply package is bundled in the deployment package and imported as an ES module. Two invocations can run in two execution environments, so the pinned versions go to DynamoDB.

Lambda invokes your function in an execution environment, which provides a secure and isolated runtime environment.

Source: AWS documentation, Lambda execution environment, read on .
Where each part lives on AWS Lambda
  • Handlerindex.mjs
  • SAM templatetemplate.yaml
  • Confirmindex.mjs

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.

Three steps

How does Esign Comply fit with AWS Lambda?

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

  1. 01
    A function environment variable holds the keyThe SAM template takes ESIGNCOMPLY_API_KEY as a NoEcho parameter and passes it to the function. Lambda encrypts environment variables at rest, and the handler reads the key from process.env. Source: AWS documentation, Lambda environment variables, read on .
  2. 02
    The handler creates the sessionAn HTTP API or a function URL sends POST /api/ceremony to the handler as one event. It calls esc.sessions.create and returns the client token. The same function serves the signup page, and the browser SDK records the ceremony from the signer's device. Source: AWS documentation, Invoking Lambda function URLs, read on .
  3. 03
    A DynamoDB item keeps the receiptThe session route stores the pinned versions in a DynamoDB table that the template declares. The confirm route reads the record with the secret key, compares it with the item, and writes the record ID and the receipt into it.
AWS Lambda setup

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

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

Environment variables

Set them through the template's parameters, with one stack for test and one for production. aws lambda update-function-configuration --environment replaces the whole set of variables of a function, so a call that names one removes the others. AWS recommends AWS Secrets Manager over environment variables for API keys.

Source: AWS documentation, Lambda environment variables, read on .

Local runs and the template

sam local start-api runs the function on the Lambda runtime image and serves it over HTTP on port 3000. It takes the function's variables from --env-vars, and it passes only the variables the template declares, so declare every one the handler reads.

Source: AWS documentation, sam local start-api, read on .

Test stacks and test mode

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: list the exact host of your test stack under Domains in the Esign Comply dashboard as a test origin.

Source: AWS documentation, Invoking Lambda function URLs, 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 it includes neither amazonaws.com nor on.aws. For the record.completed webhook, add a route to the handler and register its production URL under Webhooks in the Esign Comply dashboard.

Read on : AWS documentation, Lambda environment variables, AWS documentation, Invoking Lambda function URLs, AWS documentation, Lambda execution environment, AWS documentation, Lambda with Node.js, AWS documentation, sam local start-api, AWS documentation, sam deploy.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a AWS Lambda 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 AWS Lambda, 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 AWS Lambda
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
3 things to watch

What goes wrong when you add e-signatures on AWS Lambda?

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

  • 01

    require() of the package fails on the Lambda runtime

    esigncomply is an ES module. On the Lambda Node.js 22 runtime image, a CommonJS handler that called require("esigncomply") failed with ERR_REQUIRE_ESM. Name the handler index.mjs, or set "type": "module", and use import.

  • 02

    State outside the handler belongs to one execution environment

    Objects declared outside the handler stay initialized while Lambda reuses an environment, and AWS says not to assume it persists. Two invocations can also run in two environments. Keep the pinned versions in DynamoDB and read them with a consistent read, as the quickstart does.

    Source: AWS documentation, Lambda execution environment, read on .
  • 03

    sam local passes only the variables the template declares

    In the test run, a variable that was in the --env-vars file and not under Environment in the template never reached the function, and the handler called the API without it. Declare every variable in the template, even with an empty value.

Verifiable

What does Esign Comply record for a signature on AWS Lambda?

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

How does test mode work on AWS Lambda preview URLs?

Lambda has no preview deployments of its own: a test stack is your preview. Its HTTP API or function URL has a host of its own, which a test key refuses until you list that exact host under Domains as a test origin. On localhost, with sam local start-api, a test key works with no setup.

Where should the receipt be stored on AWS Lambda?

In a DynamoDB table, beside the signer ID and the record ID. The confirm route writes both once the record is confirmed. The quickstart declares the table in its SAM template and uses one item for the pinned versions and the receipt.

Can a Lambda handler import the esigncomply package?

Yes. Every server call of the quickstart was made with the package on the Lambda Node.js 22 runtime image, bundled in the function's folder. It has to be imported from an ES module: a CommonJS handler that called require on it failed with ERR_REQUIRE_ESM.

Can I use a function URL instead of an HTTP API?

Yes. AWS documents that function URL events follow the same schema as payload format 2.0 of API Gateway, which is what the handler reads. The quickstart's handler passed the conformance check behind the local HTTP API of SAM and with function URL events sent to the runtime emulator.

Was this code 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. The AWS settings come from AWS's documentation as of November 24, 2026. sam deploy, the IAM policy and the hosted table are proven only by a deployment.

Run the signing flow in your Lambda function. Leave the record to us.

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

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

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