Skip to content
Stack · Spring Boot

Add e-signatures and clickwrap to Spring Boot

To add e-signatures and clickwrap to Spring Boot, call the REST API with RestClient: there is no Java package, because the server SDK exists for Node.js only. One controller method creates the session with the secret key and keeps the pinned versions in the HttpSession, 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 Esign Comply artifact: spring-boot-starter-webmvc and spring-boot-starter-restclient

Spring Boot quickstart

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

Last updated

Run in Spring Boot before publishing
src/main/java/com/example/quickstart/SignupController.java (excerpt)
// Step 4: create the session with the secret key. The browser gets the client token only.
@PostMapping("/api/ceremony")
@ResponseBody
ResponseEntity<Map<String, Object>> ceremony(HttpServletRequest request) {
	// The page that runs the ceremony: the origin the browser reports, or the scheme and host the server saw.
	String origin = request.getHeader(HttpHeaders.ORIGIN);
	if (origin == null) {
		origin = ServletUriComponentsBuilder.fromContextPath(request).build().toUriString();
	}
	Answer<Session> answer = this.esc.call(HttpMethod.POST, "/sessions", Session.class, Map.of(
			"profile", this.profileId,
			"signer", SIGNER,
			"documents", List.of(
					Map.of("document", this.documents.get("terms"), "version", "current"),
					Map.of("document", this.documents.get("privacy"), "version", "current")),
			"context", Map.of("url", origin + "/signup", "locale", "en-US", "purpose", "account_signup")),
			"signup-" + SIGNER.get("external_id") + "-" + UUID.randomUUID());
	Session created = answer.body();
	if (answer.status() != 201) {
		String code = (created != null && created.error() != null) ? created.error().code() : "unknown";
		return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body(Map.of("error", code));
	}

	// Server-owned state: the servlet session. The data stays in the memory of this server,
	// and the browser holds only the session ID in the JSESSIONID cookie.
	HttpSession session = request.getSession();
	session.setAttribute("signerId", SIGNER.get("external_id"));
	session.setAttribute("versionIds", created.documents().findValuesAsString("version_id").stream().sorted().toList());
	// The documents go to the browser as the API sent them: a JsonNode is written unchanged.
	return ResponseEntity.ok(Map.of("clientToken", created.clientToken(), "apiUrl", created.apiUrl(), "documents", created.documents()));
}
Integrate with Spring Boot

How do you integrate Esign Comply with Spring Boot?

In Spring Boot the integration is one @Controller and one component around RestClient, built from the RestClient.Builder that Spring Boot provides. Records with @JsonNaming read the API's snake_case fields, the environment variable ESIGNCOMPLY_API_KEY is bound to the property esigncomply.api.key, and the HttpSession keeps the pinned versions on the server.

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run".

Source: spring.io, Spring Boot, read on .
Where each part lives in Spring Boot
  • Session methodsrc/main/java/com/example/quickstart/SignupController.java
  • The API callsrc/main/java/com/example/quickstart/EsignComply.java
  • Confirm methodsrc/main/java/com/example/quickstart/SignupController.java
  • Propertiessrc/main/resources/application.properties

Run on 2026-11-26 with Spring Boot 4.2.0 (Spring Framework 7.1.0, Tomcat 11.0.27, Jackson 3.1.8) on Java 25.0.5.1 with Maven 3.10.2, RestClient on the JDK HttpClient and no Esign Comply artifact, under mvn spring-boot:run and as the packaged jar (in the official Maven container image), with the browser SDK script build and the conformance check from esigncomply 1.0.4, against the API in test mode. The test API ran on this machine over plain http, where the JDK HttpClient asks the server to upgrade to HTTP/2 and that server closes the connection, so the app's calls went through a local HTTP/1.1 pass-through with the source unchanged. Its calls over https, where HTTP/2 is negotiated differently, were not run.

Copy-paste prompt

What prompt adds Esign Comply clickwrap to a Spring Boot 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 Spring Boot, 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 Spring Boot
Add Esign Comply clickwrap to my Spring Boot 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/spring-boot.md (the steps and the tested code for Spring Boot)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)

Spring Boot facts
- There is no Esign Comply package for Java. 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 a RestClient built from the RestClient.Builder that Spring Boot provides.
- 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, which Spring Boot binds to the property esigncomply.api.key. Spring Boot does not read .env files on its own. Never write the key into application.properties. Never print the key.
- retrieve() throws on 4xx and 5xx. Use exchange() and read the status before you read the record.
- The API's JSON is snake_case. Put @JsonNaming(SnakeCaseStrategy.class) on the records that read it. Do not set spring.jackson.property-naming-strategy for the whole app: it renames the app's own JSON too. On Spring Boot 4 the Jackson imports are tools.jackson.databind.
- Keep the signer ID and the pinned version IDs in the HttpSession, or in the store the project already has. Read it with request.getSession(false) in the confirm route. Set server.servlet.session.cookie.same-site.
- Return the document HTML with the content type text/html, unmodified. In a Thymeleaf template that is th:utext: th:text escapes it.
- Without Spring Security there is no CSRF check. If the project has Spring Security, send its CSRF token with both POST requests.
- 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. Controller method for POST /api/ceremony: call POST /v1/sessions with an Idempotency-Key, save the signer ID and the pinned version IDs in the HttpSession, and return only clientToken, apiUrl and documents.
4. Controller method 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. Controller method 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 HttpSession. 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:8080/signup --callback http://localhost:8080/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 Spring Boot?

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

  • 01

    RestClient.retrieve() throws on a refusal from the API

    Spring's documentation says RestClient throws a subclass of RestClientException when retrieving a response with a 4xx or 5xx status code. In the test on Spring Boot 4.2.0 a made-up record ID threw HttpClientErrorException$NotFound. The quickstart calls exchange(), which handed back status 404 and the error envelope, so the confirm method answers 409 and not 500.

    Source: Spring Framework reference, REST Clients, read on .
  • 02

    Jackson leaves snake_case fields null, and a global strategy renames your own JSON

    Spring Boot's documentation says Jackson 3 is the preferred and default library. In the test it read the API's answer into a record with clientToken left null and nothing thrown. With spring.jackson.property-naming-strategy=SNAKE_CASE for the whole app, the confirm route stopped reading recordId from the page. The quickstart puts @JsonNaming(SnakeCaseStrategy.class) on the records that read the API.

    Source: Spring Boot reference, JSON, read on .
  • 03

    The JSESSIONID cookie has no SameSite attribute until you set one

    In the test on Tomcat 11.0.27 the session cookie was JSESSIONID, with Path=/ and HttpOnly and nothing else. With server.servlet.session.cookie.same-site=lax in application.properties it carried SameSite=Lax. A method parameter of type HttpSession gave a new session to a caller with no cookie, so the confirm method calls getSession(false).

Verifiable

What does Esign Comply record for a signature in Spring Boot?

The same record on every stack and platform. Your Spring Boot 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 Spring Boot

Is there an Esign Comply SDK for Spring Boot?

No. The server SDK exists for Node.js only, and there is no Maven artifact. A Spring Boot app calls the REST API directly with the secret key, and the quickstart does it with RestClient and Jackson. The browser side is the same SDK as on every stack, loaded from a script tag.

Where do I create the session in Spring Boot?

In a controller method mapped with @PostMapping to /api/ceremony, with a POST to /v1/sessions that carries the secret key and an Idempotency-Key. The method saves the pinned versions in the HttpSession and returns only the client token, the API URL and the documents.

How does ESIGNCOMPLY_API_KEY become a Spring Boot property?

By its name. Spring Boot binds the environment variable to the property esigncomply.api.key, which the quickstart reads with @Value. In the test the variable also answered to esigncomply.api-key and not to esigncomply.apiKey. Spring Boot did not read .env: with the variables missing, the session route answered 502 with missing_api_key.

Do the POST routes need a CSRF token without Spring Security?

No. CSRF protection belongs to Spring Security, and the quickstart does not add it. In the test a POST with no token and the Origin of another site reached the confirm method, which refused the made-up record with 409. If your app has Spring Security, send its token with both requests.

Which property makes Spring Boot trust X-Forwarded-Proto?

server.request.header.forwarded.strategy, set to web-server or framework. In the test on Spring Boot 4.2.0 a request with X-Forwarded-Proto: https was seen as http by default and as https with either value. The older name server.forward-headers-strategy still worked, and the metadata of 4.2.0 marks it deprecated.

Add one controller to your Spring Boot app. Leave the record to us.

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

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

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