Add e-signatures and clickwrap to Go
To add e-signatures and clickwrap to Go, call the REST API with net/http: there is no Go package, because the server SDK exists for Node.js only. One handler creates the session with the secret key, another confirms the record, and the browser SDK attaches to your own form. Esign Comply seals each acceptance as an independent, verifiable 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 package to install: net/http is enough
Go 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. mux.HandleFunc("POST /api/ceremony", func(w http.ResponseWriter, r *http.Request) { origin := r.Header.Get("Origin") if origin == "" { origin = "http://" + r.Host } attempt := make([]byte, 8) rand.Read(attempt) var created session status, err := esc("POST", "/sessions", map[string]any{ "profile": os.Getenv("ESIGNCOMPLY_PROFILE_ID"), "signer": signer, "documents": []map[string]string{ {"document": documents["terms"], "version": "current"}, {"document": documents["privacy"], "version": "current"}, }, "context": map[string]string{"url": origin + "/signup", "locale": "en-US", "purpose": "account_signup"}, }, "signup-"+signer["external_id"]+"-"+hex.EncodeToString(attempt), &created) if err != nil || status != http.StatusCreated { writeJSON(w, http.StatusBadGateway, map[string]string{"error": created.Error.Code}) return } mu.Lock() pinned[signer["external_id"]] = versionIDs(created.Documents) mu.Unlock() writeJSON(w, http.StatusOK, map[string]any{"clientToken": created.ClientToken, "apiUrl": created.APIURL, "documents": created.Documents}) })
// esc makes one call to the Esign Comply API and decodes the JSON answer into out. // It returns the HTTP status: a refused call is an answer to read, not an error. func esc(method, path string, body any, idempotencyKey string, out any) (int, error) { var payload io.Reader if body != nil { encoded, err := json.Marshal(body) if err != nil { return 0, err } payload = bytes.NewReader(encoded) } req, err := http.NewRequest(method, api+path, payload) if err != nil { return 0, err } req.Header.Set("Authorization", "Bearer "+os.Getenv("ESIGNCOMPLY_API_KEY")) if body != nil { req.Header.Set("Content-Type", "application/json") } if idempotencyKey != "" { req.Header.Set("Idempotency-Key", idempotencyKey) } var res *http.Response for attempt := 0; ; attempt++ { if res, err = client.Do(req); err != nil { return 0, err } // Over the rate limit: wait for Retry-After (5 seconds at most) and try again, twice at most. Nothing else is retried. if res.StatusCode != http.StatusTooManyRequests || attempt == 2 { break } res.Body.Close() seconds, _ := strconv.Atoi(res.Header.Get("Retry-After")) time.Sleep(time.Duration(min(max(seconds, 1), 5)) * time.Second) if req.GetBody != nil { req.Body, _ = req.GetBody() // NewRequest kept the encoded body: a fresh reader for the next attempt } } defer res.Body.Close() return res.StatusCode, json.NewDecoder(res.Body).Decode(out) }
// Step 6: confirm the record with the secret key before the account exists. mux.HandleFunc("POST /api/signup/confirm", func(w http.ResponseWriter, r *http.Request) { var claim struct { RecordID string `json:"recordId"` } json.NewDecoder(r.Body).Decode(&claim) var rec record status, err := esc("GET", "/records/"+url.PathEscape(claim.RecordID), nil, "", &rec) mu.Lock() expected := pinned[signer["external_id"]] mu.Unlock() confirmed := err == nil && status == http.StatusOK && // an error envelope decodes into an empty record: check the status first slices.Contains(sealed, rec.Status) && rec.Livemode == live && rec.Signer.ExternalID == signer["external_id"] && len(expected) > 0 && slices.Equal(versionIDs(rec.Documents), expected) if !confirmed { log.Println("refused") writeJSON(w, http.StatusConflict, map[string]bool{"confirmed": false}) return } log.Printf("confirmed %s (%s)", rec.ID, rec.Status) // Only now create the account, and store the record ID and the receipt with it. writeJSON(w, http.StatusOK, map[string]any{"confirmed": true, "recordId": rec.ID}) })
How do you integrate Esign Comply with Go?
In Go the whole client is one function over net/http and encoding/json, and go.mod lists no dependency. The routes are http.ServeMux patterns with a method, the signup page is compiled into the binary with /, and a map behind a mutex holds what the server pinned.
The Go project describes Go as an open-source programming language for building simple, secure, scalable systems.
Source: go.dev, read on .- Session handlermain.go
- The API callmain.go
- Confirm handlermain.go
Run on 2026-11-26 with Go 1.27.4 and its standard library only, 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 Go 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 Go, 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 Go 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/go.md (the steps and the tested code for Go)
- https://esigncomply.com/setup.md (the order of API calls)
- https://esigncomply.com/auth.md (how to handle the keys)
Go facts
- There is no Esign Comply package for Go. Do not install or invent one. The server calls the REST API at https://esigncomply.com/v1 with net/http, Authorization: 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 in the environment variable ESIGNCOMPLY_API_KEY. os.Getenv returns an empty string when it is not set, with no error: check it at startup. Never print the key.
- Use an http.Client with a Timeout. http.DefaultClient has none.
- An error envelope decodes into a record struct with no error and zero values. Check the HTTP status before you read the record.
- 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. Handler for POST /api/ceremony: call POST /v1/sessions with an Idempotency-Key, save the signer ID and the pinned version IDs in server-owned state, and return only clientToken, apiUrl and documents.
4. Handler 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. Handler 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: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.mdWhat goes wrong when you add e-signatures in Go?
These are specific to Go. Each one was seen while the quickstart's code was run, or is in Go's own documentation.
- 01
An error envelope decodes into your struct without an error
json.Decodefills what it finds and leaves the rest at zero. In the test, thenot_foundenvelope decoded into the record struct witherr=nil, an emptyStatusandLivemodeset tofalse, the same value a test record carries. Check the HTTP status before you read the record. - 02
os.Getenv never fails
A variable that is not set comes back as an empty string. In the test run the server started without its environment and answered
502withmissing_api_keyon the first session. Load the variables into the shell that runs the server, and check the key at startup. - 03
http.DefaultClient has no timeout
The
Source: Go documentation, package net/http, read on .net/httpdocumentation says ofClient.Timeout: a Timeout of zero means no timeout. The quickstart creates its own client withTimeout: 10 * time.Second, so a call that hangs cannot hold a signup open.
Where are the Go quickstart and the API reference?
Start with the quickstart: it carries every file this page excerpts, in the order you write them.
- QuickstartGo 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 Go?
The same record on every stack and platform. Your Go 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 Go
Is there an Esign Comply SDK for Go?
No. The server SDK exists for Node.js only. A Go server calls the REST API directly with the secret key, and the quickstart does it with net/http and encoding/json from the standard library. The browser side is the same SDK as on every stack.
Where do I create the session in Go?
In the handler behind your signing page, for example POST /api, with a POST to /v1 that carries the secret key and an Idempotency-Key. The handler returns only the client token, the API URL and the pinned documents.
Which Go version do the route patterns need?
Go 1.22 or later. The quickstart writes its routes as POST /api and GET /legal, the method and wildcard patterns that came to net/http in Go 1.22. It was run on Go 1.27.4, where a GET to a POST route was answered 405.
Does the Go server use any third-party module?
No. The quickstart's go.mod has a module line and a Go version, and nothing else. The HTTP client, the router, JSON and the embedded page all come from the standard library.
Why check the HTTP status before decoding the record in Go?
Because a refused call decodes cleanly. The error envelope has none of the record's fields, so the struct keeps its zero values and Livemode reads false, as it does on a test record. The quickstart requires status 200 first.
Call the API from the Go server you already run. Leave the record to us.
Free plan: 10 live signatures a month and a full test mode. No card required.
Go is a trademark of its owner. Esign Comply is not affiliated with it. What this page says about Go is from Go's documentation or from a test run, as marked, on . /go.md is this page as Markdown.