AlmondTill/G3N API

adjustLoyaltyPoints

mutation · in the family Refunds and payment corrections

What it does

Manually add or remove a customer’s loyalty points, with a reason.

Adjust a member's points — the privileged manual correction: a signed non-zero delta + the required reason post ONE adjust entry + the conditioned cached-balance apply. active|inactive targets only (CONFLICT/REF_STATE on doomed). Requires the unrestricted capability + the record's current revision.

Before you call

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

Capability area: Refunds and payment corrections — Refunds, corrective notes and voiding invoices.

Roles that may call it:

What happens

Posts a signed points entry to the customer’s loyalty ledger — the history keeps every entry.

Careful

Points are a customer-facing promise. Adjustments are visible in the ledger and cannot be silently undone.

Arguments

NameTypeRequiredNotes
memberIdID ID!yes
revisionID ID!yesThe revision id you read on the record; the change is refused if an edit landed in the meantime.
pointsInt Int!yes
reasonString String!yes

Concurrency

Send the record’s current revision from your last read as revision. A stale revision is refused as CONFLICT/REVISION_STALE — read the record again and retry with the new value.

Returns

LoyaltyMember LoyaltyMember! — A LoyaltyMember — ONE enrollment of ONE customer identity into ONE LoyaltyProgram (parentId = the program). Enrollment requires identity: the inline customer block with email required (trim+lowercase-normalized — anonymous/walk-in cannot earn); the (program × normalized email) uniq marker reserves IN the create transaction — a live holder refuses CONFLICT/MEMBER_EXISTS naming the holder (the email is never echoed), while a doomed member's identity re-enrolls fresh. pointsBalance is the cached LoyaltyPointsEntry ledger sum (PK=loyledger#<memberId>), stamped in the same transaction as every entry, with every draw conditioned balance ≥ draw — points never go negative (CONFLICT/INSUFFICIENT_POINTS names live figures) and cap at 1000000000. Earn/redeem ride the Order place transaction; cancel claws back IN the cancel transaction (spent-below-earned refuses the cancel); returns claw earn + restore redemption exactly off the entries' per-line details in the refund flip transaction. adjustLoyaltyPoints is the only manual points surface. Doom is gated by CONFLICT/BALANCE_OUTSTANDING while points remain (zero via reason-coded adjust first); tier assignment is a manual edit v1.

Example request

graphql
mutation ExampleAdjustLoyaltyPoints($memberId: ID!, $revision: ID!, $points: Int!, $reason: String!) {
  adjustLoyaltyPoints(memberId: $memberId, revision: $revision, points: $points, reason: $reason) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    pointsBalance
    currentTier
    priceGroupId
    consumerId
  }
}

Variables:

json
{
  "memberId": "01900000-0000-7000-8000-fef5fce30000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "points": 1,
  "reason": "Correcting a miscount."
}

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

Example response

json
{
  "data": {
    "adjustLoyaltyPoints": {
      "id": "01900000-0000-7000-8000-7863f92f0000",
      "sysId": "LM-EXMP-0000-000F",
      "type": "LoyaltyMember",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-2a5697370000",
      "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",
      "pointsBalance": 1,
      "currentTier": "<current tier>",
      "priceGroupId": "01900000-0000-7000-8000-99e80f9d0000",
      "consumerId": "01900000-0000-7000-8000-3cbb3ce90000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer

Used in