AlmondTill/G3N API

doomCoupon

mutation · in the family Coupon

What it does

Permanently retire a coupon — a code a customer presents for a reduction.

Doom (terminal) a Coupon by id, within the caller's org group; requires the unrestricted capability + the record's current revision. Doom releases the org-group code namespace. NO doom-time enumeration of open orders holding the coupon — evaluation self-heals and place refuses a dead coupon CONFLICT/REF_STATE.

Before you call

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

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

Roles that may call it:

Careful

Doom is forever — a doomed record never comes back into use (its history remains readable). Anything still referencing it live will block the doom.

Arguments

NameTypeRequiredNotes
idID ID!yesThe id of the record.
revisionID ID!yesThe revision id you read on the record; the change is refused if an edit landed in the meantime.
reasonStringno

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

Coupon Coupon! — A Coupon — the code-gated entry to the discount engines: a normalized code (trim+uppercase, stored normalized-only, immutable at birth — re-code = a new coupon) that either unlocks a couponGated Promotion (trigger flavor — the reduction is source=promo at position 3) or carries its own simple effect (discount flavor — source=coupon at position 2, before promotions). Attach to an open order via applyOrderCoupon; redemption counts per order in the place transaction — a capped-out coupon refuses CONFLICT/COUPON_EXHAUSTED. Named deferrals: CouponBatch (unique single-use child codes) · per-customer caps.

Example request

graphql
mutation ExampleDoomCoupon($id: ID!, $revision: ID!, $reason: String) {
  doomCoupon(id: $id, revision: $revision, reason: $reason) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    flavor
    code
    promotionId
    startAt
    endAt
    totalUsesCap
  }
}

Variables:

json
{
  "id": "01900000-0000-7000-8000-d554478b0000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "reason": "Correcting a miscount."
}

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

Example response

json
{
  "data": {
    "doomCoupon": {
      "id": "01900000-0000-7000-8000-d554478b0000",
      "sysId": "CP-EXMP-0000-000F",
      "type": "Coupon",
      "caption": "Blue jeans",
      "status": "doomed",
      "parentId": "01900000-0000-7000-8000-eacdfcfd0000",
      "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",
      "flavor": "trigger",
      "code": "BJ-001",
      "promotionId": "01900000-0000-7000-8000-3b80190a0000",
      "startAt": "2027-01-31T00:00:00.000Z",
      "endAt": "2027-01-31T00:00:00.000Z",
      "totalUsesCap": 1
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer