unPLUGDevelopers

Checkouts and redemptions API

Preview a checkout

POST/v1/checkouts/preview

Tells you what the member could use on this cart and why everything else doesn't apply. It has no side effects: nothing is held or spent, so call it whenever the cart changes. Show only the applicable entries as tappable.

Permissions: Secret key with checkout:write, or a member token for its own member.

Request headers#

  • Idempotency-Keystring
    Any string up to 255 characters; use a UUID v4. Kept 24 hours per key (or member) and endpoint. Same key and body replays the first response with Idempotent-Replayed: true.
    Max Length 255

Request body#

The cart, plus:

  • member_idstring (uuid)
    The member. Leave it out for a guest checkout with a code. With a member token it is always the token's member.
  • location_idstring (uuid)Required
  • channelstringRequired
    app or web.
    One of app, web
  • fulfillmentstringRequired
    pickup, delivery, curbside or dine_in. May grow.
    One of pickup, delivery, curbside, dine_in
  • currencystringRequired
    USD.
  • subtotal_centsintegerRequired
    The sum of every line (unit price plus modifiers, times quantity), before discounts, tax and tip.
    Min 0
  • itemsarray of CartItemRequired
    The cart lines. See below.
    Show attributesCartItem
    • line_idstringRequired
      Your id for the line, unique within the cart.
    • pos_item_idstring
      Square catalog item variation id.
    • namestringRequired
    • quantityintegerRequired
      Min 1
    • unit_price_centsintegerRequired
      Integer cents.
      Min 0
    • pos_category_idsarray of string
    • modifiersarray of object
      Show attributesHide attributes
      • pos_modifier_idstring
      • namestring
      • price_centsinteger
        Integer cents.
        Min 0
  • codesarray of string
    Promo codes the guest typed, shared or unique.
  • reward_idsarray of string (uuid)
    Catalog rewards to check. Empty checks every catalog reward.
  • wallet_item_idsarray of string (uuid)
    Wallet items to check. Empty checks every available item in the member's wallet.

Response fields#

Returns 200 with Preview

  • member_idstring (uuid)Nullable
    null for a guest checkout.
  • points_balanceintegerNullable
    The member's balance now.
  • points_to_earninteger
    Points this cart earns as sent, before any discount. Here $12.50 at 10 Beans per dollar. If Maya uses the pastry, the order earns on $9.00 instead: 90 Beans.
  • applicablearray of PreviewEntry
    Everything the member can use on this cart: catalog rewards they can afford, wallet items, valid codes.
    Show attributesPreviewEntry
    • typestring
      Also on not_applicable entries: reward (with reward_id and points_cost), wallet_item (with wallet_item_id) or code (with code). Send that id or code to POST /v1/redemptions. May grow.
      One of reward, wallet_item, code
    • reward_idstring (uuid)
    • wallet_item_idstring (uuid)
    • codestring
    • namestring
      Label to show. Also on not_applicable entries.
    • points_costinteger
      For reward.
    • discount_centsinteger
      The discount on this cart. Show this amount; don't recalculate it.
    • affected_line_idsarray of string
      Cart lines the discount applies to. Empty for a discount on the whole subtotal.
    • Show valuesHide values
      • below_minimum_subtotal
      • wrong_channel
      • wrong_location
      • wrong_fulfillment
      • outside_available_times
      • item_not_in_cart
      • tier_required
      • not_enough_points
      • per_member_limit_reached
      • budget_exhausted
      • not_started
      • expired
      • already_used
    • messagestring
      Not-applicable entries only. Safe to show guests.
  • not_applicablearray of PreviewEntry
    Catalog rewards, wallet items and codes that don't apply, each with a reason from the reason codes and a message you can show the guest as is.
    Show attributesPreviewEntry
    • typestring
      One of reward, wallet_item, code
    • reward_idstring (uuid)
    • wallet_item_idstring (uuid)
    • codestring
    • namestring
    • points_costinteger
      For reward.
    • discount_centsinteger
      Applicable entries only.
    • affected_line_idsarray of string
      Applicable entries only.
    • Show valuesHide values
      • below_minimum_subtotal
      • wrong_channel
      • wrong_location
      • wrong_fulfillment
      • outside_available_times
      • item_not_in_cart
      • tier_required
      • not_enough_points
      • per_member_limit_reached
      • budget_exhausted
      • not_started
      • expired
      • already_used
    • messagestring
      Not-applicable entries only. Safe to show guests.
  • challenge_progressarray of object
    Coming soon How this order would move the member's challenges. Always empty at launch.

Error descriptions#

400Bad request
missing_param

A required cart field is missing. param names it.

400Bad request
invalid_param

A field has the wrong format, for example an unknown fulfillment.

404Not found
member_not_found

No member with this id.

404Not found
location_not_found

No location with this id in your brand.

410Gone
member_deleted

The member was deleted.

Free drip coffee costs 500 Beans and Maya has 420, so it is in not_applicable. An unknown or expired code is not an error here either: it comes back in not_applicable, so you can show the message next to the code field.

Any endpoint can also return the common errors.