Skip to content
DocsMenu

Add e-signatures and clickwrap with PHP

View as Markdown

Open this page inChatGPTClaudeCursor

To add e-signatures and clickwrap with PHP, call the REST API with the secret key: there is no PHP package. The curl extension creates the session and confirms the record, PHP's own session holds the pinned versions, and the browser SDK from a script tag attaches to your checkbox. 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.

This page is plain PHP with no framework. For Laravel, use the Laravel quickstart.

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 PHP app: 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/php.md (the steps and the tested code for PHP)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

PHP facts
- There is no Esign Comply package for PHP. Do not install or invent one. The server calls the REST API at https://esigncomply.com/v1 with Authorization: Bearer and the secret key, using the curl extension or the HTTP client the project already has.
- The browser SDK is a script tag: https://esigncomply.com/sdk/v1/esigncomply.js. It defines the global EsignComply.
- The secret key is in the environment variable ESIGNCOMPLY_API_KEY. PHP does not read .env files on its own. Read it with getenv(): $_ENV is empty when variables_order has no "E", as in php.ini-development and php.ini-production. Never print the key.
- Keep .env and every PHP file except the front controller outside the document root. Only public/ is served.
- With curl, set CURLOPT_RETURNTRANSFER, or curl prints the API's answer into the page. curl does not fail on 4xx and 5xx: read the status with curl_getinfo and the error envelope from the body. Do not call curl_close: it is deprecated since PHP 8.5.
- Keep the signer ID and the pinned version IDs in $_SESSION. Start the session with cookie_httponly, cookie_samesite and use_strict_mode. A session is locked while it is open: open it with read_and_close in the route that only reads it, and never keep it open across the API call.
- Print the document HTML as it is. Escape everything else you print with htmlspecialchars.
- 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 calls POST /v1/sessions with an Idempotency-Key, saves the signer ID and the pinned version IDs in $_SESSION, and returns only clientToken, apiUrl and documents.
4. Server: GET /legal/terms and /legal/privacy render the html from GET /v1/documents/{id}/versions/{version_id}/content 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 calls GET /v1/records/{id} and requires: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the ones in $_SESSION. Only then create the account.

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:8000/signup --callback http://localhost:8000/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.

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.
  • PHP with the curl and session extensions. This page was run on PHP 8.5.13 with cURL 8.23.0, with no framework and nothing installed with Composer. php -m lists the extensions you have.
  • curl and jq for steps 2 and 3, and Node.js 20.19 or later for the conformance check in step 7.

Step 1. Install

No package needed. The server SDK exists for Node.js only, so a PHP server calls the REST API directly: three endpoints, with the curl extension that PHP ships. The page loads the browser SDK from a script tag.

mkdir esigncomply-quickstart && cd esigncomply-quickstart
mkdir public src views

Only public/ is the document root. The code, the page template and the key stay beside it, where no address reaches them.

Step 2. Set the key

Put the key in .env in the project folder, above public/. PHP does not read this file: you load it into the shell that starts PHP, and the code reads the variables with getenv().

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

The folder matters. In a test with the built-in server started in the project folder and no -t public, GET /.env was answered 200 with the whole file, the key included. With public/ as the document root the same request was answered 404.

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

src/esigncomply.php holds the configuration, the client and the session. The esc function is the entire client: one HTTPS call with the secret key that returns the status and the decoded JSON, sent again only when the API answers 429.

<?php
// src/esigncomply.php
declare(strict_types=1);

// There is no PHP package: these are plain HTTPS calls with the secret key, made with the curl extension.
// getenv() reads the environment of the PHP process. $_ENV is empty when variables_order has no "E".
const SEALED = ['recorded', 'timestamped', 'anchored'];
define('API_URL', getenv('ESIGNCOMPLY_API_URL') ?: 'https://esigncomply.com/v1');
define('API_KEY', (string) getenv('ESIGNCOMPLY_API_KEY'));
define('LIVE', getenv('ESIGNCOMPLY_LIVE') === 'true'); // set it in production only
define('DOCUMENTS', ['terms' => getenv('ESIGNCOMPLY_TERMS_ID'), 'privacy' => getenv('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',
];

/** One call to the Esign Comply API. Returns [status, decoded JSON]. */
function esc(string $method, string $path, ?array $body = null, ?string $idempotencyKey = null): array
{
    $headers = ['Authorization: Bearer ' . API_KEY, 'Accept: application/json'];
    if ($body !== null) {
        $headers[] = 'Content-Type: application/json';
    }
    if ($idempotencyKey !== null) {
        $headers[] = 'Idempotency-Key: ' . $idempotencyKey;
    }

    $curl = curl_init(API_URL . $path);
    curl_setopt_array($curl, [
        CURLOPT_CUSTOMREQUEST => $method,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_RETURNTRANSFER => true, // hand the answer back: without it curl prints the answer into your page
        CURLOPT_TIMEOUT => 10,
    ]);
    if ($body !== null) {
        curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($body));
    }
    for ($attempt = 1; ; $attempt++) {
        $answer = curl_exec($curl);
        if ($answer === false) {
            return [0, ['error' => ['code' => 'network_error', 'message' => curl_error($curl)]]];
        }
        // curl does not fail on 4xx and 5xx: the status is here, and the error envelope is the body.
        $status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
        if ($status !== 429 || $attempt === 3) {
            return [$status, json_decode($answer, true) ?? []];
        }
        // Rate limited: wait for the seconds in Retry-After, 1 at least and 5 at most, and send it again, twice at most.
        sleep(max(1, min((int) curl_getinfo($curl, CURLINFO_RETRY_AFTER), 5)));
    }
}

// Server-owned state: PHP's own session. The data stays in a file on the server,
// and the browser holds only the session ID in a cookie.
function signup_session(bool $readOnly = false): void
{
    session_start([
        'cookie_httponly' => true,
        'cookie_samesite' => 'Lax',
        'cookie_secure' => LIVE, // HTTPS only, in production
        'use_strict_mode' => true,
        // A session is locked while it is open. The confirm route only reads it, so it closes it at once.
        'read_and_close' => $readOnly,
    ]);
}

Four things here are specific to PHP, and each one was seen in the test run.

The key is read with getenv(). With PHP's built-in settings $_ENV held the key too. With variables_order=GPCS, the value in both php.ini-development and php.ini-production that PHP 8.5.13 ships, $_ENV did not hold it and getenv() still returned it. Under the built-in server $_SERVER did not hold it either way.

CURLOPT_RETURNTRANSFER is set. Without it curl printed the API's answer into the response: the session route answered with the whole session object, followed by a fatal error. And curl does not fail on a refusal: a made-up record ID came back as status 404 with the error envelope in the body.

There is no curl_close(). On PHP 8.5.13 that call printed Deprecated: Function curl_close() is deprecated since 8.5 into the output of the route.

The session is PHP's own. The browser gets a cookie with a 32-character ID, marked HttpOnly and SameSite=Lax by the options here, and the data stayed on the server: a file sess_ plus the ID in /tmp, readable by its owner only, with the signer ID and the two version IDs in it. With use_strict_mode a request that sent an ID the server never issued got a new one.

When the API answers 429, esc waits for the seconds in Retry-After, 1 at least and 5 at most, and sends the request again, up to twice. curl reads the header itself: CURLINFO_RETRY_AFTER is the number in it. sleep() holds the PHP process that serves the request. The built-in server answered one request at a time in the test, so the wait held the whole server: page requests sent while four confirmations were in flight waited 2.8 to 3.9 seconds.

public/index.php is the front controller: every route of the integration in one file.

<?php
// public/index.php
declare(strict_types=1);

require __DIR__ . '/../src/esigncomply.php';

$method = $_SERVER['REQUEST_METHOD'];
$path = (string) parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

// Under PHP's built-in server this file is the router script: returning false serves a file as it is.
// Only for a real file inside public/, and never for a PHP file, which the server would run.
$file = realpath(__DIR__ . $path);
if (PHP_SAPI === 'cli-server' && $file !== false && is_file($file)
    && str_starts_with($file, __DIR__ . DIRECTORY_SEPARATOR) && !str_ends_with($file, '.php')) {
    return false;
}

function send_json(int $status, array $body): void
{
    http_response_code($status);
    header('Content-Type: application/json');
    echo json_encode($body);
}

if ($method === 'GET' && $path === '/signup') {
    header('Content-Type: text/html; charset=utf-8');
    readfile(__DIR__ . '/../views/signup.html');
    return;
}

// The document pages: each one renders a registered version, unmodified.
if ($method === 'GET' && preg_match('#^/legal/(terms|privacy)$#', $path, $match)) {
    $version = is_string($_GET['v'] ?? null) && $_GET['v'] !== '' ? $_GET['v'] : 'current';
    [$status, $content] = esc('GET', '/documents/' . DOCUMENTS[$match[1]] . '/versions/' . rawurlencode($version) . '/content');
    if ($status === 200) {
        header('Content-Type: text/html; charset=utf-8');
        // The version ID goes into an attribute, so it is escaped. The document HTML is printed as it is.
        echo '<!doctype html><meta charset="utf-8"><article data-esc-document="' . htmlspecialchars($content['version_id'], ENT_QUOTES) . '">' . $content['html'] . '</article>';
        return;
    }
}

// Step 4: create the session with the secret key. The browser gets the client token only.
if ($method === 'POST' && $path === '/api/ceremony') {
    // The page that runs the ceremony: the origin the browser reports, plus its path.
    $origin = $_SERVER['HTTP_ORIGIN'] ?? 'http://' . $_SERVER['HTTP_HOST'];
    [$status, $session] = esc('POST', '/sessions', [
        'profile' => getenv('ESIGNCOMPLY_PROFILE_ID'),
        'signer' => SIGNER,
        'documents' => [
            ['document' => DOCUMENTS['terms'], 'version' => 'current'],
            ['document' => DOCUMENTS['privacy'], 'version' => 'current'],
        ],
        'context' => ['url' => $origin . '/signup', 'locale' => 'en-US', 'purpose' => 'account_signup'],
    ], 'signup-' . SIGNER['external_id'] . '-' . bin2hex(random_bytes(16)));
    if ($status !== 201) {
        send_json(502, ['error' => $session['error']['code'] ?? 'unknown']);
        return;
    }

    signup_session();
    $_SESSION['signer_id'] = SIGNER['external_id'];
    $_SESSION['version_ids'] = array_column($session['documents'], 'version_id');
    session_write_close();
    send_json(200, ['clientToken' => $session['client_token'], 'apiUrl' => $session['api_url'], 'documents' => $session['documents']]);
    return;
}

// Step 6: confirm the record with the secret key before the account exists.
if ($method === 'POST' && $path === '/api/signup/confirm') {
    $body = json_decode((string) file_get_contents('php://input'), true); // an empty or malformed body is refused below
    $recordId = is_array($body) && is_string($body['recordId'] ?? null) ? $body['recordId'] : 'missing';
    signup_session(readOnly: true);
    [$status, $record] = esc('GET', '/records/' . rawurlencode($recordId));

    $versions = array_column($record['documents'] ?? [], 'version_id');
    $expected = $_SESSION['version_ids'] ?? [];
    sort($versions);
    sort($expected);
    $confirmed = $status === 200
        && in_array($record['status'], SEALED, true)
        && $record['livemode'] === LIVE
        && $record['signer']['external_id'] === ($_SESSION['signer_id'] ?? null)
        && $versions === $expected;

    error_log($confirmed ? "confirmed {$record['id']} ({$record['status']})" : 'refused');
    if (!$confirmed) {
        send_json(409, ['confirmed' => false]);
        return;
    }
    // Only now create the account, and store $record['id'] and $record['receipt'] with it.
    send_json(200, ['confirmed' => true, 'recordId' => $record['id']]);
    return;
}

send_json(404, ['error' => 'not_found']);

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.

The session route calls the API first and opens the session after, and the confirm route opens it with read_and_close. PHP locks a session while it is open. In a test with four workers, a request that kept the session open for two seconds made a second request with the same cookie wait 1.7 seconds inside session_start(). After a read_and_close the second request was answered at once.

context.url is built from the Origin header the browser sends with the POST, and from the Host header when there is none. Both come from the client. A request with Origin: https://evil.example was refused by the API with domain_mismatch, and the route answered 502. The built-in server set no HTTPS entry in $_SERVER, and HTTP_HOST was whatever the request said.

Start PHP's built-in server from the shell that loaded .env, with public/ as the document root and the front controller as the router script:

php -S localhost:8000 -t public public/index.php
PHP 8.5.13 Development Server (http://localhost:8000) started

The router script runs for every request. When it returns false the built-in server serves the requested file as it is. The check at the top of index.php allows that only for a real file inside public/ that is not a PHP file. A first version returned false for anything is_file() found: GET /index.php then ran the file a second time and answered with Cannot redeclare function send_json().

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 views/signup.html:

<!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:8000/signup. The button stays disabled until the box is ticked. Tick it, click Create account, and the page shows:

Account created. Record rec_qjrDEyFbPH7g0eicsQk1

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. In a test without disabled and with the session request held back, a box ticked in that time stayed ticked, and the SDK reported a finding for CR-01 at Block level. One page load sent one POST /api/ceremony.

Each link opens a document page on your own server that renders the registered version. index.php escapes the version ID, which goes into an attribute, and prints the document HTML as it is. In a test with htmlspecialchars() around the document, the page showed the tags as text and the SDK reported a finding for CR-08 at Block level: the page behind the link did not match the registered version.

Step 6. Confirm the record on the server

The result of complete() was delivered to the browser, so your server does not trust it. POST /api/signup/confirm in index.php reads the record with the secret key and grants access only when four things hold: the status is recorded, timestamped or anchored; livemode is what this deployment expects; the signer is the one in the session; and the document versions are exactly the ones this server pinned there. This step is never optional.

The server prints one line for each confirmation, through error_log():

[Thu Nov 26 11:26:12 2026] confirmed rec_qjrDEyFbPH7g0eicsQk1 (recorded)

A record ID that was made up is refused with status 409. So is a real record ID sent without the session cookie, or with a session ID the server never issued:

curl -s -X POST http://localhost:8000/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. The checker is a Node.js command line tool, so it needs Node.js 20.19 or later, in a folder of its own:

mkdir -p esc-check && cd esc-check
npm init -y && npm install esigncomply playwright
npx playwright install chromium
npx esigncomply check --url http://localhost:8000/signup --callback http://localhost:8000/api/signup/confirm

The report for this page's code, 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:8000/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_Y36GrRUhjgLbBJP4pLjh  session ses_VWCY2AqNNX94nQLw0hT4, 5 events
  768x1024   record rec_DsoFLjWs6wgPGtacAhiq  session ses_mcHw3tMwnxNiFgaauA5N, 5 events
  1440x900   record rec_DvS1RyfT2VqpaUX9Pmpq  session ses_DrMG9YyF1QS1e7YfNNEm, 5 events

Summary: 0 block, 0 warn, 27 pass.

The server logged a confirmed line for each of the three records.

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 switch the server over:

  • Set the live key as ESIGNCOMPLY_API_KEY and set ESIGNCOMPLY_LIVE=true in production only. From then on the confirm route refuses every test record there, and the session cookie is marked Secure.
  • Run public/index.php under the web server and PHP runtime you deploy, with public/ as the document root. The built-in server is for development: PHP's manual says it should not be used on a public network and that it runs one single-threaded process. This page was run under the built-in server only.
  • Use php.ini-production as your php.ini. In the test, with no php.ini, a warning was printed into the JSON a route answered. The production file sets display_errors = Off and log_errors = On. It also sets variables_order = "GPCS", which getenv() does not depend on.
  • Session data is a file on the machine that answered. With more than one machine, keep the pinned versions in your database, and store the record ID and the receipt beside the user either way.

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

  • missing_api_key from /api/ceremony. The PHP process has no ESIGNCOMPLY_API_KEY: PHP does not read .env, and getenv() sees only the environment of the process. Run set -a; . ./.env; set +a in the shell that starts PHP. The route answers 502. See missing_api_key.
  • domain_mismatch from /api/ceremony. context.url is built from the Origin or Host header, and that host is not on the test allowlist. Test keys work on localhost and 127.0.0.1 at any port. Add other hosts under Domains in the dashboard. See domain_mismatch.
  • 429 when the confirm route reads the record. esc waits for the seconds in Retry-After, 1 at least and 5 at most, and sends the request again, up to twice. Nothing else is retried. In the test, four confirmations sent at once from the session that signed all answered 200. The API's log showed why: the fourth read got 429 and passed on the next attempt, a second later. The same burst against the code without the retry got 409 twice. See rate_limit_exceeded.

Questions about the PHP quickstart

Does the quickstart need Composer?

No. There is no Composer package for Esign Comply, and the project has no composer.json. The three API calls are made with the curl extension, and the session is PHP's own. The server SDK exists for Node.js only.

Why is $_ENV empty when getenv() returns the key?

Because of variables_order. PHP fills $_ENV only when that setting contains an E. The built-in default is EGPCS, and both php.ini files that PHP 8.5.13 ships set GPCS. When this was tested with GPCS, $_ENV did not hold the key and getenv() returned it.

Why did an edit of a PHP file not show at once?

Because of OPcache. Under the built-in server of PHP 8.5.13 it was on, with opcache.revalidate_freq at 2. In the test a request sent right after an edit still ran the old code, and a request three seconds later ran the new code.

Why does the conformance check need Node.js?

The checker is the esigncomply command line tool, which is a Node.js package. It drives a headless browser against your page, whatever language serves it. Install it in a folder of its own, as step 7 shows, and your PHP project stays free of Node.js files.

Does the PHP quickstart need a domain or a card?

No. Test mode works on localhost with a test key, no card and no domain. You register and verify a domain only when you go live, and the Free plan then records 10 live signatures a month.

Next steps

Run on 2026-11-26 with PHP 8.5.13 and its curl extension (cURL 8.23.0), no framework and no Composer package, under PHP's built-in web server with a router script (in the official Composer container image), with the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode.

Last updated · API version 2026-11-21