Skip to content
DocsMenu

Add e-signatures and clickwrap with Symfony

View as Markdown

Open this page inChatGPTClaudeCursor

To add e-signatures and clickwrap with Symfony, call the REST API from a controller with Symfony's HttpClient and the secret key: there is no bundle. One action creates the session and pins the versions in the Symfony session, another confirms the record, and the browser SDK 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 Symfony. For PHP with no framework, use the PHP quickstart. 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 Symfony 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/symfony.md (the steps and the tested code for Symfony)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Symfony facts
- There is no Esign Comply bundle or Composer package. Do not install or invent one. A controller calls the REST API at https://esigncomply.com/v1 with symfony/http-client, auth_bearer and the secret key.
- The browser SDK is a script tag: https://esigncomply.com/sdk/v1/esigncomply.js. It defines the global EsignComply.
- The secret key is ESIGNCOMPLY_API_KEY in .env.local, which is not committed. Never put it in .env, which is. Never print the key.
- Configure a scoped client in config/packages/framework.yaml with base_uri ending in a slash, and request paths without a leading slash: a leading slash drops the /v1 of the base address.
- Read answers with getStatusCode() and toArray(false). Without false, toArray() throws on 4xx and 5xx.
- For the rate limit use retry_failed with http_codes 429 and max_retries 2, and set max_duration: Symfony waits for Retry-After, however long, max_delay does not cap it, and only max_duration ends that wait.
- Keep the signer ID and the pinned version IDs in the session. Call save() on the session before the API call in the action that only reads it: PHP keeps a session locked while it is open.
- Symfony applies no CSRF check to these routes. Never treat reaching a route as proof of where the request came from.
- Print the registered document HTML with the raw filter. Without it Twig escapes the tags and the page no longer matches the registered version.
- 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. Action for POST /api/ceremony: call POST /v1/sessions with an Idempotency-Key, save the signer ID and the pinned version IDs in the session, and return only clientToken, apiUrl and documents.
4. Action for GET /legal/{slug}: 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. Action for POST /api/signup/confirm: call GET /v1/records/{id} and require: status is "recorded", "timestamped" or "anchored"; livemode is as expected; the signer ID and version IDs equal the ones in the 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 8.4 or later and Composer. This page was run on Symfony 8.1.12 with PHP 8.5.13.
  • The Symfony CLI, for the local web server in step 4. Symfony's documentation recommends it for local development, and it ran here with no account and no login.
  • 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

There is no bundle and no package for the API. The server SDK exists for Node.js only, so a Symfony app calls the REST API directly with Symfony's own HTTP client. To follow along in a new app:

composer create-project symfony/skeleton:"8.1.*" esigncomply-quickstart
cd esigncomply-quickstart
composer require symfony/http-client symfony/twig-bundle

The skeleton brings the framework, the session and the routing. symfony/http-client makes the API calls and symfony/twig-bundle renders the two pages. Nothing here installs CSRF protection: step 6 says what that means.

Step 2. Set the key

Symfony reads .env and then .env.local. .env is a file you commit, and its header says not to define production secrets in it. The skeleton lists .env.local in its .gitignore. So the key goes in .env.local:

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

Symfony read the file itself in the test, with nothing loaded into the shell. A real environment variable wins, as the header of .env says: with ESIGNCOMPLY_TERMS_ID set in the environment of the server, Symfony used that value and not the one in .env.local.

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

set -a; . ./.env.local; 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.local. 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 client is configuration. Add a scoped client to config/packages/framework.yaml: the API address, the secret key, the timeouts and the retry.

# see https://symfony.com/doc/current/reference/configuration/framework.html
framework:
    secret: '%env(APP_SECRET)%'

    # Note that the session will be started ONLY if you read or write from it.
    session: true

    #esi: true
    #fragments: true

    http_client:
        scoped_clients:
            # There is no Composer package for the API: this is Symfony's own client, scoped to the API address.
            esigncomply.client:
                base_uri: '%env(ESIGNCOMPLY_API_URL)%/'
                auth_bearer: '%env(ESIGNCOMPLY_API_KEY)%'
                timeout: 10
                # Each attempt may take 10 seconds, the wait before it included.
                max_duration: 10
                # Over the rate limit: Symfony waits for Retry-After and sends the request again, twice at most.
                retry_failed:
                    http_codes: { 429: true }
                    max_retries: 2

when@test:
    framework:
        test: true
        session:
            storage_factory_id: session.storage.factory.mock_file

The API address and the live flag have defaults, in config/services.yaml. The key and the three IDs have none:

# yaml-language-server: $schema=../vendor/symfony/dependency-injection/Loader/schema/services.schema.json

# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.
# See also https://symfony.com/doc/current/service_container/import.html

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
    # Defaults for the two variables that may be left out. The key and the IDs have none: they go in .env.local.
    env(ESIGNCOMPLY_API_URL): 'https://esigncomply.com/v1'
    env(ESIGNCOMPLY_LIVE): 'false'

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/'

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

One controller holds the four routes. Symfony injects the scoped client by its name, $esigncomplyClient:

<?php
// src/Controller/SignupController.php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class SignupController extends AbstractController
{
    private const SEALED = ['recorded', 'timestamped', 'anchored'];

    // The signer. In your app this is the signed-in user, or the account you are about to create.
    private const SIGNER = [
        'external_id' => 'user_7c1d',
        'email' => 'dana@example.org',
        'name' => 'Dana Whitfield',
        'class' => 'consumer',
        'country' => 'US',
        'region' => 'US-CA',
    ];

    public function __construct(
        // The scoped client of config/packages/framework.yaml: the API address, the secret key and the retry on 429.
        private readonly HttpClientInterface $esigncomplyClient,
        #[Autowire(env: 'ESIGNCOMPLY_PROFILE_ID')] private readonly string $profile,
        #[Autowire(env: 'ESIGNCOMPLY_TERMS_ID')] private readonly string $terms,
        #[Autowire(env: 'ESIGNCOMPLY_PRIVACY_ID')] private readonly string $privacy,
        #[Autowire(env: 'bool:ESIGNCOMPLY_LIVE')] private readonly bool $live, // true in production only
    ) {
    }

    /** One call to the Esign Comply API. Returns [status, decoded JSON]. The path has no leading slash. */
    private function esc(string $method, string $path, array $options = []): array
    {
        $response = $this->esigncomplyClient->request($method, $path, $options);

        // false: Symfony does not throw on 4xx and 5xx. The status is here, and the error envelope is the body.
        return [$response->getStatusCode(), $response->toArray(false)];
    }

    #[Route('/signup', methods: ['GET'])]
    public function signup(): Response
    {
        return $this->render('signup.html.twig');
    }

    // The document pages: each one renders a registered version, unmodified.
    #[Route('/legal/{slug}', requirements: ['slug' => 'terms|privacy'], methods: ['GET'])]
    public function legal(string $slug, Request $request): Response
    {
        $document = 'terms' === $slug ? $this->terms : $this->privacy;
        $version = $request->query->getString('v', 'current');
        [$status, $content] = $this->esc('GET', 'documents/'.$document.'/versions/'.rawurlencode($version).'/content');
        if (200 !== $status) {
            throw $this->createNotFoundException();
        }

        return $this->render('legal.html.twig', ['version_id' => $content['version_id'], 'html' => $content['html']]);
    }

    // Step 4: create the session with the secret key. The browser gets the client token only.
    #[Route('/api/ceremony', methods: ['POST'])]
    public function ceremony(Request $request): JsonResponse
    {
        [$status, $session] = $this->esc('POST', 'sessions', [
            'headers' => ['Idempotency-Key' => 'signup-'.self::SIGNER['external_id'].'-'.bin2hex(random_bytes(16))],
            'json' => [
                'profile' => $this->profile,
                'signer' => self::SIGNER,
                'documents' => [
                    ['document' => $this->terms, 'version' => 'current'],
                    ['document' => $this->privacy, 'version' => 'current'],
                ],
                // The page that runs the ceremony: the scheme and host Symfony worked out for this request.
                'context' => ['url' => $request->getSchemeAndHttpHost().'/signup', 'locale' => 'en-US', 'purpose' => 'account_signup'],
            ],
        ]);
        if (201 !== $status) {
            return $this->json(['error' => $session['error']['code'] ?? 'unknown'], 502);
        }

        // Server-owned state: Symfony's session. The data stays on the server, and the browser holds only the session ID.
        $request->getSession()->set('esc_signup', [
            'signer_id' => self::SIGNER['external_id'],
            'version_ids' => array_column($session['documents'], 'version_id'),
        ]);

        return $this->json(['clientToken' => $session['client_token'], 'apiUrl' => $session['api_url'], 'documents' => $session['documents']]);
    }

    // Step 6: confirm the record with the secret key before the account exists.
    #[Route('/api/signup/confirm', methods: ['POST'])]
    public function confirm(Request $request): JsonResponse
    {
        // A body that is not JSON never gets here: getPayload() throws, and Symfony answers 400.
        $recordId = $request->getPayload()->getString('recordId', 'missing');
        $session = $request->getSession();
        $pinned = $session->get('esc_signup', []);
        $session->save(); // close the session now: PHP keeps it locked while it is open, and the API call may wait

        [$status, $record] = $this->esc('GET', 'records/'.rawurlencode($recordId));

        $versions = array_column($record['documents'] ?? [], 'version_id');
        $expected = $pinned['version_ids'] ?? [];
        sort($versions);
        sort($expected);
        $confirmed = 200 === $status
            && \in_array($record['status'], self::SEALED, true)
            && $record['livemode'] === $this->live
            && $record['signer']['external_id'] === ($pinned['signer_id'] ?? null)
            && $versions === $expected;

        error_log($confirmed ? "confirmed {$record['id']} ({$record['status']})" : 'refused');
        if (!$confirmed) {
            return $this->json(['confirmed' => false], 409);
        }

        // Only now create the account, and store $record['id'] and $record['receipt'] with it.
        return $this->json(['confirmed' => true, 'recordId' => $record['id']]);
    }
}

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.

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

base_uri ends in a slash and the paths have no leading slash. In a test, usage went to /v1/usage and was answered 200. /usage went to the root of the host, without /v1, and was answered 404.

toArray(false) reads a refusal instead of throwing it. For a made-up record ID, toArray() threw a ClientException with HTTP/1.1 404 Not Found returned. With false, the same call returned the error envelope with the code not_found.

The retry is Symfony's own. With retry_failed, a 429 is sent again after the seconds in Retry-After, twice at most. Against a stand-in that always answered 429 with Retry-After: 2, the three calls arrived 2.00 seconds apart with the same Idempotency-Key and body, and the route then answered 502 with rate_limit_exceeded. With no header the calls arrived 0.95 and 1.85 seconds apart: Symfony's own delay, 1 second and then 2, with some randomness. max_delay does not cap Retry-After: with max_delay at 1 second and Retry-After: 3, the calls still arrived 3.00 seconds apart. It limits only the delay Symfony computes itself. What ends a long wait is max_duration, which counts it. With Retry-After: 30 the call was sent once and ended after 10.0 seconds with Max duration was reached, and the route answered 500. A call that could not connect was sent three times too: with the API address on a closed port the route answered 500 after 3.2 seconds, and the next request was answered 200.

The variables are injected with #[Autowire(env: ...)]. With ESIGNCOMPLY_API_KEY not defined anywhere, every route of the controller answered 500, /signup included, with Environment variable not found: "ESIGNCOMPLY_API_KEY". With the variable defined and empty, the session route answered 502 with missing_api_key.

The session is Symfony's, on PHP's own session files. The browser got a cookie named PHPSESSID, 32 characters long, HttpOnly and SameSite=Lax. 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. PHP locks a session while it is open, so confirm calls save() before it calls the API. In a test with four PHP workers, a request that kept the session open for two seconds made a second request with the same cookie wait 2 seconds. After save(), the second request did not wait.

context.url is built with getSchemeAndHttpHost(), from what Symfony believes about the request. A request with Host: evil.example was refused by the API with domain_mismatch, and the route answered 502. Headers such as X-Forwarded-Host and X-Forwarded-Proto changed nothing until trusted proxies were configured: step 8 has the details.

Start the local web server of the Symfony CLI in the project folder:

symfony server:start --no-tls
 [OK] Web server listening
      The Web server is using PHP CGI 8.5.13
      http://127.0.0.1:8000

The server ran one php-cgi process here, and it answered one request at a time. In the test, page requests sent while four confirmations were in flight waited 0.6 to 1.8 seconds, because one of the four was waiting to retry.

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 templates/signup.html.twig. It is a Twig template with no Twig tag in it: the script uses single braces, which Twig leaves alone.

<!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_X23uPvWeV4dFna0DYXMN

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. One page load sent one POST /api/ceremony.

Each link opens a document page on your own server that renders the registered version. Its template is templates/legal.html.twig:

<!doctype html><meta charset="utf-8"><article data-esc-document="{{ version_id }}">{{ html|raw }}</article>

Twig escapes every variable it prints, which is right for the version ID and wrong for the document. The raw filter prints the registered HTML as it is. In a test without it, 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. The confirm action 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 action writes one line for each confirmation with error_log(), and the Symfony CLI shows it in its log:

[PHP-CGI    ] [26-Nov-2026 12:42:16 UTC] confirmed rec_X23uPvWeV4dFna0DYXMN (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}

A body that is not JSON never reaches the action: getPayload() threw, Symfony answered 400, and the next request was answered 200.

That request carried no token of any kind. Symfony checks a CSRF token in its forms and where you ask for it, not on a controller route, and the skeleton does not install symfony/security-csrf. In the test, a POST with the session cookie, a real record ID and Origin: https://evil.example was answered 200. What refuses a forged confirmation here is the check itself.

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_MdCdTwFPLuPqgy9FCMMy  session ses_tCSCqJEyjjZXDQUr5VCJ, 5 events
  768x1024   record rec_afuQ4hCXwqmatHFrXvQy  session ses_dY8Sue0oonuSiUt5uix9, 5 events
  1440x900   record rec_BCZwXx5QQpa3xp1dcB8e  session ses_QVgWGrfQdJteN7BEqF1H, 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 APP_ENV=prod as a real environment variable and run APP_ENV=prod APP_DEBUG=0 php bin/console cache:clear. In the test this ran the app in the prod environment, and it recorded the signature shown in step 5. Symfony's deployment guide lists the other tasks.
  • In prod the cache holds your templates and configuration. In the test an edited template was still served as it was six seconds later, and the edit showed only after cache:clear.
  • Set the live key as ESIGNCOMPLY_API_KEY and ESIGNCOMPLY_LIVE=true in production only, as real environment variables or in .env.prod.local. In the test with ESIGNCOMPLY_LIVE=true the confirm route refused a test record with 409.
  • composer dump-env prod copies every value into .env.local.php. In the test that file held the secret key in plain text with mode 644, and a later change in .env.local was not read until the file was deleted.
  • Behind a proxy that terminates TLS, configure trusted proxies. Without them Symfony ignored X-Forwarded-Proto and X-Forwarded-Host in the test: context.url stayed http, and the session cookie was not Secure. With SYMFONY_TRUSTED_PROXIES and SYMFONY_TRUSTED_HEADERS set, Symfony took the scheme and the host from those headers and marked the cookie Secure.
  • Run it under a web server such as Nginx or Apache, as Symfony's documentation says. The Symfony CLI's own start-up message says its server must never be used in a production setup. This page was run under that server only.
  • 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

  • Environment variable not found: "ESIGNCOMPLY_API_KEY" and 500 on every route. The variable is in neither .env.local nor the real environment. Add it to .env.local. With the variable defined and empty, the session route answers 502 with missing_api_key.
  • domain_mismatch from /api/ceremony. context.url is built from the scheme and host Symfony worked out for the request, and that host is not on the test allowlist. Test keys work on localhost and 127.0.0.1 at any port. Behind a proxy, configure trusted proxies so Symfony sees the public host. See domain_mismatch.
  • 429 when the confirm action reads the record. The scoped client carries retry_failed: on 429 Symfony waits for the seconds in Retry-After and sends the request again, up to twice. In the test, four confirmations sent at once from the session that signed all answered 200. The API's log showed why: one read got 429 and passed on the next attempt. See rate_limit_exceeded.
  • The document page shows tags as text. The template prints the HTML without the raw filter, so Twig escapes it. The text then differs from the registered version and the SDK reports CR-08. Print it with {{ html|raw }}.

Questions about the Symfony quickstart

Is there an Esign Comply bundle for Symfony?

No. The server SDK exists for Node.js only. A Symfony app calls the REST API directly, and this quickstart does it with symfony/http-client and a scoped client in framework.yaml. Composer adds the HTTP client and Twig, and nothing for the API.

Why do the paths have no leading slash?

Because a leading slash replaces the path of base_uri. The API lives under /v1. In the test a request for /usage went to the root of the host and was answered with status 404, and usage went to /v1/usage and was answered with status 200.

Do the routes need a CSRF token?

Not for Symfony. It checks a CSRF token in its forms and where you ask for one, and the skeleton does not install the package that does it. In the test a request with the session cookie and the origin of another site was answered with status 200. The confirm route relies on its four checks.

Where does Symfony keep the pinned versions?

In the session, which is a file on the server. In the test it was a file named sess_ plus the ID in /tmp, readable by its owner only, and the browser held a 32-character ID in an HttpOnly cookie. With more than one machine, keep the pinned versions in your database.

Does the quickstart need the Symfony CLI?

Only for the local web server. Symfony's documentation recommends it for local development, and it ran here with no account. In production you run the app under a web server such as Nginx or Apache, and the CLI's own start-up message says its server must never be used there.

Does the Symfony 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 Symfony 8.1.12 from the official skeleton (symfony/http-client 8.1.12, symfony/twig-bundle 8.1.9, Twig 3.31.1) on PHP 8.5.13 with Composer 2.11.2 (the official Composer container image), under the local web server of the Symfony CLI 5.23.0 with PHP CGI, in the dev environment and with APP_ENV=prod, 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