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 quickstartFree plan: 10 live signatures a month and a full test mode. No card required.
Last updated
// 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']]); }
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/** 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)]; }
// 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']]); }
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 .- 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.
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 toolAdd 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.mdWhat 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
Source: Symfony documentation, HTTP Client, read on .429among other codes. In the test on Symfony 8.1.12 the header won over that delay, andmax_delaydid not cap it: withmax_delayat 1 second andRetry-After: 3, the calls came 3.00 seconds apart. WithRetry-After: 30andmax_duration: 10, the call ended after 10.0 seconds withMax duration was reached. The quickstart setsmax_durationfor that reason. - 02
composer dump-env prod writes the secret key into .env.local.php
Symfony's documentation says the command parses all
Source: Symfony documentation, Configuring Symfony, read on ..envfiles and dumps their final values to.env.local.php, which Symfony then loads instead. In the test that file heldESIGNCOMPLY_API_KEYin plain text with mode644, and a later change in.env.localwas not read until the file was deleted. The skeleton's.gitignorelists the file. - 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,
Source: Symfony documentation, Behind a Proxy, read on .getSchemeAndHttpHost()stayed onhttpandlocalhostwith both headers sent, and the session cookie was notSecure. WithSYMFONY_TRUSTED_PROXIESandSYMFONY_TRUSTED_HEADERSset, it returnedhttps:/and the cookie was/app.example Secure. The quickstart buildscontext.urlfrom that method.
Where are the Symfony quickstart and the API reference?
Start with the quickstart: it carries every file this page excerpts, in the order you write them.
- QuickstartSymfony quickstartStep by step, from install to your first sealed test record, with every file and the output of each step.Open
- ReferenceAPI referenceEvery endpoint, field and error code. Sessions, records and documents are the three this page uses.Open
- GuideServer confirmationThe one place access is granted: what to compare, and the webhook that backs the check up.Open
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, andGET /v1returns it again./records /{id} /receipt 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.
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, with a POST to /v1 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:/ 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.