POST /api/v4.0/integrations/coupons/validate

Changed on

Validates a list of coupons and checks their eligibility for use by a customer. Every coupon must pass - the first failure ends the call and nothing is locked. Describe the cart as well, and each coupon is additionally matched against its rules - on merchant, branch, channel, collection, category, product, the line-item fields and extra data. Set the lock flag to True to reserve the coupons under one lock session. By default the lock flag is False, allowing only validation without reserving the coupons.

Request

  • Base URL
    https://api.gameball.co
  • Auth
    API key in header apikey and API key in header secretkey

Request body

object required
customerId, string required

Unique identifier for the customer that you can reference across the customer's whole lifetime. Could be a database ID, random string, email or anything that uniquely identifies the customer.

email, string

Customer's email address. Required if your account uses email-based channel merging.

mobile, string

Customer's mobile number. Required if your account uses mobile-based channel merging.

coupons, string[] required

A list of coupon codes to validate.

lock, boolean

Indicates whether the request is intended to validate the coupon or to lock it for a future redemption.

lockReference, string

Required only if the lock flag is set to True and you need to validate and lock a new or updated list of coupons within an existing lock session.

lockDuration, integer

Represents the number of minutes for which a coupon will be locked if the lock flag is set to True.

merchantId, string

Cart-level. The merchant the order is placed with. Required if the coupon is restricted to specific merchants.

branchId, string

Cart-level. The branch or outlet the order is placed at. Required if the coupon is restricted to specific branches. There is no plural or per-item form.

channel, string

Cart-level. The sales channel the order is placed through. Read by a coupon's Channel rule.

extra, object

Cart-level. Free-form order data, read by a coupon's Extra.<key> rules. The rule names the key path to read: Extra.paymentMethod reads extra.paymentMethod, and Extra.shipping.city reads the nested extra.shipping.city. Send each key exactly as it is spelled in the rule.

collectionId, string

Item-level. A collection the basket touches. Evaluated together with collectionsIds as a single list. Ignored when lineItems is present.

collectionsIds, string[]

Item-level. Every collection the basket touches. Maximum 200 values. Ignored when lineItems is present.

lineItems, object[]

The cart described item by item. Maximum 500 entries. The only way to send categories and products. Required for any rule on a field with no flat form (category, product, title, price, quantity, discount, vendor, sku, tags, weight, extra, and the TotalItems and TotalUniqueItems totals), and for an AND coupon with two or more item-level rules. When lineItems is present, the flat collectionId and collectionsIds fields are ignored for matching.

totalPurchaseAmount, number

Cart-level. The total value of the purchase the coupon will be applied to. Checked against the coupon's minOrderValue. Sending this field describes a cart only when the coupon carries a minOrderValue; for those coupons it switches on full restriction enforcement, and omitting it is rejected the same way a value below the minimum is.

Example request

{
  "merchantId": "cairo-downtown",
  "branchId": "branch-14",
  "channel": "online",
  "extra": {
    "paymentMethod": "card"
  }
}

Response

Coupons validated successfully

object required
valid, boolean

Indicates whether the coupons are valid.

coupons, ValidatedCoupon[]

An array containing the details of the coupons that need to be locked or validated in the request.

lockReference, string

The unique reference code associated with the coupon lock session.

dateToExpire, string date-time

The exact date and time when the coupon lock will expire.

Example response

{
  "coupons": [
    {
      "rules": [
        {
          "name": "Price",
          "operator": "GreaterThanOrEqual",
          "matchValue": "100"
        }
      ]
    }
  ]
}

Changes

    • breaking

      the response property coupons/items/couponRulesLogicalOperator became nullable for the status

    • breaking

      the coupons/items/couponRulesLogicalOperator response's property type changed from integer to string null for status

    • warning

      removed the request property categories

    18 more changes in this revision