# Add e-signatures and clickwrap with Go

> Build a signup clickwrap in Go with net/http and the standard library only: plain HTTPS calls to the Esign Comply API and a sealed test record.

Source: https://esigncomply.com/docs/quickstart/go

Last updated November 26, 2026

To add e-signatures and clickwrap with Go, call the REST API with `net/http` and the secret key: there is no Go package, and none is needed. One handler creates the session, another confirms the record, and the browser SDK from a script tag attaches to your own checkbox and button. Esign Comply seals each acceptance as an independent record.

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

Paste this prompt into Cursor, Claude Code or another AI coding tool to have it build the same integration:

```text copy="Copy prompt" open="cursor"
Add 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.md
```

The rest of this page is the same integration by hand, in eight steps.

## Before you start

- A test API key. [Create an account](https://esigncomply.com/signup) with your email, no card, then choose **Create test key** in the dashboard. The key is shown once and starts with `esc_test_`. An AI agent with an agent token creates it with `POST /v1/agent/api-keys`: see the [agent account API](https://esigncomply.com/docs/api/agent.md).
- Nothing else from Esign Comply. Test mode works on `localhost` with no card and no domain, and the Free plan includes it in full.
- Go 1.22 or later: the routes use method and wildcard patterns, which `net/http` has had since Go 1.22. This page was run on Go 1.27.4.
- `curl` and `jq` for steps 2 and 3, and Node.js 20.19 or later for the conformance check in step 7.

## Step 1. Install

No package needed. The server SDK exists for Node.js only, so a Go server calls the REST API directly with `net/http` from the standard library. The page loads the browser SDK from a script tag.

```bash
mkdir esigncomply-quickstart && cd esigncomply-quickstart
go mod init example.com/quickstart
mkdir public
```

## Step 2. Set the key

Put the key in `.env` in the project folder. Go does not read this file: you load it into the shell that runs the server, and `main.go` reads the variables with `os.Getenv`.

```bash
# .env (never commit this file)
ESIGNCOMPLY_API_KEY=esc_test_us_...
```

Load the file into your shell for the commands in steps 2, 3 and 7, then check that the key works:

```bash
set -a; . ./.env; set +a
curl -s ${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}/usage \
  -H "Authorization: Bearer $ESIGNCOMPLY_API_KEY" | jq '{plan_name, test_events}'
```

```json
{
  "plan_name": "Free",
  "test_events": {
    "used_this_month": 0,
    "quota_per_month": 500
  }
}
```

A `401` means the key is wrong or revoked: see [`invalid_api_key`](https://esigncomply.com/docs/api/errors.md#invalid_api_key). The rules for handling keys are in [/auth.md](https://esigncomply.com/auth.md).

## Step 3. Register a document version

Every record pins the exact version of each document by hash, so the documents are registered first. This block registers a Terms of Service and a Privacy Notice with one version each, and creates a profile: the Federal pack, a checkbox with a button, level L1. It is the same for every stack and needs `curl` and `jq`.

```bash
ESC=${ESIGNCOMPLY_API_URL:-https://esigncomply.com/v1}
KEY="Authorization: Bearer $ESIGNCOMPLY_API_KEY"
JSON="Content-Type: application/json"

# Two sample documents, one version each.
TERMS=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Terms of Service","type":"terms"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$TERMS/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Terms of Service\n\nThese are sample terms for a test."},"material_change":true}' \
  | jq -r .id; sleep 1
PRIVACY=$(curl -s $ESC/documents -H "$KEY" -H "$JSON" \
  -d '{"name":"Privacy Notice","type":"privacy_notice"}' | jq -r .id); sleep 1
curl -s $ESC/documents/$PRIVACY/versions -H "$KEY" -H "$JSON" \
  -d '{"version_label":"1","language":"en","content":{"format":"markdown","text":"# Privacy Notice\n\nThis is a sample privacy notice for a test."}}' \
  | jq -r .id; sleep 1

# A profile: Federal pack, checkbox plus button, L1.
PROFILE=$(curl -s $ESC/profiles -H "$KEY" -H "$JSON" \
  -d '{"name":"Signup","jurisdictions":["US-FED"],"method":"checkbox","assurance_level":"L1"}' | jq -r .id)

printf 'ESIGNCOMPLY_PROFILE_ID=%s\nESIGNCOMPLY_TERMS_ID=%s\nESIGNCOMPLY_PRIVACY_ID=%s\n' "$PROFILE" "$TERMS" "$PRIVACY"
```

It prints the two version IDs, then three lines with your own IDs:

```text
dv_YiWs9cmWoVSGp7ALPeZS
dv_bAYeA7QigKUH0iLhPpV7
ESIGNCOMPLY_PROFILE_ID=prof_SPVEgBT8a8Ror3mJ8M99
ESIGNCOMPLY_TERMS_ID=doc_bDgYFndAoC8tkeYibAVy
ESIGNCOMPLY_PRIVACY_ID=doc_mb2hnWKS0Qa7SKtucDW9
```

Add the three lines to `.env`, then load the file into your shell again. The pauses keep the script under the Free plan's 2 requests per second. Keep the names `Terms of Service` and `Privacy Notice`: the notice on your page names each document by its registered name, and rule [CR-02](https://esigncomply.com/docs/conformance.md#cr-02) checks that it does. With your own documents, publish the text you already have and change the notice to match. See [Documents](https://esigncomply.com/docs/api/documents.md) and [Profiles](https://esigncomply.com/docs/api/profiles.md).

## Step 4. Create a session on the server

`main.go` is the whole server: the signup page, the two document pages, the handler that creates the session, and the handler that confirms the record. The `esc` function is the entire client: one HTTPS call with the secret key that returns the status and decodes the JSON answer. `POST /api/ceremony` creates the session and returns three values to the browser: the client token, the API URL and the pinned documents.

```go file="main.go"
// main.go
package main

import (
	"bytes"
	"crypto/rand"
	_ "embed"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"net/url"
	"os"
	"slices"
	"strconv"
	"sync"
	"time"
)

// The signup page is compiled into the binary.
//
//go:embed public/signup.html
var signupPage []byte

// There is no Go package: these are plain HTTPS calls with the secret key.
var (
	api       = getenv("ESIGNCOMPLY_API_URL", "https://esigncomply.com/v1")
	client    = &http.Client{Timeout: 10 * time.Second} // http.DefaultClient has no timeout
	live      = os.Getenv("ESIGNCOMPLY_LIVE") == "true" // set it in production only
	sealed    = []string{"recorded", "timestamped", "anchored"}
	documents = map[string]string{
		"terms":   os.Getenv("ESIGNCOMPLY_TERMS_ID"),
		"privacy": os.Getenv("ESIGNCOMPLY_PRIVACY_ID"),
	}
)

// The signer. In your app this is the signed-in user, or the account you are about to create.
var signer = map[string]string{
	"external_id": "user_7c1d",
	"email":       "dana@example.org",
	"name":        "Dana Whitfield",
	"class":       "consumer",
	"country":     "US",
	"region":      "US-CA",
}

// Signer ID -> the version IDs this server pinned. Use a table in your database in production.
var (
	mu     sync.Mutex
	pinned = map[string][]string{}
)

type document struct {
	DocumentID string `json:"document_id"`
	VersionID  string `json:"version_id"`
}

type session struct {
	ClientToken string     `json:"client_token"`
	APIURL      string     `json:"api_url"`
	Documents   []document `json:"documents"`
	Error       struct {
		Code string `json:"code"`
	} `json:"error"`
}

type record struct {
	ID       string `json:"id"`
	Status   string `json:"status"`
	Livemode bool   `json:"livemode"`
	Signer   struct {
		ExternalID string `json:"external_id"`
	} `json:"signer"`
	Documents []document `json:"documents"`
}

type content struct {
	VersionID string `json:"version_id"`
	HTML      string `json:"html"`
}

func getenv(key, fallback string) string {
	if value := os.Getenv(key); value != "" {
		return value
	}
	return fallback
}

// 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)
}

func versionIDs(docs []document) []string {
	ids := make([]string, len(docs))
	for i, doc := range docs {
		ids[i] = doc.VersionID
	}
	slices.Sort(ids)
	return ids
}

func writeJSON(w http.ResponseWriter, status int, body any) {
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(status)
	json.NewEncoder(w).Encode(body)
}

func main() {
	mux := http.NewServeMux()

	mux.HandleFunc("GET /signup", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "text/html; charset=utf-8")
		w.Write(signupPage)
	})

	// The document pages: each one renders a registered version, unmodified.
	mux.HandleFunc("GET /legal/{slug}", func(w http.ResponseWriter, r *http.Request) {
		documentID := documents[r.PathValue("slug")]
		version := r.URL.Query().Get("v")
		if version == "" {
			version = "current"
		}
		var page content
		status, err := esc("GET", "/documents/"+documentID+"/versions/"+url.PathEscape(version)+"/content", nil, "", &page)
		if documentID == "" || err != nil || status != http.StatusOK {
			writeJSON(w, http.StatusNotFound, map[string]string{"error": "not_found"})
			return
		}
		w.Header().Set("Content-Type", "text/html; charset=utf-8")
		fmt.Fprintf(w, `<!doctype html><meta charset="utf-8"><article data-esc-document="%s">%s</article>`, page.VersionID, page.HTML)
	})

	// 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})
	})

	// 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})
	})

	port := getenv("PORT", "8080")
	log.Printf("http://localhost:%s/signup", port)
	log.Fatal(http.ListenAndServe(":"+port, mux))
}
```

The signer is a fixed test person here. In your app it is the signed-in user or the account you are about to create. The `pinned` map is the server-owned state the confirmation compares against: replace it with a table in your database before you run more than one instance.

When the API answers `429`, `esc` waits for the seconds in `Retry-After`, 5 at most, and sends the request again, up to twice. `net/http` serves each request in a goroutine of its own, so the wait holds that one request: page requests sent while two confirmations waited were answered in under 0.03 seconds.

Start the server from the shell that loaded `.env`:

```bash
go run .
```

```text
2026/11/26 07:58:17 http://localhost:8080/signup
```

## Step 5. Attach the ceremony in the browser

The browser SDK renders nothing. It observes the checkbox, the notice, the links and the button you built, and reports each step from the signer's browser straight to Esign Comply. Save the page as `public/signup.html`. The `//go:embed` directive in `main.go` compiles it into the binary.

```html file="public/signup.html"
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Create account</title>
    <style>
      body { font: 16px/1.5 system-ui, sans-serif; max-width: 480px; margin: 48px auto; padding: 0 20px; }
      a { color: #0b57d0; text-decoration: underline; }
      button { font: inherit; padding: 10px 16px; }
    </style>
  </head>
  <body>
    <h1>Create account</h1>
    <form id="signup">
      <div id="assent">
        <!-- The page is on screen before the script has a session, so the box stays disabled until the SDK watches it. -->
        <label><input id="agree" type="checkbox" disabled /> I agree to the Terms of Service and Privacy Notice</label>
        <p>
          By checking the box and clicking Create account, you agree to the
          <a id="tos-link" href="/legal/terms">Terms of Service</a> and acknowledge the
          <a id="privacy-link" href="/legal/privacy">Privacy Notice</a>.
        </p>
        <button id="create-account" type="submit" disabled>Create account</button>
      </div>
      <p id="message" role="alert"></p>
    </form>

    <script src="https://esigncomply.com/sdk/v1/esigncomply.js"></script>
    <script type="module">
      const agree = document.querySelector("#agree");
      const submit = document.querySelector("#create-account");
      const message = document.querySelector("#message");

      // Your server creates the session and returns only the client token and the pinned documents.
      const response = await fetch("/api/ceremony", { method: "POST" });
      const { clientToken, apiUrl, documents } = await response.json();

      const ceremony = await EsignComply.attach({ clientToken, apiUrl });
      ceremony.on("change", ({ remainingSteps }) => {
        submit.disabled = remainingSteps.some((step) => step !== "signature.applied");
      });

      // Point each link at the exact version this session pinned, then report it.
      const links = [document.querySelector("#tos-link"), document.querySelector("#privacy-link")];
      for (const [i, link] of links.entries()) {
        link.search = "?v=" + documents[i].version_id;
        await ceremony.presentDocument({ versionId: documents[i].version_id, mode: "hyperlink", link });
      }
      await ceremony.observeAssent({
        region: document.querySelector("#assent"), // notice, links, checkbox, button
        checkbox: agree,
        submit,
      });
      agree.disabled = false; // the SDK watches the box from here on. Only the user ticks it.

      document.querySelector("#signup").addEventListener("submit", async (event) => {
        event.preventDefault();
        try {
          const result = await ceremony.complete(); // the signing act, from the signer's own click
          // The result came to the browser. Your server confirms the record before anything is granted.
          const confirmed = await fetch("/api/signup/confirm", {
            method: "POST",
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ recordId: result.recordId }),
          });
          message.textContent = confirmed.ok
            ? `Account created. Record ${result.recordId}`
            : "We could not confirm whether your acceptance was recorded. Please wait while we check.";
        } catch (error) {
          message.textContent = error.message;
        }
      });
    </script>
  </body>
</html>
```

Open [http://localhost:8080/signup](http://localhost:8080/signup). The button stays disabled until the box is ticked. Tick it, click **Create account**, and the page shows a line such as:

```text
Account created. Record rec_4S2skJucbC2vVYiy1Er5
```

The checkbox starts unchecked and disabled. The page is on screen before the script has a session, and the script enables the box once the SDK observes it: a box ticked before that fails [CR-01](https://esigncomply.com/docs/conformance.md#cr-01). In a test with the session request held back, a click on the box did nothing. The notice names the button by its label and each document by its name, and both links are underlined in a color that differs from the text around them. Each link opens a document page on your own server that renders the registered version.

## Step 6. Confirm the record on the server

The result of `complete()` was delivered to the browser, so your server does not trust it. `POST /api/signup/confirm` in `main.go` reads the record with the secret key and grants access only when four things hold: the status is `recorded`, `timestamped` or `anchored`; `livemode` is what this deployment expects; the signer is the one this server created the session for; and the document versions are exactly the ones it pinned. This step is never optional.

The server logs one line for each confirmation:

```text
2026/11/26 07:59:46 confirmed rec_4S2skJucbC2vVYiy1Er5 (anchored)
```

A record ID that was made up is refused with status `409`:

```bash
curl -s -X POST http://localhost:8080/api/signup/confirm \
  -H "Content-Type: application/json" -d '{"recordId":"rec_made_up"}'
```

```json
{"confirmed":false}
```

The handler checks the HTTP status before anything else, and for a reason that is specific to Go: the error envelope of a refused call decodes into the `record` struct with no error, and leaves `Livemode` at `false` and `Status` empty.

See [Server confirmation](https://esigncomply.com/docs/guides/server-confirmation.md) for the webhook that backs this handler up when the browser closes early.

## Step 7. Check the result

Open the dashboard and choose **Records**. The test record is there with what was observed, what was asserted, and its evidence report, watermarked TEST.

Then run the conformance check against the page. It opens the page in headless Chromium at three window sizes, signs as a visitor would, and tries four things that must be refused. One of them posts a made-up record ID to your confirm route. The checker is a Node.js command line tool, so it needs Node.js 20.19 or later, in a folder of its own:

```bash
mkdir -p esc-check && cd esc-check
npm init -y && npm install esigncomply playwright
npx playwright install chromium
npx esigncomply check --url http://localhost:8080/signup --callback http://localhost:8080/api/signup/confirm
```

The report for this page's code, shortened:

```text
Violations that must be refused
  REFUSED   Submit with the checkbox untouched      No record was made.
  REFUSED   Completion from another origin          The API answered 403 domain_mismatch.
  REFUSED   Programmatic click                      No record was made.
  REFUSED   Forged success posted to your callback  http://localhost:8080/api/signup/confirm answered 409.

Ceremonies
  390x844    record rec_4S2skJucbC2vVYiy1Er5  session ses_hVQSFMV52E7XNMvEVn1E, 5 events
  768x1024   record rec_hEMGG5kJD6V6WFbGhamA  session ses_GmC8ENY8hx85U7EQypLL, 5 events
  1440x900   record rec_YgporHT3bXLFtPiuZFqj  session ses_g8SknidyCQB7B0BeErbc, 5 events

Summary: 0 block, 0 warn, 27 pass.
```

Fix every finding marked `block` and read every finding marked `warn`. Each one names the rule the screen missed, the measurement and the fix. In test mode a finding never stops a record from being sealed, so read the report. The rules are on [Conformance rules](https://esigncomply.com/docs/conformance.md), and every flag of the command is on the [CLI page](https://esigncomply.com/docs/sdk/cli.md).

## Step 8. Go live

Going live takes three steps on the Esign Comply side. There is no plan to choose and no checkout: the Free plan records 10 live signatures a month.

1. Register your production domain and verify it. See [Register a domain](https://esigncomply.com/docs/guides/domains.md).
2. Add your organization's legal name, country and address under **Go live** in the dashboard.
3. Create a live key. It is shown once and starts with `esc_live_`.

Test and live share nothing, so create the documents and the profile again with the live key, or copy them to live from the dashboard, and use the live IDs in production.

Then switch the server over:

- Set the live key as `ESIGNCOMPLY_API_KEY` and set `ESIGNCOMPLY_LIVE=true` in production only. From then on the confirm handler refuses every test record there.
- Behind a proxy that terminates TLS, the handler takes the page's address from the `Origin` header the browser sends, so `context.url` keeps the `https` scheme.
- Replace the `pinned` map with a table in your database, and store the record ID and the receipt beside the user.

In live mode `context.url` must be inside your registered domain, and browser calls are accepted only from it. By default a live signature with a finding at Block level is recorded and you are told at once which rule failed. Turn on blocking, on the dashboard's Conformance page, and it is refused before it is sealed. Run the check from step 7 until no finding is at Block level before you switch keys.

## Troubleshooting

- **`missing_api_key` from `/api/ceremony`.** The variables are not in the environment of the shell that runs the server. `os.Getenv` returns an empty string without an error, so the server starts anyway: in the test run it answered `502` with this code. Run `set -a; . ./.env; set +a` first. See [`missing_api_key`](https://esigncomply.com/docs/api/errors.md#missing_api_key).
- **`pattern public/signup.html: no matching files found` at build time.** The `//go:embed` directive names a file that is not there. The path is relative to `main.go`. Save the page from step 5 before you run `go run .`.
- **`domain_mismatch` when the page loads.** The page was opened from a host that is not on the test allowlist, for example a tunnel or your machine's LAN address. Test keys work on `localhost` and `127.0.0.1` at any port. Add other hosts under Domains in the dashboard. See [`domain_mismatch`](https://esigncomply.com/docs/api/errors.md#domain_mismatch).
- **`429` when the confirm handler reads the record.** `esc` waits for the seconds in `Retry-After`, 5 at most, and sends the request again, up to twice. Nothing else is retried. In the test, four confirmations sent at once for one record all answered `200`, two of them a second later than the others. Four reads sent at once through `esc` showed why: a read that got `429` with `Retry-After: 1` passed on the next attempt. See [`rate_limit_exceeded`](https://esigncomply.com/docs/api/errors.md#rate_limit_exceeded).

## Questions about the Go quickstart

### Is there a Go module for Esign Comply?

No. The server SDK exists for Node.js only. A Go server calls the REST API directly, and this quickstart does it with `net/http` and `encoding/json`, so `go.mod` lists no dependency at all.

### Which Go version does the quickstart need?

Go 1.22 or later. The routes are written as `POST /api/ceremony` and `GET /legal/{slug}`, the method and wildcard patterns that `net/http` gained in Go 1.22. The quickstart was run on Go 1.27.4.

### Why does the confirm handler check the HTTP status first?

Because Go decodes an error envelope into the `record` struct without complaint. In the test, the `not_found` envelope gave `err=nil`, an empty `Status` and `Livemode` set to `false`, the same value a test record carries. The status code tells them apart.

### What happens when a route is called with the wrong method?

The server answers `405`. With the pattern `POST /api/ceremony`, a `GET` to the same path was answered `405 Method Not Allowed` in the test run, with no code in the handler.

### Does the Go quickstart need a domain or a card?

No. Test mode works on `localhost` with a test key, no card and no domain. You register and verify a domain only when you go live, and the Free plan then records 10 live signatures a month.

## Next steps

- [E-signatures and clickwrap for Go](https://esigncomply.com/go): what the integration gives you on this stack, with the things to watch for.
- [Server confirmation](https://esigncomply.com/docs/guides/server-confirmation.md): the checks in step 6 and the `record.completed` webhook.
- [Sessions API](https://esigncomply.com/docs/api/sessions.md) and [Records API](https://esigncomply.com/docs/api/records.md): every field of the two calls this server makes.
- [Add e-signatures and clickwrap with Node.js](https://esigncomply.com/docs/quickstart/nodejs.md): the same flow with the server SDK.
- [All quickstarts](https://esigncomply.com/docs/quickstart.md#quickstarts-by-stack-and-platform).
