AlmondTill/G3N API

grantConsent

mutation · in the family Selling

What it does

Record a customer’s consent (marketing, data use) as staff, on their word.

Staff: record a grant decision for a named consumer: NO record → dual-birth born granted (the permanent pair marker + the first-decide everReferenced stamp ride the ONE transaction) · withdrawn → the evented transition (capture context refreshed) · already granted → a capture-context revision. Gates: purpose active + consumer NOT doomed (each CONFLICT/REF_STATE naming it; a suspended consumer stays legal — the subject's right). The create race self-cures via the marker. Requires the unrestricted capability. Template class (capture-at-source — hand-derived v20).

Before you call

A bearer session from an API key (see Authentication and key hygiene) or a signed-in user.

Capability area: Selling — Ringing sales, serving customers and issuing invoices.

Roles that may call it:

Careful

Consent records are legal facts — record only what was actually given.

Arguments

NameTypeRequiredNotes
inputConsentDecisionInput ConsentDecisionInput!yesStaff decide-input for grantConsent/withdrawConsent: the acted-on consumer is named and the capture surface is required.

Returns

ConsentRecord ConsentRecord! — A ConsentRecord — the proof-of-decision per (Consumer × Purpose): consumer-parented (parentId = the Consumer id — the LoyaltyMember construct-parented class), family document, sparse. The permanent (consumer × purpose) uniq pair marker is both the singleton guarantee AND the O(1) lookup (never released, never taken over; purge reaps). NO update op — the only writes are the 4 decide ops (grantConsent/withdrawConsent staff · grantMyConsent/withdrawMyConsent consumer) + the system doom; a same-decision re-capture is a capture-context revision under a new policyVersion. Capture context ∈ {policyVersion, captureSurface ∈ [storefront, pos, back_office, cli, import], captureLocale?} reflects the latest decision. Effective consent = resolveEffectiveConsent (the myConsents view): consumer doomed ⇒ denied · purpose inactive/doomed ⇒ denied · granted ⇒ allowed · withdrawn/doomed ⇒ denied · absent ⇒ opt_in? Denied: allowed. Audit rides existing machinery — NO bespoke ledger. NOT searchable.

Example request

graphql
mutation ExampleGrantConsent($input: ConsentDecisionInput!) {
  grantConsent(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    purposeId
    policyVersion
    captureSurface
    captureLocale
  }
}

Variables:

json
{
  "input": {
    "consumerId": "01900000-0000-7000-8000-3cbb3ce90000",
    "purposeId": "01900000-0000-7000-8000-0faf80a10000",
    "policyVersion": "<policy version>",
    "captureSurface": "<capture surface>",
    "captureLocale": "<capture locale>"
  }
}

Send it with the envelope naming the version: "extensions": {"at": {"version": {"name":"genesis","number":0}}}.

Example response

json
{
  "data": {
    "grantConsent": {
      "id": "01900000-0000-7000-8000-c942ced40000",
      "sysId": "CD-EXMP-0000-000F",
      "type": "ConsentRecord",
      "caption": "Blue jeans",
      "status": "granted",
      "parentId": "01900000-0000-7000-8000-3cbb3ce90000",
      "rootId": "01900000-0000-7000-8000-a1295a650000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-53c6eea90000",
      "purposeId": "01900000-0000-7000-8000-0faf80a10000",
      "policyVersion": "<policy version>",
      "captureSurface": "<capture surface>",
      "captureLocale": "<capture locale>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer

Used in