Cart Management
Add Line Item
Adds a product variant to the cart with automatic shipment grouping based on fulfillment requirements
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_refobject 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
Device authentication token to identify and map the session
Path Parameters
Domain of the merchant website (e.g.,
staging.luma.gift)Query Parameters
When
true, clears the cart before adding the new itemRequest Body
Product reference from catalog API containing variant informationProperties:
variant_id(string, required): Product variant identifierproduct_id(string, optional): Parent product identifiervariant_handles(array, optional): Array of variant configuration handles (e.g.,["color:blue", "size:large"])
Quantity to add (minimum 1)
Response
Returns the complete shopping cart including the newly added item. See Get Cart for full response schemaKey Response Features:
Shows automatic shipment assignment for the new item
Available addon services for the updated cart
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
Theadd_to_cart_ref object should be passed directly from catalog API responses:
Error Responses
400 Bad Request
400 Bad Request
Invalid request format or missing required parameters
404 Not Found
404 Not Found
Product variant not found in catalog
409 Conflict
409 Conflict
Product is not supported for cart operations
422 Unprocessable Entity
422 Unprocessable Entity
Various processing errors
Automatic Shipment Assignment
When adding items to the cart, the system automatically:
- Groups compatible items: Items with similar fulfillment requirements are grouped together
- Creates new shipments: Items with different requirements get separate shipments
- 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:Related Endpoints
- Get Cart - View current cart state
- Update Line Item - Modify cart items
- Clear Cart - Empty the cart
Add Line Item