Skip to main content

Cart API overview

With the Cart API, Rokt partners can add additional products to a customer's cart within a transaction. The Cart API works with the Web SDK to help render frontend placements and provide hooks to update a customer's cart. There are two integrations needed to power upsells through Rokt:

  1. Integrate your backend cart/checkout system with the Rokt Cart API (this documentation).
  2. Integrate the Web SDK into your cart frontend.

A parking spot is a good example of a Rokt add-to-cart product. For example, a ticketing partner can upsell parking spots to their customers while they are purchasing event tickets. These parking spots are sourced through a third-party parking provider.

Minimal Integration

To fulfull customer orders, partners need to integrate with the following hook and API endpoint.

  1. Subscribe to V2_CART_ITEM_UPDATED events to be informed of when a user adds items to their cart.
  2. Call /cart/confirm to confirm the successful purchase of the items.

Reserving Items

Some items needs to be reserved during checkout to guarantee that the inventory is still available when they eventually confirm. The following endpoints should be used for handling reservation.

  1. Call /cart/reserve to reserve the items for a set period of time.
  2. Optionally, call /cart/release to cancel a reservation and allow other customers to reserve those items.

Canceling Confirmed Items

The following endpoint is available for canceling items after they have been confirmed.

  1. Call /confirmation/cancel

In-transaction request flow

To fulfill customer orders, partners need to adhere to the following transaction flow.

In-Transaction Request Flow

  1. (Optional) Call /placements/any to determine whether there are any placements to display, so you can skip the cross-sell/upsell stage if not there are no relevant offers.
  2. Based on whether /placements/any returns true or false, you can choose to show or skip the upsell page in the transaction flow. On the upsell page, you must initialize the Web SDK, which requests and displays available placements.
  3. Once a customer opts in, the Web SDK informs the partner's frontend by sending the V2_CART_ITEM_UPDATED message. Then the normal purchase process proceeds.
  4. (Optional) Call /cart/reserve to reserve the items for a set period of time during which the purchase must be completed and confirmed with Rokt.
  5. Once a customer pays for the items, call /cart/confirm to confirm the successful purchase of the items. Rokt then informs the relevant provider of the products for fulfillment.
    1. To cancel a reservation, call /cart/release. This is optional as reserved items that are not confirmed are automatically released after a timeout. This is suitable for high-traffic partners that require prompt release of reserved items.
    2. To cancel a confirmed item, call /confirmation/cancel. This is suitable for partners who want to cancel an item after it has been confirmed.