The Urban Store frontend manages cart state locally using a Zustand store persisted inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ALEJ4NDRO2025/urban-store/llms.txt
Use this file to discover all available pages before exploring further.
localStorage. After every mutation — adding an item, changing a quantity, removing an item, or clearing the cart — the Zustand cartStore calls this endpoint to push the current local state to MongoDB. The server replaces the stored cart wholesale with whatever the frontend sends, ensuring both layers always reflect the same data.
This is a full replace operation. The entire existing cart in MongoDB is discarded and rewritten from the items array in the request body. To clear the cart server-side, send an empty array.
Authentication required:
POST /api/cart/sync/
Replace the authenticated user’s server-side cart with the provided items. If no cart exists yet for the user, one is created.Request Body
The complete array of cart item objects representing the frontend’s current cart state. Send an empty array
[] to clear the cart on the server.Slug of the product.
Display name of the product. Stored as-is for cart rendering.
Number of units. Defaults to
1 if not provided.Size variant. Defaults to an empty string if not provided.
Color variant. Defaults to an empty string if not provided.
Unit price at the time the item was added to the local cart. Defaults to
0 if not provided.Cloudinary image URL for the item. Defaults to an empty string if not provided.
Response Fields
Always
"ok" on a successful sync.Recalculated sum of
price_at_time × quantity for all synced items.Recalculated sum of all item quantities after the sync.
Example — Sync after adding an item
To clear the cart server-side, POST with an empty items array. This is the canonical way to wipe a user’s MongoDB cart — for example, after a successful checkout.Response: