Consent

The store's CMP configuration for the built-in Consent Mode v2 banner. Defaults are always applied server-side, so the payload is complete and renderable even for an unconfigured store (compliant built-in modal, BG + EN copy shipped).

Storefront wiring (the trap that matters)

  • Mount <ConsentInit required={consent.enabled}> as the first child of <body>, it sets the synchronous Consent Mode v2 DEFAULT and must never wait on this fetch in the browser (async default = first-hit consent race). Resolve this config server-side (RSC) and inline the setting into the document; the prop is required, a layout without it does not compile.
  • The switch decides the default; a stored choice wins. enabled: true is a store that collects consent: every visitor starts DENIED until they choose on the banner. enabled: false is a store with no consent gate: every visitor starts GRANTED, and every configured pixel fires. Either way a choice already in the _1c_consent cookie is what counts, so a visitor who declined keeps that decision if the banner is switched off.
  • Render the built-in banner only when enabled && mode === "builtin".
  • mode: "external" = the merchant's CMP owns the UI and must write the same _1c_consent cookie (or call setConsent()), all Cartbase-side tag gating works off that one seam.
  • Choices persist 12 months in the cookie. The platform's own analytics (the page view and presence beacons <StorefrontTags> sends) stays outside consent by design and reports the visitor's analytics choice with each beacon.
  • Pair with integrations.md: tracking.consent_required mirrors enabled here, and <StorefrontTags> hands it to every pixel that gates its own SDK (Meta, TikTok, ChatGPT). Google reads the <ConsentInit> default.
  • Purpose: everything the banner needs to render, per locale.
  • Auth: anon (x-client-id).
  • Request: no params.
  • Response: the EXACT allowlist (nothing else will ever appear here):
{
  "consent": {
    "enabled": true,
    "mode": "builtin",              // "builtin" | "external"
    "layout": "modal",              // "modal" (blocking) | "banner-bottom" (non-blocking)
    "privacy_href": "/cookies",
    "reject_on_first_layer": false,
    "copy": {
      "bg": {
        "title": "Преди да продължиш",
        "body": "…",
        "privacy_link_label": "…",
        "accept_label": "…", "settings_label": "…", "reject_label": "…",
        "settings_title": "…",
        "accept_all_label": "…", "save_label": "…", "reject_all_label": "…",
        "necessary_label": "…", "necessary_description": "…",
        "analytics_label": "…", "analytics_description": "…",
        "ads_label": "…", "ads_description": "…"
      },
      "en": { /* same 16 keys, every field always present per locale */ }
    }
  }
}
  • Errors: 400 missing_client_id only, the payload itself always succeeds (a corrupt/missing stored config degrades to defaults, never to a broken banner).
  • SDK: consent.getConsent(client)
  • Components: <ConsentInit required={consent.enabled}> + <ConsentBanner copy={copy[locale]} layout privacyHref rejectOnFirstLayer> (consent family).
  • Settings: admin, Settings, Consent (enabled/mode/layout/ privacy_href/copy per locale).
# Complete, renderable config: even on an unconfigured store the defaults
# make every documented key present.
BODY=$(curl -sf "$BASE/api/store/consent" -H "x-client-id: $CLIENT_ID")
echo "$BODY" | grep -q '"consent"'
echo "$BODY" | grep -q '"mode"'
echo "$BODY" | grep -q '"layout"'
echo "$BODY" | grep -q '"privacy_href"'
echo "$BODY" | grep -q '"reject_on_first_layer"'
echo "$BODY" | grep -q '"analytics_label"'
echo "$BODY" | grep -q '"ads_description"'
# A missing tenant header answers the standard 400.
STATUS=$(curl -s -o /dev/null -w '%{http_code}' "$BASE/api/store/consent")
test "$STATUS" = 400