Skip to main content
GET
/
cart
Get Cart
curl --request GET \
  --url https://api.example.com/cart
{
  "id": 1,
  "userId": 5,
  "createdAt": "2026-03-01T10:00:00.000Z",
  "updatedAt": "2026-03-05T14:30:00.000Z",
  "items": [
    {
      "id": 10,
      "cartId": 1,
      "productId": 42,
      "quantity": 2,
      "product": {
        "id": 42,
        "name": "Wireless Headphones",
        "description": "High-quality Bluetooth headphones with noise cancellation",
        "price": "89.99",
        "imageUrl": "https://example.com/images/headphones.jpg",
        "stock": 50,
        "categoryId": 3,
        "createdAt": "2026-01-15T08:00:00.000Z",
        "updatedAt": "2026-02-20T12:00:00.000Z"
      }
    },
    {
      "id": 11,
      "cartId": 1,
      "productId": 15,
      "quantity": 1,
      "product": {
        "id": 15,
        "name": "Laptop Stand",
        "description": "Adjustable aluminum laptop stand",
        "price": "34.99",
        "imageUrl": "https://example.com/images/stand.jpg",
        "stock": 120,
        "categoryId": 5,
        "createdAt": "2026-01-10T08:00:00.000Z",
        "updatedAt": "2026-02-15T10:00:00.000Z"
      }
    }
  ]
}

Authentication

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

Response

id
integer
required
Unique identifier for the cart
userId
integer
required
ID of the user who owns this cart
createdAt
string
required
ISO 8601 timestamp when the cart was created
updatedAt
string
required
ISO 8601 timestamp when the cart was last updated
items
array
required
Array of cart items
id
integer
required
Unique identifier for the cart item
cartId
integer
required
ID of the cart this item belongs to
productId
integer
required
ID of the product
quantity
integer
required
Quantity of the product in the cart
product
object
required
Full product details
id
integer
required
Product ID
name
string
required
Product name
description
string
Product description
price
string
required
Product price (decimal string)
imageUrl
string
required
URL to product image
stock
integer
required
Available stock quantity
categoryId
integer
Category ID the product belongs to
createdAt
string
required
ISO 8601 timestamp when the product was created
updatedAt
string
required
ISO 8601 timestamp when the product was last updated
{
  "id": 1,
  "userId": 5,
  "createdAt": "2026-03-01T10:00:00.000Z",
  "updatedAt": "2026-03-05T14:30:00.000Z",
  "items": [
    {
      "id": 10,
      "cartId": 1,
      "productId": 42,
      "quantity": 2,
      "product": {
        "id": 42,
        "name": "Wireless Headphones",
        "description": "High-quality Bluetooth headphones with noise cancellation",
        "price": "89.99",
        "imageUrl": "https://example.com/images/headphones.jpg",
        "stock": 50,
        "categoryId": 3,
        "createdAt": "2026-01-15T08:00:00.000Z",
        "updatedAt": "2026-02-20T12:00:00.000Z"
      }
    },
    {
      "id": 11,
      "cartId": 1,
      "productId": 15,
      "quantity": 1,
      "product": {
        "id": 15,
        "name": "Laptop Stand",
        "description": "Adjustable aluminum laptop stand",
        "price": "34.99",
        "imageUrl": "https://example.com/images/stand.jpg",
        "stock": 120,
        "categoryId": 5,
        "createdAt": "2026-01-10T08:00:00.000Z",
        "updatedAt": "2026-02-15T10:00:00.000Z"
      }
    }
  ]
}

Notes

  • If the user doesn’t have a cart yet, a new empty cart will be created automatically
  • The cart is unique per user (one cart per user)
  • Product details are included in each cart item for convenience

Build docs developers (and LLMs) love