Skip to main content

POST /consent/v1/:ledgerId/state - record consent

Persists a consent record asynchronously. Ledger is append-only: records can never be edited or deleted.

This API does not support CORS. So writes from the browser are send-and-forget, use navigator.sendBeacon or fetch with the mode: "no-cors" option.

To change a user's consent, post a new ConsentState for the same metadata.user to this API.

This is a non-local record of consent. Consent will always need to be stored for decisions related to behavior of the application or website.

The "categories" field is deduplicated, meaning that sending "categories": ["analytics", "necessary", "analytics"] will be persisted as "categories": ["analytics", "necessary"] when it is read back.

Support for custom surface metadata and custom non-surface metadata are supported under the fields .metadata.custom and .surface.metadata.custom, these fields must be objects but can contain any information.

All unknown fields will be stripped before being persisted.

Path parameters

Name

Type

Notes

ledgerId

UUID string

Your ledger UUID. Must name an existing ledger. Repeated in the body as ledgerId on purpose; the two must match.

Authentication: none. A public write endpoint by design (browser beacon / agent use); no Authorization header is needed.

Request body - a ConsentState. Pre-stringified JSON. The server ignores Content-Type - from a browser send text/plain so the request needs no CORS preflight, but the charset part of Content-Type is honored, defaults to utf-8.

Responses

Status

Body

Meaning

202 Accepted

RecordConsentStateResponse

Durably queued. metadata.id is the new record's ID; pass it as recordId to read the record back. metadata.recordedAt is the record's recordedAt, the same value the read returns. Reads are not guaranteed to be immediately visible.

400 Bad Request

application/problem+json

The body is invalid, including when its ledgerId does not match the ledgerId in the path, or a path parameter is not valid, for instance not a valid UUID

404 Not Found

application/problem+json

No ledger with this ledgerId exists.

413 Content Too Large

application/problem+json

Body size is > 64KiB. (This is the same limit as sendBeacon)

415 Unsupported Media Type

application/problem+json

Declared charset is unknown

4xx

application/problem+json

Other client errors (see "Errors").

Example (with minimal metadata)

POST https://ledger.enzuzo.com/consent/v1/5ae66dc4-2a1a-4c84-b559-c7959100bb24/state
{
  "ledgerId": "5ae66dc4-2a1a-4c84-b559-c7959100bb24",
  "surface": {
    "kind": "web"
  },
  "categories": ["necessary", "analytics"],
  "action": "accept"
}

Example (with maximal metadata)

POST https://ledger.enzuzo.com/consent/v1/5ae66dc4-2a1a-4c84-b559-c7959100bb24/state
{
  "ledgerId": "5ae66dc4-2a1a-4c84-b559-c7959100bb24",
  "surface": {
    "kind": "web",
    "metadata": {
      "scroll": { "x": 0, "y": 420 },
      "screen": {
        "actual": { "height": 1080, "width": 1920 },
        "available": { "height": 1040, "width": 1920 },
        "colorDepth": 24, "pixelDepth": 24,
        "orientation": { "type": "landscape-primary", "angle": 0 },
        "isFullscreen": false
      },
      "globalPrivacyControl": false,
      "location": "https://www.example.com/pricing",
      "referrer": "https://www.google.com/",
      "languages": ["en-CA", "en"],
      "platform": "MacIntel",
      "textDirection": "ltr",
      "visibilityState": "visible",
      "characterSet": "UTF-8",
      "contentType": "text/html",
      "title": "Pricing - Example",
      "custom": { "some-custom-field": 10 }
    }
  },
  "categories": ["necessary", "analytics"],
  "action": "accept",
  "metadata": {
    "user": "u_7f3a9c",
    "settings": "3b9c1f…",
    "consentSignal": { "kind": "tcf", "value": "CQ…" },
    "custom": { "some-custom-field": 10 }
  }
}

Example (response):

HTTP/1.1 202 Accepted
{
  "apiVersion": "v1",
  "kind": "RecordConsentStateResponse",
  "metadata": {
    "ledgerId": "5ae66dc4-2a1a-4c84-b559-c7959100bb24",
    "recordedAt": "2026-10-20T17:22:05Z",
    "id": "353fabdf-d4fc-4c7d-9e00-ff0c54879f2e"
  }
}

For an AI-agent surface send something like "surface": { "kind": "ai-chat", "metadata": { ... } } with whatever context/metadata that is relevant. Currently web is the only known surface. Unknown surface kinds are accepted with free-form metadata.

Did this answer your question?