AlmondTill/G3N API

Start a loyalty programme and enrol members

Define how customers earn and redeem points, enrol members, and correct a member’s points with a reason when you must — every entry stays in the ledger.

Promotions & loyalty · a play in 4 steps.

The steps

  1. Define the programme — how points are earned and redeemed. — createLoyaltyProgram
  2. Enrol a customer as a member. — createLoyaltyMember
  3. Add or remove a member’s points with a reason — a signed, visible ledger entry. — adjustLoyaltyPoints
  4. Read a member’s points history — every earn, redemption and adjustment. — loyaltyLedger

The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

createLoyaltyProgram

createLoyaltyProgram — mutation · Create a new your loyalty program — how customers earn and redeem points at your organization.

Example request

mutation ExampleCreateLoyaltyProgram($input: NewLoyaltyProgramInput!) {
  createLoyaltyProgram(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    currency
    organizationIds
    startAt
    endAt
  }
}

Variables:

{
  "input": {
    "caption": "Blue jeans",
    "currency": "USD",
    "earnRate": {
      "points": 1,
      "perMinor": 1
    },
    "redeemRate": {
      "points": 1,
      "perMinor": 1
    }
  }
}

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

Example response

{
  "data": {
    "createLoyaltyProgram": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "LP-EXMP-0000-000F",
      "type": "LoyaltyProgram",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "currency": "USD",
      "organizationIds": [
        "01900000-0000-7000-8000-60e064dc0000"
      ],
      "startAt": "2027-01-31T00:00:00.000Z",
      "endAt": "2027-01-31T00:00:00.000Z"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

createLoyaltyMember

createLoyaltyMember — mutation · Create a new customer’s membership in your loyalty program at your organization.

Example request

mutation ExampleCreateLoyaltyMember($input: NewLoyaltyMemberInput!) {
  createLoyaltyMember(input: $input) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    pointsBalance
    currentTier
    priceGroupId
    consumerId
  }
}

Variables:

{
  "input": {
    "caption": "Blue jeans",
    "programId": "01900000-0000-7000-8000-892c2b660000",
    "customer": {
      "name": "Blue jeans",
      "email": "<the person’s email address>"
    }
  }
}

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

Example response

{
  "data": {
    "createLoyaltyMember": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "LM-EXMP-0000-000F",
      "type": "LoyaltyMember",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "pointsBalance": 1,
      "currentTier": "<current tier>",
      "priceGroupId": "01900000-0000-7000-8000-c7ffbf680000",
      "consumerId": "01900000-0000-7000-8000-6e8c92ec0000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

adjustLoyaltyPoints

adjustLoyaltyPoints — mutation · Manually add or remove a customer’s loyalty points, with a reason.

Example request

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:

{
  "memberId": "01900000-0000-7000-8000-80d971ae0000",
  "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

{
  "data": {
    "adjustLoyaltyPoints": {
      "id": "01900000-0000-7000-8000-37386ae00000",
      "sysId": "LM-EXMP-0000-000F",
      "type": "LoyaltyMember",
      "caption": "Blue jeans",
      "status": "active",
      "parentId": "01900000-0000-7000-8000-065235280000",
      "rootId": "01900000-0000-7000-8000-a093dd800000",
      "createdAt": "2027-01-31T00:00:00.000Z",
      "updatedAt": "2027-01-31T00:00:00.000Z",
      "revisionNum": 1,
      "revision": "01900000-0000-7000-8000-b7960e180000",
      "pointsBalance": 1,
      "currentTier": "<current tier>",
      "priceGroupId": "01900000-0000-7000-8000-c7ffbf680000",
      "consumerId": "01900000-0000-7000-8000-6e8c92ec0000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

loyaltyLedger

loyaltyLedger — query · A loyalty member’s points history — every earn, redemption, and adjustment.

Example request

query ExampleLoyaltyLedger($memberId: ID!, $limit: Int) {
  loyaltyLedger(memberId: $memberId, limit: $limit) {
    id
    parentId
    entryType
    points
    reason
    orderId
    returnId
    caption
    createdAt
  }
}

Variables:

{
  "memberId": "01900000-0000-7000-8000-80d971ae0000",
  "limit": 1
}

Example response

{
  "data": {
    "loyaltyLedger": [
      {
        "id": "01900000-0000-7000-8000-37386ae00000",
        "parentId": "01900000-0000-7000-8000-065235280000",
        "entryType": "earn",
        "points": 1,
        "reason": "Correcting a miscount.",
        "orderId": "01900000-0000-7000-8000-f6d8263a0000",
        "returnId": "01900000-0000-7000-8000-4d4c03d20000",
        "caption": "Blue jeans",
        "createdAt": "2027-01-31T00:00:00.000Z"
      }
    ]
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": null,
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}