AlmondTill/G3N API

adjustStoredValueInstrument

mutation · in the family Refunds and payment corrections

What it does

Manually correct a gift card or store-credit balance, with a reason.

Adjust an instrument balance — the privileged manual correction: a signed non-zero delta + the required reason post ONE adjust entry + the conditioned cached-balance apply (below-zero refuses CONFLICT/INSUFFICIENT_BALANCE naming the live figures). active|depleted targets only (CONFLICT/REF_STATE otherwise); a positive adjust on depleted re-opens it; a draw landing zero on a non-reloadable flips depleted in the same transaction. 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 balance entry on the instrument’s ledger.

Careful

This is money movement on a customer-held instrument — every entry is permanent and auditable.

Arguments

NameTypeRequiredNotes
instrumentIdID ID!yes
revisionID ID!yesThe revision id you read on the record; the change is refused if an edit landed in the meantime.
amountMinorInt 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

StoredValueInstrument StoredValueInstrument! — A StoredValueInstrument — a balance-bearing money instrument: gift_card (purchasable, reloadable-by-field, bearer) · gift_certificate (fixed-amount) · store_credit (refund/goodwill-born, customer-BOUND, never purchasable as a line). Dual-birth: immediate active (the issue entry rides the create) or staged inactive printed stock (activated at sale via the Order line arm, or directly via activateStoredValueInstrument). Selling/reloading one is an Order line (untaxed — basis instrument_sale; engine-invisible); redeeming one is an applyTender step-5 internal tender; store credit from a return mints via refundReturn method=store_credit. Doom is gated by CONFLICT/BALANCE_OUTSTANDING while value remains (zero via reason-coded adjust first — no silent money destruction).

Example request

graphql
mutation ExampleAdjustStoredValueInstrument($instrumentId: ID!, $revision: ID!, $amountMinor: Int!, $reason: String!) {
  adjustStoredValueInstrument(instrumentId: $instrumentId, revision: $revision, amountMinor: $amountMinor, reason: $reason) {
    id
    sysId
    type
    caption
    status
    parentId
    rootId
    createdAt
    updatedAt
    revisionNum
    revision
    instrumentType
    code
    reloadable
    balanceMinor
    currency
  }
}

Variables:

json
{
  "instrumentId": "01900000-0000-7000-8000-87615d500000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "amountMinor": 1250,
  "reason": "Correcting a miscount."
}

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

Example response

json
{
  "data": {
    "adjustStoredValueInstrument": {
      "id": "01900000-0000-7000-8000-713d7f020000",
      "sysId": "SV-EXMP-0000-000F",
      "type": "StoredValueInstrument",
      "caption": "Blue jeans",
      "status": "active",
      "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",
      "instrumentType": "gift_card",
      "code": "BJ-001",
      "reloadable": true,
      "balanceMinor": 1250,
      "currency": "USD"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}

Errors this call can answer

Used in