AlmondTill/G3N API

On this page

createCouponBatch

mutation · in the family Pricing

What it does

Mint a batch of unique single-use codes (up to 48) that all unlock one existing coupon’s terms.

Mint a batch of UNIQUE SINGLE-USE child codes under one existing Coupon: ONE atomic transaction (48 codes max — bigger campaigns mint more batches); the codes are SERVER-GENERATED (<prefix>-<random tail>, the org-group code namespace — a collision refuses CONFLICT/COUPON_CODE_TAKEN, retry-able) and each unlocks the PARENT coupon's terms with ONE extra law: single use (the place transaction stamps it once-only). The coupon must be same-tenant + non-doomed (CONFLICT/REF_STATE). Requires the unrestricted capability. Template class (the coupon-authoring class — v79).

What happens

Creates the batch and its codes in one step; the codes are generated for you.

Who may call it

Capability area: Pricing — Prices, price schedules, promotions, coupons and the money rules of selling.

Arguments

NameTypeRequiredNotes
couponIdID ID!yesNo further notes.
countInt Int!yesNo further notes.
codePrefixString String!yesNo further notes.
captionStringnoNo further notes.

Returns

CouponBatchMint CouponBatchMint! — The createCouponBatch result — the batch + its minted codes (also listable later via couponBatchCodes).

Example request

mutation ExampleCreateCouponBatch($couponId: ID!, $count: Int!, $codePrefix: String!, $caption: String) {
  createCouponBatch(couponId: $couponId, count: $count, codePrefix: $codePrefix, caption: $caption) {
    couponBatch {
      id
      sysId
      type
      caption
      status
      parentId
      rootId
      createdAt
      updatedAt
      revisionNum
      revision
      codePrefix
      codeCount
    }
  }
}

Variables:

{
  "couponId": "01900000-0000-7000-8000-d21413c60000",
  "count": 1,
  "codePrefix": "<code prefix>",
  "caption": "Blue jeans"
}

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

Example response

{
  "data": {
    "createCouponBatch": {
      "couponBatch": {
        "id": "01900000-0000-7000-8000-37386ae00000",
        "sysId": "CB-EXMP-0000-000F",
        "type": "CouponBatch",
        "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",
        "codePrefix": "<code prefix>",
        "codeCount": 1
      }
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer

Used in