Skip to content
Stack · Symfony

Add e-signatures and clickwrap to Symfony

To add e-signatures and clickwrap to Symfony, call the REST API from a controller with symfony/http-client: there is no bundle, because the server SDK exists for Node.js only. One action creates the session with the secret key and pins the versions in the Symfony session, and another confirms the record. Esign Comply seals each acceptance as an independent record.

Follow the quickstart and each signature is a valid electronic signature under the U.S. ESIGN Act, state UETA laws and New York's ESRA, and each clickwrap is built the way courts require: clear notice of the terms, an unmistakable act of assent, and a sealed record of both.

No bundle to install: composer require symfony/http-client symfony/twig-bundle

Symfony quickstart

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

Last updated

Run in Symfony before publishing
src/Controller/SignupController.php (excerpt)
// 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']]);
}
Integrate with Symfony

How do you integrate Esign Comply with Symfony?

In Symfony the client is configuration: a scoped client in framework.yaml carries the API address, the key from .env.local and retry_failed for the rate limit. One controller with route attributes holds the four routes, the session holds the versions the server pinned, and a Twig template prints the registered document with the raw filter.

Symfony is a powerful PHP framework that empowers developers to build scalable, high-performance web applications with reusable components, comprehensive documentation, and a strong community.

Source: symfony.com, read on .
Where each part lives in Symfony
  • Session actionsrc/Controller/SignupController.php
  • Scoped clientconfig/packages/framework.yaml
  • The API callsrc/Controller/SignupController.php
  • Confirm actionsrc/Controller/SignupController.php

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.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a Symfony app?

Paste this into Cursor, Claude Code or the AI coding tool that is open on your project. It names the packages that exist, where the secret key goes in Symfony, what to build and what never to do, and it ends with the rules block for your project.

The rules block lives at /rules.md. Added to your project's instruction file, it makes every later session build signing and acceptance flows the same way. The prompt generator writes the long version, with your own document and profile IDs.

Pages for each AI tool
Prompt: Esign Comply clickwrap in Symfony
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
3 things to watch

What goes wrong when you add e-signatures in Symfony?

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

  • 01

    retry_failed waits as long as Retry-After says

    Symfony's documentation says failed requests are retried with an exponential delay, for 429 among other codes. In the test on Symfony 8.1.12 the header won over that delay, and max_delay did not cap it: with max_delay at 1 second and Retry-After: 3, the calls came 3.00 seconds apart. With Retry-After: 30 and max_duration: 10, the call ended after 10.0 seconds with Max duration was reached. The quickstart sets max_duration for that reason.

    Source: Symfony documentation, HTTP Client, read on .
  • 02

    composer dump-env prod writes the secret key into .env.local.php

    Symfony's documentation says the command parses all .env files and dumps their final values to .env.local.php, which Symfony then loads instead. In the test that file held ESIGNCOMPLY_API_KEY in plain text with mode 644, and a later change in .env.local was not read until the file was deleted. The skeleton's .gitignore lists the file.

    Source: Symfony documentation, Configuring Symfony, read on .
  • 03

    Without trusted proxies Symfony ignores X-Forwarded-Proto and X-Forwarded-Host

    Symfony's documentation says you get incorrect information about HTTPS and the requested host until you tell it which proxies to trust. In the test, getSchemeAndHttpHost() stayed on http and localhost with both headers sent, and the session cookie was not Secure. With SYMFONY_TRUSTED_PROXIES and SYMFONY_TRUSTED_HEADERS set, it returned https://app.example and the cookie was Secure. The quickstart builds context.url from that method.

    Source: Symfony documentation, Behind a Proxy, read on .
Verifiable

What does Esign Comply record for a signature in Symfony?

The same record on every stack and platform. Your Symfony code creates the session and confirms the record, and the browser SDK reports what happened on the page. Esign Comply seals the result where your code cannot change it. The record itself is described on Evidence and verification.

  • Observed and asserted fields

    Every field is tagged. Observed is what the browser SDK and the API saw: the box unchecked at load, the tick from a trusted user event, the notice text, the terms version by hash, the server time. Asserted is what your app said, such as the user's email.

  • A signed receipt

    complete() returns a receipt signed with ES256, using keys you do not hold. Your server stores it next to the user, and GET /v1/records/{id}/receipt returns it again.

  • An external timestamp

    An outside authority timestamps the hash of every live record (RFC 3161), so the time on the record does not rest on your clock or on ours.

  • An offline verifier

    Each record has an evidence report (PDF) and an evidence package (ZIP). Anyone you send the package to checks the acceptance with the open-source esigncomply-verify, without an account.

Recordrec_Z4m8
simple · L1
RecordedWritten durably, receipt signed with ES256
TimestampedExternal RFC 3161 token over the record hash
AnchoredPublic anchor pending
Checkbox changed by a trusted user eventobserved
Terms of Service, version dv_3kT9observed
Server time 2026-11-21T15:03:20.291Zobserved
Signer email dana@example.orgasserted
record_hash sha256:5be7…example record

Questions about e-signatures in Symfony

Is there an Esign Comply SDK for Symfony?

No. There is no bundle and no Composer package, because the server SDK exists for Node.js only. A Symfony app calls the REST API directly with the secret key, and the quickstart does it with symfony/http-client and a scoped client in framework.yaml.

Where do I create the session in Symfony?

In a controller action with #[Route('/api/ceremony', methods: ['POST'])], with a POST to /v1/sessions that carries the secret key and an Idempotency-Key. The action saves the pinned versions in the session and returns only the client token, the API URL and the documents as JSON.

Does Symfony's HttpClient honour Retry-After on a 429?

Yes, with retry_failed. In the test against a stand-in that answered 429 with Retry-After: 2, the three calls arrived 2.00 seconds apart with the same Idempotency-Key. Four confirmations sent at once all answered 200: the API's log showed one read refused with 429 and passed on the next attempt.

Does Symfony apply CSRF protection to the confirm route?

No. Symfony checks a CSRF token in its forms and where you ask for one, and the skeleton does not install symfony/security-csrf. In the test a POST with the session cookie and Origin: https://evil.example was answered 200. What refuses a forged confirmation is the route's own four checks.

Does the key belong in .env or in .env.local?

In .env.local. Symfony's skeleton lists that file in .gitignore, and the header of .env says not to define production secrets in a committed file. In the test Symfony read .env.local itself, and a real environment variable with the same name won over it.

Add one controller to your Symfony app. Leave the record to us.

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

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

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