Skip to navigation

Validate a coupon code

Checks a code the customer typed against the cart, so you can show the discount before checkout. A well-formed request always gets 200: read valid, and reason when it is false.

The discount is calculated again when the order is created; send the code as couponCode to POST /orders. A code replaces automatic promotions: an order gets either a code or the best automatic promotion, never both.

For this endpoint, slug goes in the body. Rate limit: 30 requests per 60 seconds per slug and IP. Guide: Coupons and promotions.

Authentication

AuthorizationBearer

Either this or a trusted browser origin. The restaurant’s API key, sent as Authorization: Bearer lbs_…. Use it from your server only, never in browser code. Keys are issued per restaurant by LettBestilt.

OR
Originstring

Either this or an API key. No key is needed when the request’s Origin header is trusted for this restaurant: https://{slug}.lettbestilt.no, a verified domain of the restaurant, or a partner origin LettBestilt has bound to the restaurant. Browsers set Origin themselves; it is not something you configure. Not accepted by GET /site-gate, which requires an API key.

Request

This endpoint expects an object.
slugstringRequired<=64 characters
The restaurant's slug. Sent in the body for this endpoint.
codestringRequired<=64 characters

The code the customer typed. Not case-sensitive.

subtotalintegerRequired>=0

The cart subtotal in øre, including add-ons.

fulfillmentenumOptional

Optional. Pass to evaluate WRONG_FULFILLMENT correctly when the coupon is restricted to one fulfillment type.

Allowed values:
deliveryFeeintegerOptional>=0

Optional. Delivery fee in øre — needed to evaluate FREE_DELIVERY coupons correctly.

cartlist of objectsOptional

Optional for validate (unlike preview-auto, where it’s required). Pass it when the coupon is scoped to specific products/categories, uses per-variant FIXED_PRICE pricing, or is a BUNDLE («X for Y kr») offer, so NOT_APPLICABLE_TO_CART can be evaluated correctly. A BUNDLE code without a cart is always NOT_APPLICABLE_TO_CART.

emailstringOptionalformat: "email"<=200 characters

Optional. Required when the coupon is only for newsletter subscribers; without it the response is reason: SUBSCRIBER_ONLY. It also lets the server check once-per-customer codes early.

requestedPickupAtdatetimeOptional

Optional. The pickup time the customer selected for a pre-order (same value you send as requestedPickupAt to POST /api/v1/orders). Day-of-week and time-of-day restrictions on the coupon (and its expiry) are evaluated against THIS moment, not the moment of the request — a Monday/Tuesday offer must not apply to an order placed on Tuesday for a Thursday pickup. Omit for as-soon-as-possible orders. Send the same value here and on the order, or the cart will show a discount the order rejects.

Response

The result. Always 200 when the request is valid, also when the code does not apply: then valid is false and reason says why.

object
OR
object

Errors

401
Unauthorized Error
404
Not Found Error
422
Unprocessable Entity Error
429
Too Many Requests Error