Skip to main content
POST
Add Line Item

Overview

The Add Line Item endpoint adds a new product to the shopping cart with these features:
  • Automatic Shipment Assignment: Items are automatically grouped into shipments based on their fulfillment requirements
  • Catalog Integration: Uses add_to_cart_ref object directly from catalog API responses
  • Variant Support: Handles configurable products with variant handles
  • Cart Creation: Automatically creates a new cart if one doesn’t exist
  • Optional Cart Clearing: Can clear existing cart before adding new item

Authentication

string
required
Device authentication token to identify and map the session

Path Parameters

string
required
Domain of the merchant website (e.g., staging.luma.gift)

Query Parameters

boolean
default:"false"
When true, clears the cart before adding the new item

Request Body

object
required
Product reference from catalog API containing variant informationProperties:
  • variant_id (string, required): Product variant identifier
  • product_id (string, optional): Parent product identifier
  • variant_handles (array, optional): Array of variant configuration handles (e.g., ["color:blue", "size:large"])
number
required
Quantity to add (minimum 1)

Response

Returns the complete shopping cart including the newly added item. See Get Cart for full response schema

Key Response Features:

array
Shows automatic shipment assignment for the new item
array
Available addon services for the updated cart
string
Indicates the cart schema version

Code Examples

Advanced Examples

With Variant Handles

For configurable products with multiple options:

Clear Cart First

To replace cart contents with a new item:

Catalog Integration

The add_to_cart_ref object should be passed directly from catalog API responses:

Error Responses

Invalid request format or missing required parameters
Product variant not found in catalog
Product is not supported for cart operations
Various processing errors

Automatic Shipment Assignment

When adding items to the cart, the system automatically:
  1. Groups compatible items: Items with similar fulfillment requirements are grouped together
  2. Creates new shipments: Items with different requirements get separate shipments
  3. Inherits options: New shipments inherit available fulfillment and shipping options

Example: Mixed Cart

Adding a large sofa (requires scheduled delivery) to a cart with small accessories (standard shipping) creates separate shipments: