# Build an order form signing flow

> Let customers sign order forms inside your own app. The quote and totals are your UI and the signature is recorded. Live demo, full prompt, steps and record.

Source: https://esigncomply.com/use-cases/order-form

Use case · order form

You're closing deals in your own app: the customer reviews the quote, checks the totals and signs the order form. The quote builder and the totals are your UI, built with your AI coding tool, and Esign Comply records the signature against the exact order the customer saw.

[Get started](https://esigncomply.com/signup) · [Generate a prompt](https://esigncomply.com/product/prompt-generator)

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

Live demo · test mode

## Try an order form signing page

This is a real signing ceremony against the real Esign Comply API in test mode: type any name, click Sign order, and the signature is recorded against that exact order.

**Interactive on the HTML page:** A live demo of a signing screen (Order form). It runs a real signing ceremony against the Esign Comply API in test mode and shows each step as it is recorded. Open https://esigncomply.com/use-cases/order-form#demo to use it.

The demo runs at level L1, so there is no code to fetch from an inbox. Esign Comply recommends L2 for an order form: the buyer also confirms a six-digit code sent to their email.

The prompt · from the generator

## The prompt that builds the order signing page

The Esign Comply prompt generator produced this for contract signing with an Order Form, on Next.js App Router with Supabase and Vercel, under the U.S. Federal rule pack. Paste it into Cursor, Claude Code, v0, Lovable, Bolt or Replit. It covers the signing page and the record. The quote builder is your own feature, described in your own words.

The prompt labels the button Sign agreement. Rename it to Sign order or anything else: the notice has to name the label exactly. IDs in angle brackets are placeholders the prompt tells your tool to ask for, and `{Company}` is your company name.

[Generate it for your own regions and stack](https://esigncomply.com/product/prompt-generator)

esigncomply-order-form-prompt.md · 1,681 words

````markdown
# Esign Comply integration: contract signing
Prompt esc_prompt_6a6a4f615310 · blocks 2026.11 · guidance bundled · region US
Jurisdictions: US-FED · mode auto

You are adding legally significant signature flows to this Next.js App Router application (TypeScript, Supabase Auth and Postgres, deployed on Vercel). Esign Comply is the independent record keeper. You build every screen. The Esign Comply SDK observes the screens you build and seals the record.

Follow this prompt exactly. If something here 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.

This prompt has four kinds of instruction. Keep them apart:
- "Required for the record": build all of it. Esign Comply checks these.
- "Your obligations": duties the law places on {Company}. Esign Comply does not check them. Build what code can do and list the rest in your report.
- "Recommendations": suggestions. Ask the developer before applying any that changes the product.
- "What you can send us": optional reports {Company} may file with Esign Comply.

## Context
- Packages (the only ones that exist): `esigncomply` (server), `@esigncomply/browser` (client), `@esigncomply/react` (optional hooks).
- API host: https://esigncomply.com/v1
- Environment variables (server only, never NEXT_PUBLIC_): ESIGNCOMPLY_API_KEY, ESIGNCOMPLY_WEBHOOK_SECRET
- Profiles: contract = `<profile ID for contract>`
- Documents: Order Form = `<document ID for Order Form>`
- An ID in angle brackets does not exist yet. Ask the developer for it. Do not invent IDs.
- Rule pack versions: 2026-11-21 (all selected packs).
- Server SDK calls return `{ data, error }` and do not throw. Check `error` every time.

## Required for the record
1. Create every session on the server with the secret key. Send only `client_token` to the browser.
2. Read `required_steps` from the session and satisfy each one. Do not hard-code steps.
3. Show the notice text directly above the action button, in the same container, visible without scrolling at 390 x 844 (CR-04).
4. Every notice names the action button by its label and every document by its title (CR-02, CR-03). Each flow's wording is in its build step.
5. Links to documents must be underlined and use a colour that differs from the surrounding text with a contrast ratio of at least 3:1, and at least 4.5:1 against the background. Notice text is at least 14px and never lighter than body text (CR-05, CR-06).
6. Every typed-name field starts empty (CR-01).
7. Only one primary button inside the assent container. Any other action sits outside it (CR-07).
8. Serve each document at a stable page on this domain that renders the registered version fetched from Esign Comply, unmodified (CR-08).
9. Treat the browser result as untrusted. Grant access only after the server has confirmed the record with the secret key (step 4 below).
10. Pass an `Idempotency-Key` on session creation.

### Never
- Never pre-check a box, auto-submit, or call `.click()` on the user's behalf.
- Never treat sign-in, scrolling, or continued use as acceptance.
- Never use "By continuing" or "By clicking below" wording.
- Never put the secret key, or any call that uses it, in a client component.
- Never proxy `@esigncomply/browser` calls through this application's server.
- Never cache or copy document text into the repository. Always render the registered version.
- Never write to `esign_acceptances` from the browser.
- Never show "signed" or "accepted" in the interface before step 4 confirms it.
- Never write or change the text of the Order Form.

## Your obligations
These are {Company}'s duties under the rule packs selected. Esign Comply lists them and does not perform, monitor, or verify them. The list is not exhaustive.

US-FED · pack 2026-11-21
- Customer: where another law requires {Company} to keep a record, keep an accurate, accessible copy for that period, including after export (US-31); before offering a record in court, give the adverse party reasonable written notice and access to the record and declaration (US-38). Outside this codebase.

## Recommendations
Esign Comply recommends the following. Ask the developer which to apply.

- State in the contract notice that the signer agrees to sign electronically, give a way to decline, and show a review step before the final act (US-04, US-05). Already reflected in step 6.
- Before a material update to a document takes effect, notify signers in advance and ask for a fresh acceptance (US-18).
- Keep saving and printing open wherever a signed record is shown (US-29).
- Where minors may sign, consider an age attestation checkbox: `ceremony.ageAttested({ checkbox })` (US-42).

## What you can send us
Optional. Each report is sealed with Esign Comply's receipt time and marked as supplied by {Company}; Esign Comply does not verify it. Every field is optional and any text, JSON, or file is accepted.
Reports never affect recording, and a failed one never blocks the user's action. Suggested `data` per type: `esc.supplements.types()`.

- When the terms-update notice email is sent:
  `esc.supplements.create({ subject: { signer: signerId }, type: "notice.sent", rule_ids: ["US-18"], text, data: { channel: "email", template } })`
- Anything else worth keeping (support ticket, screenshot, policy in force): type `note`, or omit `type`.

Only wire these if the developer says yes.

## Build steps

### 1. Install and configure
`npm install esigncomply @esigncomply/browser`
Create `lib/esigncomply.ts`:
```ts
import "server-only";
import { EsignComply } from "esigncomply";
export const esc = new EsignComply(process.env.ESIGNCOMPLY_API_KEY!);
```
Keys go in `.env.local` and the Vercel project settings, never in chat.
Run commands in the integrated terminal. Rules file: `.cursor/rules/esigncomply.mdc`.

### 2. Database (Supabase migration)
```sql
create table public.esign_acceptances (
  id uuid primary key default gen_random_uuid(),
  user_id uuid references auth.users(id) on delete cascade,
  signer_id uuid not null,
  record_id text not null unique,
  document_id text not null,
  version_id text not null,
  purpose text not null,
  signed_at timestamptz not null,
  created_at timestamptz not null default now()
);
alter table public.esign_acceptances enable row level security;
create policy "read own" on public.esign_acceptances
  for select using (auth.uid() = user_id);
-- No insert, update, or delete policies. Only the service role writes.
```
Add `signer_id uuid unique` to the profile table.

### 3. Document pages
Create `app/legal/[slug]/page.tsx` for `order-form`. Resolve `current` on session creation only. Fetch with `esc.documents.versions.getContent(documentId, versionId)`; render, print and download by the exact version ID returned on the session; the cache key includes that ID. Render inside `<article data-esc-document>` and reject stale versions before the final action. Give users a real opportunity to read the terms.

### 4. Server confirmation (the only place access is granted)
Server action `finishContract(recordId)`:
- `const { data: record, error } = await esc.records.get(recordId);`
- Require: no error; `record.status` is "recorded", "timestamped", or "anchored"; `record.signer.external_id` equals the signer ID this server put on the session; `record.livemode` equals `process.env.VERCEL_ENV === "production"`; the record lists the exact versions pinned in that session.
- Only then mark the document signed, and insert one `esign_acceptances` row per document using the service-role client.
- If checks are inconclusive, do not mark the document signed. Show: "We could not confirm whether your acceptance was recorded. Please wait while we check." Reconcile the existing session before requesting another act.

### 5. Webhook
`app/api/esigncomply/webhook/route.ts`, Node.js runtime. Read the raw body, then `esc.webhooks.verify(rawBody, request.headers, process.env.ESIGNCOMPLY_WEBHOOK_SECRET!)`.
Reject on failure with 400. Handle idempotently by `webhook-id`:
- `record.completed`: upsert `esign_acceptances` (covers a browser that closed early).
- `record.disputed`: flag the row and notify the admin email.
- Ignore event types you do not recognise and return 200.
Return 200 within 5 seconds.

### 6. Contract signing (`/contracts/[id]`)
- Server: create a session with `profile: "<profile ID for contract>"`, `documents: [{ document: "<document ID for Order Form>", version: "current" }]`, `context.purpose: "contract_signature"`, the signer's `external_id`, `name` and `email`, `class: "business"`.
- Obtain `country` and applicable jurisdiction from the form/customer configuration; do not guess from IP.
- Page layout, top to bottom:
  1. The full session-pinned Order Form rendered inline with download and print. Call `ceremony.presentDocument({ versionId, mode: "inline", container })`.
  2. Email verification (CR-17): a "Send code" button calls `ceremony.verify.start({ method: "email_otp" })`; a 6-digit field calls `ceremony.verify.confirm({ code })`. Show the masked address returned by the API. Allow resend after 30 seconds.
  3. Review line: "You are signing the Order Form between {Company} and {signer name} as {signer name}." Record it with `ceremony.reviewPresented({ container })` (CR-13).
  4. Assent container with: the notice "By typing your name and clicking Sign agreement, you agree to sign this agreement electronically and to be bound by it." (CR-12); an empty text field labelled "Type your full legal name" (CR-09); a primary button "Sign agreement"; a secondary text link "Decline" outside the container that calls `ceremony.cancel()`.
  5. `ceremony.observeAssent({ region, typedName: nameField, submit })`, then `ceremony.complete()` from the click.
- After completion, confirm on the server as in step 4, then show "Signed. A copy has been emailed to you by Esign Comply." with a link to `result.verifyUrl` and a "Download copy" link.
- Do not render a signature image or a cursive font as the signature.

### 7. Errors
- `ceremony.complete()` rejected with a rule ID: show the message, keep the form, do not retry automatically.
- Network failure or 5xx: show "We could not confirm whether your acceptance was recorded. Please wait while we check." Reconcile the same session and idempotency key before requesting another act. Never proceed without a record.
- `client_token_expired`: create a new session and re-attach.
- `verification_failed`: start a new session; offer no way past verification.

## Verify before you report success
1. `npm run build` passes and no file under `app/**` marked "use client" imports `esigncomply` or reads ESIGNCOMPLY_API_KEY.
2. Run `npx esigncomply check --url http://localhost:3000/contracts/test`. Fix every finding marked "block", re-running until none is left. List every finding marked "warn" in your report.
3. Confirm by test that submitting with the name field empty does nothing, and that calling `finishContract` with a made-up record ID does not mark the document signed.
4. Report: files created or changed, anything in this prompt you did not implement and why, the conformance summary, each item under "Your obligations" with "built", "partly built", or "needs a process outside this codebase", and each recommendation with the developer's decision.
````

6 required steps

## The six steps an order form signature needs

These are the `required_steps` the API returns for a session on the recommended contract profile. The order page your tool builds satisfies them in this order before the Sign button does anything.

Esign Comply's guidance for an order form

### A typed name with an emailed code

For an order form, Esign Comply recommends the typed-name method at level L2. The buyer's signatory types their full legal name, and Esign Comply confirms a one-time code sent to the email address on the order.

- Method · Typed name
- Level · L2, one-time code by email
- method: typed · assurance_level: L2 · document_type: contract · purpose: contract_signature

1. **The SDK attaches to the order page**

   `client.attached`

   The signer sees

   The order page in your app, opened from the link your team sent.

   Esign Comply records

   The page address, the SDK version, the viewport, the language and the time zone, sent straight from the buyer's browser.

2. **The order is shown**

   `document.presented:<version_id>`

   The signer sees

   The order form with its line items, term, price and total, rendered from the version you registered for this deal.

   Esign Comply records

   The version ID and a hash of the text on screen. A page that shows other numbers than the registered version produces a different hash.

3. **The notice is captured**

   `notice.captured`

   The signer sees

   The notice above the button: "By typing your name and clicking Sign order, you agree to sign this agreement electronically and to be bound by it."

   Esign Comply records

   The text of the signing area, the button label, the document links and how the notice and the button were laid out.

4. **The emailed code is confirmed**

   `identity.verified`

   The signer sees

   A code sent to their email by Esign Comply, typed into a field on your page.

   Esign Comply records

   The confirmation that the code for the address on the session came back in time.

5. **The buyer types their name**

   `intent.captured`

   The signer sees

   An empty field for their full legal name.

   Esign Comply records

   The typed name, the field and button labels, and that the entry came from real user events.

6. **The signing act**

   `signature.applied`

   The signer sees

   The Sign order button. Your app shows the order as signed after your server confirms the record.

   Esign Comply records

   The act itself with Esign Comply's server time, sealed into a record with a signed receipt.

The prompt adds a review line before the signing act, recorded with `ceremony.reviewPresented()`: the buyer sees what they are signing and as whom, and can still go back and correct it.

[How the ceremony works](https://esigncomply.com/docs/concepts/ceremony) · [Browser SDK reference](https://esigncomply.com/docs/sdk/browser) · [Ceremony SDK and conformance checks](https://esigncomply.com/product/ceremony-sdk)

You vibe code · Esign Comply handles

## What you build for an order form, and what Esign Comply handles

The commercial part of an order is yours from the first line item to the invoice. Esign Comply comes in at one moment: when the buyer signs.

### The quote

You vibe code

Products, quantities, discounts, tax and the total. Your pricing logic, your quote builder, your approval rules.

Esign Comply handles

Nothing here. Esign Comply never calculates or checks a price.

### The order document

You vibe code

When the quote is final, render it as the order form and register that text as a version: Markdown, HTML, plain text or PDF.

Esign Comply handles

Hashes the version and pins it to the record, so the signed order is the one with those line items and that total.

### Changes after sending

You vibe code

A changed quantity or price is a new version. Send the buyer the new link and retire the old one in your app.

Esign Comply handles

Versions are immutable, and a record always names the version that was presented.

### The signing page

You vibe code

The order view, the code field, the name field, the notice and the Sign order button, in your own design.

Esign Comply handles

The rules prompt for your AI tool, and the browser SDK that reports each step from the buyer's browser.

### Who signs

You vibe code

Collect the signatory's name, title and email in your form. Add a signer for your side when your process needs a countersignature.

Esign Comply handles

One session per signer, each with its own sealed record. The name you pass is recorded as supplied by you.

### Your order ID

You vibe code

Put your own order or deal ID in the session's `metadata`.

Esign Comply handles

Returns it on the record, so your server ties the confirmed record back to the order.

### After the signature

You vibe code

Provision the account, create the invoice or the subscription and tell the account team, from your server, after confirmation.

Esign Comply handles

`GET /v1/records/{id}` and the signed `record.completed` webhook. Payment stays with you: Esign Comply records the signature.

The record

## The record you get for each signed order

The record answers one question for good: which order did this person sign. It names the version with those line items and that total, and it is held outside your CRM and your database.

Sealed at signing · kept by Esign Comply

### What the sealed record holds

- The order form version, pinned by SHA-256 hash, so the line items and the total are fixed.
- The notice and the button label as the buyer's browser rendered them.
- The typed name of the signatory.
- The confirmed one-time code for the signatory's email address.
- Your order ID in `metadata`, marked as supplied by you.
- Server times for every step, a receipt signed with ES256, an outside RFC 3161 timestamp and a ledger entry.

Yours to store, send and check

### What you do with it

- Signed receipt

  **Store it on the order**

  Save the record ID and the receipt on the order row. Finance and support read your table, and the receipt ties it to the sealed record.

- PDF, per record

  **Evidence report**

  Attach `GET /v1/records/{id}/report` to the deal: the signatory, the order version and its hash, the method and the timeline.

- `verify_url`

  **Verification page**

  Print the verification link on the countersigned PDF you send the customer.

- ZIP, verifies offline

  **Evidence package**

  The record, the receipt, the timestamp token, the ledger proof and the exact document bytes. Anyone you hand it to runs the open-source `esigncomply-verify` with no account and no network.

[How sealing and verification work](https://esigncomply.com/product/evidence) · [Why a third party keeps the record](https://esigncomply.com/why/third-party-record)

## Build guides, stack guides and AI tools

An order form sits between a quote and an invoice. These guides cover the parts around the signature.

- Build guide

  **[Build your own PandaDoc](https://esigncomply.com/build/pandadoc-alternative)**

  Proposals and quotes with a pricing table, a share link, and acceptance with a signature on the page.

- Build guide

  **[Build your own DocuSign](https://esigncomply.com/build/docusign-alternative)**

  Send any PDF for signature from your own app, with several signers and completed copies.

- Stack guides

  **[Step-by-step guides for your stack](https://esigncomply.com/guides)**

  Sessions, the signing page and server confirmation on the framework you already use.

- AI tools

  **[Build it with your AI tool](https://esigncomply.com/build#tools)**

  How to hand this prompt to Cursor, Claude Code, Lovable, v0, Bolt or Replit.

### Run the prompt in your AI tool

- [Cursor](https://esigncomply.com/build/cursor)
- [Claude Code](https://esigncomply.com/build/claude-code)
- [Codex](https://esigncomply.com/build/codex)
- [Windsurf](https://esigncomply.com/build/windsurf)
- [GitHub Copilot](https://esigncomply.com/build/github-copilot)
- [Devin](https://esigncomply.com/build/devin)
- [Lovable](https://esigncomply.com/build/lovable)
- [v0](https://esigncomply.com/build/v0)
- [Bolt](https://esigncomply.com/build/bolt)
- [Replit](https://esigncomply.com/build/replit)
- [ChatGPT](https://esigncomply.com/build/chatgpt)
- [Grok](https://esigncomply.com/build/grok)
- [Grokbot](https://esigncomply.com/build/grokbot)
- [Muse](https://esigncomply.com/build/muse)
- [All AI tools](https://esigncomply.com/build#tools)

## Questions about order form signing

### How do I let customers sign an order form in my app?

Render the final quote as an order form and register it as a document version. When the buyer opens their link, your server creates a session with POST /v1/sessions, your page shows the order and attaches the browser SDK, and the buyer confirms an emailed code, types their name and clicks the Sign button. Your server confirms the record, then provisions and invoices.

[Read the quickstart](https://esigncomply.com/docs/quickstart)

### Does Esign Comply build the quote or calculate the totals?

No. The quote, the line items, the discounts and the totals are your UI and your logic. You register the finished order form as a document version, and Esign Comply records the signature against that exact version by hash.

### What if the order changes after I send it?

Register the changed order as a new version and send a new link. Versions are immutable and every record names the version the signer was shown, so a signature on the old numbers is never mistaken for a signature on the new ones.

### Who signs an order form, and how?

The buyer's signatory, with a typed name and an emailed code. Esign Comply's guidance for an order form is the typed method at level L2. When you countersign, add a session for your own signatory on the same version: each signer gets a separate sealed record.

### Can the order form and the master agreement be signed together?

Yes. Put both documents on the same session. The signer is shown each one, the record pins each version by hash, and up to 10 documents accepted together count as one signature event.

[See pricing](https://esigncomply.com/pricing)

### More use cases

- [NDA](https://esigncomply.com/use-cases/nda)
- [Contractor agreement](https://esigncomply.com/use-cases/contractor-agreement)
- [Consent form](https://esigncomply.com/use-cases/consent-form)
- [Terms update](https://esigncomply.com/use-cases/terms-update)
- [All use cases](https://esigncomply.com/use-cases)

## Build the order flow yourself. Leave the record to us.

[Get started](https://esigncomply.com/signup) · [Documentation](https://esigncomply.com/docs)

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

PandaDoc, DocuSign and the other product names on this page are trademarks of their owners. Esign Comply is not affiliated with them.

---

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.
