Meet Toki Operator

Docs/Manage API

Balances & redemptions

Points transactions, issued discounts and perks, and redeeming on a member's behalf.

Every change to a member's balance is recorded as a transfer. Rewards issued to members, such as discount codes, are perks. The redemption operations turn a balance or a membership perk into a discount code. A member's current balances are on TokiUser.balances.

mutation

userTransfersDelete#

Archives selected transfers belonging to the member and this merchant's store credits, recalculates balances transactionally, then runs the existing follow-up jobs. Unmatched IDs are ignored unless none match.

Input

TokiUserTransfersDeleteInput!
  • userIdID!Required

    The member whose transfers are removed.

  • transferIds[String!]!Required

    IDs to archive. At least one must belong to this member and merchant.

Returns

Boolean!

true when the change was made. Anything that stops it comes back as an error.

mutation UserTransfersDelete($input: TokiUserTransfersDeleteInput!) {
  userTransfersDelete(input: $input)
}
Variables
{
  "input": {
    "userId": "c618b613-c518-4480-a818-b939c718b7a6",
    "transferIds": [
      "582b90f4-592b-4287-aa2b-941a5b2b95ad"
    ]
  }
}
Response
{
  "data": {
    "userTransfersDelete": true
  }
}

transfers#

Lists transfers across all members and store credits, newest first. Pass userId for one member's history, or select transfers on a TokiUser.

Arguments

  • queryString

    Filter with field:value terms such as created_at:>-30d. Operators: :, :!=, :>, :>=, :<, :<=; dates also accept relative values like -30d, -1w or -6m. Terms are combined with AND unless joined by OR. Fields: amount, created_at, description, source, to_user_id, token_id, transfer_id, type.

  • reverseBoolean

    Reverse the sort order.

  • userIdString

    Only this member's transfers.

  • idID

    Only items whose id equals this value.

Returns

TokiTransferConnection!

A page of TokiTransfer in nodes, with pageInfo for the next page. Each item:

One change to a member's balance, such as points earned, spent, expired or adjusted by hand.

  • idID!
  • userIdID!

    The member whose balance changed.

  • amountFloat!

    Points moved, as a positive number whether they were added or taken. type tells which.

  • createdAtString!

    When the balance changed.

  • tokenIdID!

    The store credit whose balance changed; the same ID as TokiUserBalance.id.

  • typeString

    Whether points were added or taken, for example ADDED, ADDED_NONCUMULATIVE (doesn't count toward tier progress), SPENT or PENALTY (also counts against tier progress).

  • descriptionString

    The transaction's title, which the member sees in their wallet's transaction history.

  • sourceString

    What caused the change, for example manual (a manual adjustment), activity_reward, discount_code (points redeemed for a discount code) or token_expiration.

  • userTokiUser

    The member whose balance changed.

  • issuedRewardTokiIssuedReward

    The activity reward that credited these points; null for transfers with another cause.

query Transfers($first: Int) {
  transfers(first: $first) {
    nodes {
      id
      amount
      createdAt
      type
      user {
        id
        email
        name
        firstName
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "first": 10
}
Response
{
  "data": {
    "transfers": {
      "nodes": [
        {
          "id": "5f9068a3-5e90-4710-a190-6bc960906a36",
          "amount": 49.99,
          "createdAt": "2026-10-14T09:30:00.000Z",
          "type": "default",
          "user": {
            "id": "8db6c034-8eb6-41c7-afb6-c35a90b6c4ed",
            "email": "anna@example.com",
            "name": "Anna Petrova",
            "firstName": "Anna"
          }
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}

userPerks#

Lists perks, the discount codes issued to members, newest first. By default it returns every member's perks in the current store; pass userId for one member or allShops: true for all your stores.

Arguments

  • queryString

    Filter with field:value terms such as used:false or created_at:>-30d. Operators: :, :!=, :>, :>=, :<, :<=; dates also accept relative values like -30d, -1w or -6m. Terms are combined with AND unless joined by OR. Fields: code, created_at, expired_at, key, order_id, perk_id, reason, total_price, transfer_id, updated_at, used.

  • reverseBoolean

    Reverse the sort order.

  • userIdID

    Only this member's perks. Required with groupByDiscount.

  • allShopsBoolean

    true includes perks from all your stores; by default only the current store's.

  • availableOnlyBoolean

    true returns only unused, unexpired codes with a reason the wallet lists as unused discounts: Activity, Refer a friend, Workflow, Custom, External API, Klaviyo, Exclusive Products (Checkout) or a Token Spend … value.

  • groupByDiscountBoolean

    true merges the copies of each code across stores into one item and lists them in shopDetails; use it with allShops: true. Requires userId, and ignores availableOnly.

Returns

TokiUserPerkConnection!

A page of TokiUserPerk in nodes, with pageInfo for the next page. Each item:

A perk: a discount code Toki issued to a member in one of your stores, for example as a reward or in exchange for points.

  • perkIdID!
  • userIdID!

    The member the code was issued to.

  • createdAtString!

    When Toki issued the code.

  • updatedAtString!
  • expiredAtString

    When the code expires, in the past or the future; null if it has no expiry date.

  • expiredAtMsFloat

    expiredAt as Unix time in milliseconds.

  • keyString

    What the code was issued for, usually the ID of a reward rule (TokiReward.id).

  • codeString!

    The discount code the member enters at checkout.

  • valueTokiJSON!

    The discount as JSON: a type such as absolute, percentage or free-shipping, the code's settings, and for fixed and percentage discounts an amount in your store currency or a percent as a fraction (0.1 is 10%).

  • reasonString!

    Where the perk came from, for example Activity, Refer a friend, Workflow, or a Token Spend … value for codes bought with points. Discount and free shipping codes from membership perks carry the membership's name.

  • usedBoolean

    Whether the code was used. With groupByDiscount, whether any store's copy was used.

  • orderIdID

    The order that used the code.

  • totalPriceFloat

    The total of the order that used the code, in your store currency.

  • shopIdID!

    The store the code was created in.

  • transferIdID

    The transfer that deducted the points the member paid for the code; null if it cost no points.

  • shopNameString

    With groupByDiscount, the name of the store whose copy this item shows; otherwise null.

  • shopDetails[TokiUserPerkShopDetails!]

    With groupByDiscount, every store's copy of the code, used ones first; otherwise null.

query UserPerks($first: Int) {
  userPerks(first: $first) {
    nodes {
      createdAt
      code
      value
      totalPrice
      shopDetails {
        shopId
        createdAt
        totalPrice
        status
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
Variables
{
  "first": 10
}
Response
{
  "data": {
    "userPerks": {
      "nodes": [
        {
          "createdAt": "2026-10-14T09:30:00.000Z",
          "code": "TOKI-7Q2M-4KXD",
          "value": {},
          "totalPrice": 49.99,
          "shopDetails": [
            {
              "shopId": "10ae74b9-0fae-4326-aeae-71930dae7000",
              "createdAt": "2026-10-14T09:30:00.000Z",
              "totalPrice": 49.99,
              "status": "active"
            }
          ]
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yOjE5"
      }
    }
  }
}
query

userSpendingRule#

Returns a member's balance in your default store credit, their conversion rate, and the discount limits of the redemption rule that applies to them in the current store. userSpend works with the same figures.

Arguments

  • userIdID!Required

    The member.

Returns

TokiUserSpendingRulePayload!

A member's balance and spending limits for userSpend.

  • balanceFloat!

    The member's balance in your default store credit, in points.

  • maxToSpendFloat

    The largest discount one code can be worth, in your store currency; null for no maximum.

  • minToSpendFloat

    The smallest discount a code can be worth, in your store currency; null for no minimum.

  • minimumCartSpendFloat

    The cart subtotal a code requires at checkout, in your store currency; null for none.

  • conversionRateFloat!

    How many points equal one unit of your store currency for this member.

query UserSpendingRule($userId: ID!) {
  userSpendingRule(userId: $userId) {
    balance
    maxToSpend
    minToSpend
    minimumCartSpend
    conversionRate
  }
}
Variables
{
  "userId": "696e204e-6a6e-41e1-a76e-1d28686e1ebb"
}
Response
{
  "data": {
    "userSpendingRule": {
      "balance": 49.99,
      "maxToSpend": 49.99,
      "minToSpend": 49.99,
      "minimumCartSpend": 49.99,
      "conversionRate": 0.1
    }
  }
}
query

userMembershipPerks#

Lists the membership perks userRedeemPerk can turn into a code for the member: percentage discounts, fixed-amount discounts and free shipping. For each of these kinds, only the highest-ranked membership the member holds that offers one counts.

Arguments

  • userIdID!Required

    The member.

Returns

TokiUserMembershipPerksPayload!

The membership perks a member can redeem.

  • rewards[TokiUserMembershipPerksRewards!]!

    The perks: percentage discounts first, then fixed-amount discounts, then free shipping.

query UserMembershipPerks($userId: ID!) {
  userMembershipPerks(userId: $userId) {
    rewards {
      id
      label
      tier
    }
  }
}
Variables
{
  "userId": "f9b6ddd3-f8b6-4c40-abb6-e0f9fab6df66"
}
Response
{
  "data": {
    "userMembershipPerks": {
      "rewards": [
        {
          "id": "390b8f3e-3a0b-40d1-a70b-8c18380b8dab",
          "label": "Summer double points",
          "tier": "Tier"
        }
      ]
    }
  }
}
mutation

userSpend#

Turns part of the member's balance in your default store credit into a single-use discount code worth amount, created in each of your stores. The points are deducted at the member's conversion rate as a transfer, which fires the TRANSACTION_CREATED webhook. It fails if the member is suspended in the current store, has too few points, or no redemption rule allows the amount (see userSpendingRule).

Input

TokiUserSpendInput!
  • userIdID!Required

    The member.

  • amountFloat!Required

    The discount value in your store currency, such as 12.5. Toki deducts amount times the member's conversion rate in points, rounded to a whole number.

Returns

TokiUserSpendPayload!

The result of a redemption.

  • discountCodeString

    The discount code to give the member.

mutation UserSpend($input: TokiUserSpendInput!) {
  userSpend(input: $input) {
    discountCode
  }
}
Variables
{
  "input": {
    "userId": "fffa0dce-00fa-4f61-adfa-0aa8fefa0c3b",
    "amount": 49.99
  }
}
Response
{
  "data": {
    "userSpend": {
      "discountCode": "TOKI-7Q2M-4KXD"
    }
  }
}
mutation

userRedeemPerk#

Generates the discount code for one of the member's membership perks in the current store; their balance doesn't change. Calling it again returns the same code while that code is unused and unexpired; unless the perk has an expiry date or period, a code expires an hour after it's generated. For a one-time perk that was already used, discountCode holds a message instead of a code.

Input

TokiUserRedeemPerkInput!
  • userIdID!Required

    The member.

  • rewardIdID!Required

    The perk to redeem: an id from userMembershipPerks.

Returns

TokiUserSpendPayload!

The result of a redemption.

  • discountCodeString

    The discount code to give the member.

mutation UserRedeemPerk($input: TokiUserRedeemPerkInput!) {
  userRedeemPerk(input: $input) {
    discountCode
  }
}
Variables
{
  "input": {
    "userId": "27eb2f9e-28eb-4131-a5eb-2c7826eb2e0b",
    "rewardId": "80035bce-8103-4d61-ae03-58a87f035a3b"
  }
}
Response
{
  "data": {
    "userRedeemPerk": {
      "discountCode": "TOKI-7Q2M-4KXD"
    }
  }
}