Basket

What is the Basket Service?

The Basket Service (lets-trade-basket) is a core microservice in the LetsTrade platform responsible for managing shopping carts, checkout processes, and order creation. It handles the entire shopping journey from adding products to a basket through to final checkout and payment processing.

This service provides APIs for:

  • Creating and managing shopping baskets

  • Adding, updating, and removing products from baskets

  • Applying discounts, vouchers, and promotional deals

  • Processing checkout with various payment methods

  • Generating delivery quotes and estimates

  • POS (Point of Sale) basket operations

  • Kiosk-based ordering

  • Basket analytics and abandonment tracking


Core Entities

Basket

The central entity representing a shopping cart. A basket contains:

  • client_id: The merchant/business that owns this basket

  • user_id: The customer who owns the basket (optional for guest checkouts)

  • branch_id: The specific store/branch location

  • channel: The sales channel (e.g., "WEB", "APP", "POS", "KIOSK")

  • status: Current state of the basket (ACTIVE, CHECKED_OUT, ABANDONED, etc.)

  • product_list: Array of products in the basket

  • totals: Calculated subtotal, VAT, discounts, and final total

  • delivery_address: Shipping destination (if applicable)

  • payment: Payment method and transaction details

  • subscription: Subscription/recurring order details

  • deal: Applied promotional deals

  • extra_data: Custom key-value pairs for client-specific data

Basket Product

Individual items within a basket:

  • product_id: Reference to the product catalog

  • title: Product name

  • sku: Stock keeping unit

  • quantity: Number of items

  • price: Unit price

  • variations: Selected product variations (size, color, etc.)

  • condiments: Add-ons or modifiers

  • instructions: Special instructions for this item

Payment

Payment information attached to a basket:

  • type: Payment method (CARD, EFT, WALLET, CASH, etc.)

  • card_token: Tokenized card reference

  • wallet_id: Customer wallet identifier

  • amount: Payment amount

  • status: Payment status

Delivery

Shipping/delivery information:

  • type: Fulfillment method (DELIVERY, COLLECTION, DINE_IN)

  • address: Delivery destination

  • fee: Calculated delivery fee

  • estimated_time: Expected delivery/collection time


Basket Lifecycle


Basket Statuses

Status
Description

ACTIVE

Basket is open and can be modified

CHECKED_OUT

Checkout completed, payment processed

ABANDONED

Basket inactive beyond abandonment threshold

EXPIRED

Basket validity period exceeded


Fulfillment Methods

The basket service supports multiple fulfillment types:

Type
Description

DELIVERY

Products shipped to customer address

COLLECTION

Customer picks up from store/branch

DINE_IN

For restaurant orders consumed on premises

DRIVE_THROUGH

For quick-service restaurant drive-through


Key API Operations

Basket Management

Endpoint
Method
Description

/create/basket

POST

Create a new basket

/basket/{id}

GET

Retrieve basket by ID

/user/basket

GET

Get user's active basket

/user/baskets

GET

List all baskets for a user

/basket/list

GET

List baskets with filters

Product Operations

Endpoint
Method
Description

/add/product

POST

Add product to basket

/update/product

POST

Update product quantity/options

/remove/product

POST

Remove product from basket

/clear/basket

POST

Remove all products from basket

Checkout & Payment

Endpoint
Method
Description

/checkout

POST

Process basket checkout

/pos/checkout

POST

POS-specific checkout

/add/payment

POST

Add payment method to basket

/add/subscription

POST

Convert to subscription order

Discounts & Deals

Endpoint
Method
Description

/add/voucher

POST

Apply voucher/promo code

/remove/voucher

POST

Remove applied voucher

/add/deal

POST

Apply promotional deal

/remove/deal

POST

Remove applied deal

Delivery

Endpoint
Method
Description

/add/delivery

POST

Set delivery address and method

/quote

POST

Get delivery quote/estimate

Analytics & Dashboard

Endpoint
Method
Description

/client/dashboard

GET

Basket dashboard metrics

/client/basket/analytics

GET

Client-level analytics

/user/basket/analytics

GET

User-level basket analytics

/highest/basket/spent

GET

Top spending customer

Kiosk Operations

Endpoint
Method
Description

/create/kiosk/basket

POST

Create and checkout kiosk order

Abandonment

Endpoint
Method
Description

/config/basket/abandonment

POST

Configure abandonment settings


Authentication

All Basket API endpoints require JWT Bearer token authentication:

API Base URL

The base URL for all API endpoints is:


Response Format

All responses follow the standard LetsTrade format:

Success Response:

Error Response:

Configure basket abandonment

post

Configures the basket abandonment settings for the client, specifying how long before an inactive basket is marked as abandoned.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
Responses
chevron-right
200

Abandonment configuration saved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successully configured basket abandonment.
post
/config/basket/abandonment

Get highest spending customer

get

Retrieves the customer with the highest basket spending for the client.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Responses
chevron-right
200

Highest spending customer retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Highest basket spent successfully retrieved!
get
/highest/basket/spent

Get client basket analytics

get

Retrieves aggregated basket analytics for the client.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Responses
chevron-right
200

Client analytics retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Client basket analytics successfully retrieved!
get
/client/basket/analytics

Get user dashboard analytics

get

Retrieves dashboard analytics for a specific user.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
user_idstringRequired

User ID

Responses
chevron-right
200

User dashboard analytics retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: User dashboard analytics successfully retrieved!
get
/user/dashboard/analytics

Get user basket analytics

get

Retrieves basket analytics for a specific user.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
user_idstringRequired

User ID

Responses
chevron-right
200

User basket analytics retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: User basket analytics successfully retrieved!
get
/user/basket/analytics

Checkout a basket

post

Completes the checkout process for a basket, processing payment and finalizing the order.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

transactionobjectOptional

Transaction details

walletobjectOptional

Wallet payment details

loan_amountstringOptional

Loan amount if applicable

laybuy_amountstringOptional

Laybuy amount if applicable

strawbooleanOptional

Include straw

cutlerybooleanOptional

Include cutlery

serviettesbooleanOptional

Include serviettes

instructionsstringOptional

Special instructions

time_stampstringOptional

Checkout timestamp

Responses
chevron-right
200

Basket successfully checked out

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Basket successfully checked out!
post
/checkout

Request payment for a basket

post

Sends a payment request to a user for a basket, typically via email.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

notesstringOptional

Payment notes

Responses
chevron-right
200

Payment request sent successfully

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Payment request sent successfully!
post
/payment/request

Create a new basket

post

Creates a new shopping basket for a user with optional products and delivery address.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
user_idstringOptional

User ID

branch_idstringOptional

Branch ID

branch_group_idstringOptional

Branch group ID

typestring · enumOptionalPossible values:
channelstringOptional

Sales channel

extra_dataobjectOptional

Additional custom data

Responses
chevron-right
200

Basket successfully created

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Basket successfully created!
post
/create

Cancel a basket

put

Cancels an existing basket by setting its status to CANCELLED.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID to cancel

Responses
chevron-right
200

Basket successfully cancelled

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully cancelled basket!
put
/cancel

Create and checkout a POS basket

post

Creates a Point of Sale basket and immediately checks it out. Used for in-store transactions.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
client_idstringOptional

Client ID

user_idstringOptional

User ID

branch_idstringOptional

Branch ID

uuidstringOptional

Unique identifier for the basket

delivery_feestringOptional

Delivery fee

outstanding_amountstringOptional

Outstanding amount

totalstringOptional

Total amount

service_feestringOptional

Service fee

product_handling_feesstringOptional

Product handling fees

vatstringOptional

VAT amount

sub_totalstringOptional

Subtotal

Responses
chevron-right
200

POS basket successfully created and checked out

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully create and checkout basket!
post
/create/pos/basket

Create and immediately checkout a basket

post

Creates a new basket with products and immediately proceeds to checkout.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
branch_idstringRequired

Branch ID

typestringRequired

Order type (DELIVERY, COLLECTION, etc.)

Responses
chevron-right
200

Basket successfully created and checked out

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully create and checkout basket!
post
/create/checkout/basket

Submit basket as quote

post

Submits a basket as a quote for review, typically used for B2B or custom pricing scenarios.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID to submit as quote

Responses
chevron-right
200

Quote successfully submitted

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully submitted basket quote!
post
/submit/quote

Retrieve a basket

get

Retrieves a specific basket by ID, user ID, or UUID.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
_idstringOptional

Basket ID

user_idstringOptional

User ID

uuidstringOptional

Basket UUID

flat_structurebooleanOptional

Return flat product structure

branch_idstringOptional

Branch ID filter

Responses
chevron-right
200

Basket successfully retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully retrieved basket!
get
/basket

Get latest basket

post

Retrieves the most recent basket for a user or UUID with optional status filtering.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
_idstringOptional

Basket ID

user_idstringOptional

User ID

uuidstringOptional

Basket UUID

flat_structurebooleanOptional

Return flat product structure

branch_idstringOptional

Branch ID filter

status_liststring[]Optional

List of statuses to filter by

Responses
chevron-right
200

Latest basket successfully retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully retrieved basket!
post
/get/latest/basket

Get baskets for branches

post

Retrieves baskets for specified branches with optional date filtering and pagination.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
branch_id_liststring[]Required

List of branch IDs

from_datestringOptional

Start date filter (ISO format)

to_datestringOptional

End date filter (ISO format)

pagestringOptional

Page number

sizestringOptional

Page size

Responses
chevron-right
200

Branch baskets successfully retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully branch basket list!
post
/get/branch/basket

Get user basket list

get

Retrieves a paginated list of baskets for a specific user with filtering options.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
user_idstringRequired

User ID

branch_idstringOptional

Branch ID filter

pagestringOptional

Page number

sizestringOptional

Page size

from_datestringOptional

Start date filter

to_datestringOptional

End date filter

statusstringOptional

Status filter

typestringOptional

Order type filter

search_stringstringOptional

Search string

Responses
chevron-right
200

User basket list successfully retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully retrieved user basket list!
get
/user/basket/list

Get client basket list

get

Retrieves a paginated list of all baskets for the client with advanced filtering and sorting options.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
pagestringOptional

Page number

sizestringOptional

Page size

from_datestringOptional

Start date filter (created)

to_datestringOptional

End date filter (created)

statusstringOptional

Status filter

typestringOptional

Order type filter

branch_idstringOptional

Branch ID filter

search_stringstringOptional

Search string

sort_bystringOptional

Field to sort by

order_bystringOptional

Sort order (asc/desc)

Responses
chevron-right
200

Client basket list successfully retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully retrieved branch basket list!
get
/client/basket/list

Add product to basket

post

Adds a single product to an existing basket with optional variations and condiments.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

dynamic_pricestringOptional

Override product price

Responses
chevron-right
200

Product successfully added

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully added product to basket.
post
/add/product

Add multiple products to basket

post

Adds multiple products to an existing basket in a single request.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

Responses
chevron-right
200

Products successfully added

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully added product to basket.
post
/add/products

Update basket status

put

Updates the status of a basket (ACTIVE, PROCESSING, ABANDONED, CANCELLED, QUOTE).

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

statusstring · enumRequired

New basket status

Possible values:
Responses
chevron-right
200

Status successfully updated

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully updated basket status!
put
/update/basket/status

Remove products from basket

put

Removes specified products from a basket by their IDs.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

product_id_liststring[]Required

List of product IDs to remove

Responses
chevron-right
200

Products successfully removed

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully removed products from the basket!
put
/remove/products

Update basket

put

Updates basket properties such as delivery address, type, provider, and scheduled time.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

Responses
chevron-right
200

Basket successfully updated

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Basket successfully updated!
put
/update/basket

Apply or remove voucher from basket

put

Applies or removes a voucher from a basket.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
basket_idstringRequired

Basket ID

voucher_codestringRequired

Voucher code to apply

appliedbooleanRequired

Whether to apply or remove voucher

redemption_idstringOptional

Redemption ID if applicable

Responses
chevron-right
200

Voucher application successfully updated

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Voucher application successfully updated.
put
/update/basket/voucher

Update product in basket

put

Updates a specific product in a basket (quantity, instructions, etc.).

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

Responses
chevron-right
200

Product successfully updated

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully updated basket product
put
/update/product

Update POS basket

put

Updates a Point of Sale basket with amounts, products, deals, and vouchers.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
_idstringRequired

Basket ID

Responses
chevron-right
200

POS basket successfully updated

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: POS basket amounts successfully updated!
put
/update/pos/basket

Apply Starshipit delivery rate

post

Applies a selected Starshipit shipping rate to a basket.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
basket_idstringRequired

Basket ID

Responses
chevron-right
200

Rate successfully applied

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully applied Starshipit rate to basket!
post
/basket/apply/starshipit/rate

Prepare Starshipit rate request

post

Prepares a rate request for Starshipit shipping based on basket and address.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
basket_idstringRequired

Basket ID

Responses
chevron-right
200

Rate request prepared successfully

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully prepared Starshipit rate request!
post
/basket/starshipit/rates/prepare

Get client basket dashboard

get

Retrieves basket dashboard data for a client including basket status groupings.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
periodstringRequired

Dashboard period (e.g., daily, weekly, monthly)

branch_idstringOptional

Branch ID filter

branch_id_liststringOptional

Comma-separated branch IDs

Responses
chevron-right
200

Dashboard data retrieved

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Successfully retrieved basket dashboard!
get
/client/dashboard

Create kiosk basket

post

Creates a new basket for kiosk orders and immediately checks it out.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Body
user_idstringOptional

User ID

branch_idstringOptional

Branch ID

channelstringOptional

Sales channel (e.g., KIOSK)

extra_dataobjectOptional

Additional custom data

instructionsstringOptional

Order instructions

Responses
chevron-right
200

Kiosk basket created and checked out

application/json
successbooleanOptionalExample: true
messagestringOptionalExample: Basket successfully checked out!
post
/create/kiosk/basket

Last updated