Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/astrxnomo/shop-microservers/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint retrieves the current contents of the authenticated user’s shopping cart from Redis. The cart is keyed by the userId extracted from the JWT bearer token, so each user maintains their own isolated cart. If the cart does not yet exist — or has expired after the 7-day Redis TTL — the response returns an empty items array and a total of 0.

Endpoint

GET /api/cart/

Authentication

This endpoint requires a valid JWT passed as a Bearer token in the Authorization header.
Authorization: Bearer <token>

Request

No parameters

This endpoint accepts no path parameters, query parameters, or request body.

Example request

curl http://localhost/api/cart/ \
  -H "Authorization: Bearer eyJhbGci..."

Response

200 — Success

Returns the user’s current cart, including a computed total rounded to two decimal places.
{
  "success": true,
  "data": {
    "items": [
      {
        "productId": "clxxxxxxxxxxxxx",
        "name": "Wireless Headphones",
        "price": 79.99,
        "imageUrl": "https://example.com/headphones.jpg",
        "quantity": 2
      }
    ],
    "total": 159.98
  },
  "error": null
}

Response fields

data.items
array
required
Array of CartItem objects currently in the user’s cart. Empty array [] if the cart is empty or has expired.
data.items[].productId
string
required
CUID of the product, matching the id field returned by the catalog service.
data.items[].name
string
required
Display name of the product, stored in the cart at the time it was added.
data.items[].price
number
required
Unit price of the product at the time it was added to the cart.
data.items[].imageUrl
string
required
URL of the product image, stored in the cart at the time it was added.
data.items[].quantity
number
required
Number of units of this product currently in the cart.
data.total
number
required
Sum of price × quantity across all items, rounded to 2 decimal places using Math.round(...* 100) / 100.
The cart TTL is 7 days (604800 seconds). Each write operation — adding or removing an item — resets the TTL. If neither action occurs within 7 days, the Redis key expires and the cart is silently treated as empty on the next read.

401 — Unauthorized

Returned when the Authorization header is missing or the JWT is invalid or expired.
{
  "success": false,
  "data": null,
  "error": "Unauthorized"
}

Build docs developers (and LLMs) love