Validate Coupons

Purpose

Validate one or more coupon codes for an order in a single request.

Format

To validate coupon eligibility and discount amounts, these are computed against the order content provided in the request, any changed content can be re-validated to confirm eligibility.

Each coupon code is validated independently, so any invalid or ineligible codes will not fail the whole request

There are two scenarios where validating coupons is reccomended;

  • When a customer enters a coupon code - check for eligibility and confirm the discount to apply to the order.
  • Whenever an order changes - with items added, removed, quantities updated, coupons need revalidated with the updated content.

Path Parameters

Path parameterTypeDescription
accountIdstringThe Deliverect account id.
channelLinkIdstringThe channel link id the order belongs to. The account, location and channel used for validation are all derived from this channel link.

Revalidating after the order changes

Whenever the customer's order mutates, re-validate by sending all the codes relevant to the order in codes — both any code the customer just entered and any code(s) already applied to the order from a previous validation — in a single call against the current order state. Then, for each result:

  • applicable: false → the code is no longer eligible for the current order (e.g. a PLU-scoped discount whose matching item was removed, or a minimum-spend coupon that no longer qualifies after items were removed). Un-apply it from the order and surface validationErrors to the customer.
  • applicable: true → re-apply the returned discounts as-is, replacing whatever was previously applied for that code. Don't reuse a previously computed amount: a percent_off discount's effective amount depends on the order total and an item-scoped discount's depend on which basket items are currently present — both can change even when the code itself remains valid.

Reconcile the order's totals using the fresh discount amounts from the latest call, not the amounts from any earlier validation. This keeps the customer from checking out with a stale discount amount, or one that no longer applies at all, after the order has changed since it was last validated.

Request body

FieldTypeRequiredDescription
sessionIdstringYesClient/session identifier for the checkout session the coupons are being validated for.
orderOrderYesThe order the coupons are being validated against.
codesarray of stringYesThe coupon codes to validate. At least one is required. Codes cannot be empty or blank.

Order object

FieldTypeRequiredDescription
orderTypestringYesThe order's fulfillment type. One of delivery, pickup, eatIn.
itemsarray of ItemYesThe items on the order/basket.
placedTimestring (ISO 8601 date-time)NoWhen the order was/will be placed.

Item object

FieldTypeRequiredDescription
idstringYesThe item's own id on the basket. Used to resolve item-scoped discounts back to the specific basket line they apply to.
plustringYesThe item's PLU.
priceintegerYesThe item's price, in the smallest currency unit (e.g. $2.00200).

Example request

{
  "sessionId": "session-123",
  "order": {
    "orderType": "delivery",
    "items": [
      {
        "id": "64f1a2b3c4d5e6f7a8b9c0d3",
        "plu": "SKU-001",
        "price": 1500
      },
      {
        "id": "64f1a2b3c4d5e6f7a8b9c0d4",
        "plu": "SKU-002",
        "price": 800
      }
    ]
  },
  "codes": [
    "SUMMER25",
    "INVALIDCODE"
  ]
}

Response

Returns a list with one result entry per requested code.

FieldTypeDescription
codestringThe coupon code this result is for.
applicablebooleanWhether the code is valid and applicable to this order. false if the code doesn't exist or fails any condition.
discountsarray of DiscountsThe discount(s) this coupon would apply, if applicable is true. Empty otherwise.
descriptionstringThe coupon's description, if applicable.
validationErrorsarray of ValidationErrorPresent when applicable is false; explains why the code could not be applied.

Discount object

FieldTypeDescription
offerobjectThe discount amount/type. See Offer types.
scopeobjectWhat the discount applies to. See Scope types.
providerstringAlways "coupon".
externalIdstringThe coupon's code.
namestringThe coupon's name.

Offer types

Discriminated by offer.type:

typeFieldsDescription
flat_offvalue (integer)A fixed amount off, in the smallest currency unit.
percent_offvalue (integer), maxAmount (integer)A percentage off, in basis points (e.g. 2500 = 25%), capped at maxAmount.

Scope types

Discriminated by scope.type:

typeFieldsDescription
orderThe discount applies to the whole order.
itemitemIds (array of string)The discount applies only to the specific basket item(s) matching this coupon's configured PLU(s), identified by the ids you passed in the request's order.items.

ValidationError object

FieldTypeDescription
codestringMachine-readable error code. See table below.
messagestringHuman-readable explanation.
codeMeaning
coupon_not_foundNo coupon exists for this code on the account.
max_uses_per_coupon_exceededThe coupon has reached its maximum number of uses.
coupon_not_available_for_locationThe coupon isn't configured for the order's location.
not_eligible_fulfillment_typeThe coupon doesn't support the order's fulfillment type (delivery/pickup/eat-in).
coupon_not_valid_for_channelThe coupon isn't configured for the order's channel.
coupon_not_valid_for_channel_linkThe coupon isn't configured for this specific channel link.
coupon_not_enabledThe coupon exists but is currently disabled.

Example response

[
  {
    "code": "SUMMER25",
    "applicable": true,
    "discounts": [
      {
        "offer": {
          "type": "percent_off",
          "value": 2500,
          "maxAmount": 3000
        },
        "scope": {
          "type": "order"
        },
        "provider": "coupon",
        "externalId": "SUMMER25",
        "name": "Summer 25% off"
      }
    ],
    "description": "25% off your order, up to $30",
    "validationErrors": []
  },
  {
    "code": "INVALIDCODE",
    "applicable": false,
    "discounts": [],
    "description": "",
    "validationErrors": [
      {
        "code": "coupon_not_found",
        "message": "coupon not found"
      }
    ]
  }
]

Notes

  • This endpoint does not redeem the coupon — it only validates and returns the
    applicable discount(s). Redemption happens separately at checkout.
Path Params
string
required
string
required
Response
200
Language
Credentials
OAuth2
LoadingLoading…
Response
Click Try It! to start a request and see the response here!