Skip to the page
MintilaDocs

Docs Consent

Consent API, webhooks and the browser

Read, export, summarise and erase a site’s records from your server, hear each decision, and react to it in the page.

Markdown Updated December 2, 2026
On this page

Keys

Each site has two kinds of key, under Keys. The publishable key (slc_pub_…) is in the tag and public by design. A secret key (slc_sec_…) reads that one site’s records and erases its visitors: press New secret key, name it and, if you like, give it an expiry of 30 days, 90 days or a year. It is shown once, and stops working the moment you revoke it.

The API

Every path is under https://www.stacklumen.com/app/api/consent/v1, with the secret key as a Bearer token.

RequestWhat it answers
GET /recordsThe decisions, newest first, with from, to, visitor, cursor and limit (1 to 500, 100 by default). Pass next_cursor back as cursor for the next page.
GET /records.csvThe same decisions as CSV, up to 100,000 rows.
GET /summaryDecisions, visitors, where they were made, and each category’s opt-ins and rate. The last 30 days unless given, at most 400.
DELETE /visitors/{visitor_id}Erases every decision that visitor made on this site. 204, whether there were any or not.
GET /config?key=slc_pub_…Public: the dialog’s words and look, as the script reads them.

from and to are dates or ISO timestamps; a date as to includes that whole day. A key that doesn’t open answers 401, and more than 120 requests a minute with one key answer 429 with Retry-After.

Terminal
# The last 30 days, summarised
curl -H "Authorization: Bearer $SLC_SECRET" "https://www.stacklumen.com/app/api/consent/v1/summary"

# Answer an erasure request
curl -X DELETE -H "Authorization: Bearer $SLC_SECRET" \
  "https://www.stacklumen.com/app/api/consent/v1/visitors/3f9a1c2e-8d47-4b1a-9c05-6e2f7a1d3b98"

Webhooks

Add up to 5 https addresses under a site’s Webhooks. Every new decision is sent to each once, as it is recorded; there is no retry, because the record itself is kept and the API reads it back. Addresses on a private network aren’t sent to, and redirects aren’t followed.

consent.recorded
{
  "id": "consent_6c1f0e9a-2b47-4d38-9a1e-5f0c7d2b8e41",
  "type": "consent.recorded",
  "created_at": "2026-11-06T19:41:07.512Z",
  "property": {
    "id": "9b2d5c71-0e4a-4f6b-8c3d-1a7e9f20b5c4",
    "name": "Example Shop"
  },
  "data": {
    "id": "6c1f0e9a-2b47-4d38-9a1e-5f0c7d2b8e41",
    "created_at": "2026-11-06T19:41:07.512Z",
    "visitor_id": "3f9a1c2e-8d47-4b1a-9c05-6e2f7a1d3b98",
    "account_ref": null,
    "analytics": true,
    "functional": true,
    "marketing": false,
    "policy_version": "2026-11",
    "surface": "banner",
    "origin": "https://www.example.com",
    "path": "/pricing",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) …"
  }
}

Each endpoint has its own signing secret (slsig_…). Work out the HMAC-SHA256 of the timestamp t, a dot and the raw body, as hex; accept the delivery only when it equals v1 from the Stacklumen-Signature header and t is within five minutes. Send a test delivers a signed sample marked "test": true.

JavaScript
// Node: check a delivery before trusting it.
import {createHmac, timingSafeEqual} from 'node:crypto';

export function verify(secret, header, rawBody) {
  const parts = Object.fromEntries(
    (header ?? '').split(',').map((p) => {
      const i = p.indexOf('=');
      return [p.slice(0, i).trim(), p.slice(i + 1).trim()];
    }),
  );
  const t = Number(parts.t);
  if (!Number.isInteger(t) || !parts.v1) return false;
  if (Math.abs(Date.now() / 1000 - t) > 300) return false; // five minutes
  const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
  return expected.length === parts.v1.length && timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}

In the browser

NameWhat it is
StacklumenConsent.open()Opens Preferences, for a “Cookie settings” link of your own.
StacklumenConsent.get()The choices, {analytics, functional, marketing}, or null before the visitor has decided.
StacklumenConsent.on(fn)Calls fn with the choices once they are known and after every decision. Answers a function that stops it.
sl-consent eventDispatched on window after every decision, with the choices as event.detail.
JavaScript
// Start your own analytics only once it is allowed
window.addEventListener('sl-consent', (e) => {
  if (e.detail.analytics) startAnalytics();
});

The script loads async, so window.StacklumenConsent may not exist yet when your code runs. Listen for the sl-consent event, or hold the tag, which waits for you.

Something here wrong or missing? Tell us · Get help