<aside> 🙋🏼
Exercise: Design the request and response payloads for the "fetch cart" call triggered when a user taps the cart icon, plus the follow-up mutation APIs.
</aside>

"_note": "INVENTED" inline so no one mistakes them for real data.Triggered when the user taps the cart icon.
A cart fetch is a read, so it's a GET. The only inputs that change the result are the delivery address / pincode (they affect serviceability and delivery promises), so those go in query params. Identity and plumbing go in headers. There is no request body.
GET /v3/cart?address_id=ADDR_001&pincode=400093
Headers
{
"Authorization": "Bearer <access_token>",
"X-Request-Id": "req_a1b2c3d4e5",
"X-Device-Platform": "android",
"X-App-Version": "8.12.3",
"Accept": "application/json",
"Accept-Language": "en-IN",
"If-None-Match": "\"cart-v42\""
}
Query params
{
"address_id": "ADDR_001",
"pincode": "400093"
}
200 OK)All 9 items populated. Money in paise. null for absent fields. No envelope. Invented items flagged inline.
{
"cart_id": "CART_789",
"version": 42,
"currency": "INR",
"address": {
"address_id": "ADDR_001",
"display_name": "Pankaj Ku...",
"full_name": "Pankaj Kumar",
"pincode": "400093",
"type": "HOME"
},
"groups": [
{
"type": "flipkart",
"label": "Flipkart",
"count": 4,
"lines": [
{
"line_id": "LINE_001",
"product_id": "PROD_BOOK_123",
"listing_id": "LST_88",
"title": "A Promised Land (English, Hardcover)",
"subtitle": "Hardcover, Obama Barack",
"image_url": "<https://example.cdn/a-promised-land.jpg>",
"rating": { "average": 4.5, "count": 50 },
"price": { "mrp_minor": 99900, "sale_minor": 38400, "discount_pct": 61 },
"offers": { "applied": 1, "available": 1 },
"delivery": { "promise_date": "2022-02-07", "fee_minor": 5000, "fee_waived": false, "original_fee_minor": null },
"quantity": { "value": 1, "min": 1, "max": 10, "step": 1 },
"availability": { "status": "in_stock", "units_left": null, "message": null },
"seller": { "seller_id": "SELL_BOOKS", "name": null, "assured": false },
"actions": ["save_for_later", "remove", "update_quantity"]
},
{
"line_id": "LINE_002",
"product_id": "PROD_CHAIR_456",
"listing_id": "LST_91",
"title": "Rastogi Office Revolving Mesh Ergonomic Chair",
"subtitle": "Black, Pre-assembled",
"image_url": "<https://example.cdn/rastogi-chair.jpg>",
"rating": null,
"price": { "mrp_minor": 1500000, "sale_minor": 899900, "discount_pct": 40 },
"offers": { "applied": 1, "available": 1 },
"delivery": { "promise_date": "2022-02-09", "fee_minor": 0, "fee_waived": true, "original_fee_minor": 4000 },
"quantity": { "value": 1, "min": 1, "max": 5, "step": 1 },
"availability": { "status": "low_stock", "units_left": 5, "message": "Only 5 left" },
"seller": { "seller_id": "SELL_RASTOGI", "name": "RastogiSteelFurniture", "assured": true },
"actions": ["save_for_later", "remove", "update_quantity"]
}
]
},
{ "type": "grocery", "label": "Grocery", "count": 4, "lines": [] },
{ "type": "quick", "label": "Quick", "count": 1, "lines": [] }
]
}