# Add e-signatures and clickwrap to Laravel

> Add e-signatures and clickwrap to Laravel with one controller and the Http facade: POST /v1/sessions, GET /v1/records, config() and the CSRF token.

Source: https://esigncomply.com/laravel

Stack · Laravel

To add e-signatures and clickwrap to Laravel, call the API from a controller with Laravel's `Http` client: there is no Composer package, because the server SDK exists for Node.js only. One action creates the session with the secret key and pins the versions in the 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.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/laravel)

No package to install: Laravel's HTTP client is enough

[Laravel quickstart](https://esigncomply.com/docs/quickstart/laravel)

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

Last updated November 26, 2026

Run in Laravel before publishing

**Session action**

app/Http/Controllers/SignupController.php (excerpt)

```php
// Step 4: create the session with the secret key. The browser gets the client token only.
public function ceremony(Request $request)
{
    $origin = $request->header('Origin') ?? $request->getSchemeAndHttpHost();
    $session = $this->esc()
        ->withHeaders(['Idempotency-Key' => 'signup-'.self::SIGNER['external_id'].'-'.Str::uuid()])
        ->post('/sessions', [
            'profile' => config('esigncomply.profile'),
            'signer' => self::SIGNER,
            'documents' => [
                ['document' => config('esigncomply.documents.terms'), 'version' => 'current'],
                ['document' => config('esigncomply.documents.privacy'), 'version' => 'current'],
            ],
            'context' => ['url' => "$origin/signup", 'locale' => 'en-US', 'purpose' => 'account_signup'],
        ]);
    if ($session->status() !== 201) {
        return response()->json(['error' => $session->json('error.code')], 502);
    }

    // The Laravel session is stored on the server: the browser holds only its ID, in an encrypted cookie.
    $request->session()->put('pinned_versions', collect($session['documents'])->pluck('version_id')->sort()->values()->all());

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

**Config file**

`config/esigncomply.php`

```php
<?php
// config/esigncomply.php

return [
    'url' => env('ESIGNCOMPLY_API_URL', 'https://esigncomply.com/v1'),
    'key' => env('ESIGNCOMPLY_API_KEY'),
    'live' => env('ESIGNCOMPLY_LIVE', false), // set ESIGNCOMPLY_LIVE=true in production only
    'profile' => env('ESIGNCOMPLY_PROFILE_ID'),
    'documents' => [
        'terms' => env('ESIGNCOMPLY_TERMS_ID'),
        'privacy' => env('ESIGNCOMPLY_PRIVACY_ID'),
    ],
];
```

**Confirm action**

app/Http/Controllers/SignupController.php (excerpt)

```php
// Step 6: confirm the record with the secret key before the account exists.
public function confirm(Request $request)
{
    // An empty or malformed body carries no record ID. Refuse it here: an empty ID would ask the API for the list of records.
    $recordId = $request->input('recordId');
    if (! is_string($recordId) || $recordId === '') {
        return response()->json(['confirmed' => false], 409);
    }

    $record = $this->esc()->get('/records/'.rawurlencode($recordId));
    $confirmed = $record->ok()
        && in_array($record->json('status'), self::SEALED, true) // null when the answer is not a record
        && $record['livemode'] === (bool) config('esigncomply.live')
        && $record['signer']['external_id'] === self::SIGNER['external_id']
        && collect($record['documents'])->pluck('version_id')->sort()->values()->all() === $request->session()->get('pinned_versions');
    Log::info($confirmed ? "confirmed {$record['id']} ({$record['status']})" : 'refused');
    if (! $confirmed) {
        return response()->json(['confirmed' => false], 409);
    }

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

Integrate with Laravel

## How do you integrate Esign Comply with Laravel?

In Laravel the integration is one controller, one config file and two Blade views. The `Http` facade makes the calls, the session holds the versions the server pinned, and the routes sit in `routes/web.php`, where they carry the session and the request forgery check.

Laravel is a framework for building modern web apps and AI agents.

Source: [laravel.com](https://laravel.com/docs/13.x), read on November 24, 2026.

[Laravel quickstart](https://esigncomply.com/docs/quickstart/laravel) · [All stacks](https://esigncomply.com/stacks)

Where each part lives in Laravel

- **Session action** · `app/Http/Controllers/SignupController.php`
- **Config file** · `config/esigncomply.php`
- **Confirm action** · `app/Http/Controllers/SignupController.php`

Run on 2026-11-26 with Laravel 13.44.1 on PHP 8.5.13 (the official Composer container image), under php artisan serve, 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 Laravel 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 Laravel, 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](https://esigncomply.com/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](https://esigncomply.com/product/prompt-generator) writes the long version, with your own document and profile IDs.

[Pages for each AI tool](https://esigncomply.com/build)

Prompt: Esign Comply clickwrap in Laravel

```
Add Esign Comply clickwrap to my Laravel 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/laravel.md (the steps and the tested code for Laravel)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Laravel facts
- There is no Esign Comply Composer package. Do not install or invent one. A controller calls the REST API at https://esigncomply.com/v1 with the Http facade, withToken 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. Read it through a config file and config(), never with env() in a controller: env() returns null once the configuration is cached. Never print the key.
- Define the routes in routes/web.php, so they carry the session and the request forgery check. The page sends the token from the csrf-token meta tag in the X-CSRF-TOKEN header.
- Keep the pinned version IDs in the session.
- Print the registered document HTML with {!! !!}. With {{ }} Blade 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 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 server-owned state. 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 Laravel?

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

- **env() returns null once the configuration is cached**

  Laravel's documentation says to call `env` only from configuration files, because a cached configuration no longer loads `.env`. In the test, `env('ESIGNCOMPLY_API_KEY')` returned null after `php artisan config:cache` while `config('esigncomply.key')` still held the key. The quickstart reads every value through `config()`.

  Source: [Laravel documentation, Configuration](https://laravel.com/docs/13.x/configuration), read on November 24, 2026.

- **Blade escapes the document unless you print it with {!! !!}**

  The document page has to show the registered HTML unmodified. In the test, the view with `{{ $html }}` returned `&lt;h1&gt;Terms of Service`, with every tag visible as text, and the same view with `{!! $html !!}` returned the document.

- **A POST from outside the browser needs the CSRF token**

  Laravel 13 lets a same-origin request from a modern browser through on its `Sec-Fetch-Site` header and falls back to the token otherwise. In the test run a POST from `curl` with no token was answered `419`. The page sends the token from the meta tag in `X-CSRF-TOKEN`, which covers both cases.

  Source: [Laravel documentation, CSRF Protection](https://laravel.com/docs/13.x/csrf), read on November 24, 2026.

## Where are the Laravel quickstart and the API reference?

Start with the quickstart: it carries every file this page excerpts, in the order you write them.

- Quickstart

  **[Laravel quickstart](https://esigncomply.com/docs/quickstart/laravel)**

  Step by step, from install to your first sealed test record, with every file and the output of each step.

- Reference

  **[API reference](https://esigncomply.com/docs/api)**

  Every endpoint, field and error code. Sessions, records and documents are the three this page uses.

- Long guide

  **[Clickwrap in Laravel](https://esigncomply.com/guides/laravel-clickwrap)**

  The full registration flow: a model that stores the acceptance, the controllers, the Blade form and the webhook.

- Guide

  **[Server confirmation](https://esigncomply.com/docs/guides/server-confirmation)**

  The one place access is granted: what to compare, and the webhook that backs the check up.

Verifiable

## What does Esign Comply record for a signature in Laravel?

The same record on every stack and platform. Your Laravel 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](https://esigncomply.com/product/evidence).

- **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.

[How sealing and verification work](https://esigncomply.com/product/evidence) · [Observed and asserted, in the docs](https://esigncomply.com/docs/concepts/observed-and-asserted) · [The offline verifier](https://esigncomply.com/docs/sdk/verify)

Record

`rec_Z4m8`

simple · L1

Recorded

Written durably, receipt signed with ES256

Timestamped

External RFC 3161 token over the record hash

Anchored

Public anchor pending

Checkbox changed by a trusted user event · observed

Terms of Service, version dv_3kT9 · observed

Server time 2026-11-21T15:03:20.291Z · observed

Signer email dana@example.org · asserted

record_hash sha256:5be7… · example record

## Questions about e-signatures in Laravel

### Is there an Esign Comply SDK for Laravel?

No. There is no Composer package, because the server SDK exists for Node.js only. A Laravel app calls the REST API directly with the secret key, and the quickstart does it with the `Http` facade. `composer.json` does not change.

### Where do I create the session in Laravel?

In a controller action behind `POST /api/ceremony`, with a call to `POST /v1/sessions` that carries the secret key and an `Idempotency-Key`. Define the route in `routes/web.php`, so the action has the session, and return only the client token, the API URL and the pinned documents.

### Why read the key with config() and not env()?

Because `env()` stops returning values from `.env` once the configuration is cached, which Laravel recommends for production. In the test it returned null after `php artisan config:cache`. A value read in `config/esigncomply.php` is part of the cache and stays available.

### Does Laravel 13 still need the CSRF token on the fetch calls?

Send it. Laravel 13 accepts a same-origin request from a modern browser on its `Sec-Fetch-Site` header, and checks the token whenever that header does not settle it. With the token in `X-CSRF-TOKEN` the page works in both cases.

### Where does Laravel keep the session by default?

In the database. A new Laravel 13 app sets `SESSION_DRIVER=database`, and `composer create-project` creates the SQLite file and runs the migrations. The browser holds a cookie that was `HttpOnly` in the test run, not the pinned versions themselves.

### Other stacks

- [Rails](https://esigncomply.com/rails)
- [Django](https://esigncomply.com/django)
- [Express](https://esigncomply.com/express)

### Platforms used with Laravel

- [Supabase](https://esigncomply.com/supabase)
- [Vercel](https://esigncomply.com/vercel)

[All stacks](https://esigncomply.com/stacks) · [All platforms](https://esigncomply.com/platforms) · [Clickwrap API](https://esigncomply.com/clickwrap) · [E-signature API](https://esigncomply.com/sign)

## Add one controller to your Laravel app. Leave the record to us.

[Get an API key](https://esigncomply.com/signup) · [Read the docs](https://esigncomply.com/docs/quickstart/laravel)

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

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

---

Every page on esigncomply.com has a Markdown version at the same URL plus `.md` (the home page is `https://esigncomply.com/index.md`). https://esigncomply.com/llms.txt lists them.

---

Esign Comply is the e-signature API and clickwrap API for developers who build their own signing flow in their own UI: it supplies the ceremony rules as a generated prompt for AI coding tools, records events in direct browser ceremonies, and seals independent, verifiable evidence.
