> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Cart

> Retrieve details of a specific shopping cart

<Note>
  This endpoint retrieves the current state of a shopping cart, including all items, calculated totals, and applied discounts.
</Note>

## Authentication

This endpoint requires a valid API key with `carts:read` permissions.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the cart
</ParamField>

## Query Parameters

<ParamField query="expand" type="array">
  Expand related objects: "items.product", "customer", "shipping\_methods"
</ParamField>

<ParamField query="calculate_shipping" type="boolean">
  Calculate available shipping methods (requires shipping address)
</ParamField>

<ParamField query="calculate_tax" type="boolean">
  Calculate tax amount (requires shipping address)
</ParamField>

### Response

Returns the cart object if found.

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://api.stateset.com/v1/carts/cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30?calculate_shipping=true&calculate_tax=true' \
  --header 'Authorization: Bearer YOUR_API_KEY'
  ```

  ```javascript Node.js theme={null}
  const cart = await stateset.carts.retrieve(
    'cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30',
    {
      calculate_shipping: true,
      calculate_tax: true
    }
  );
  ```

  ```python Python theme={null}
  cart = stateset.carts.retrieve(
    'cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30',
    calculate_shipping=True,
    calculate_tax=True
  )
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "cart_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
    "object": "cart",
    "customer_id": "cust_abc123",
    "customer": {
      "id": "cust_abc123",
      "email": "john@example.com",
      "name": "John Doe"
    },
    "session_id": "sess_xyz789",
    "channel": "web",
    "currency": "USD",
    "locale": "en-US",
    "status": "active",
    "items": [
      {
        "id": "ci_abc123",
        "product_id": "prod_123",
        "variant_id": "var_blue_large",
        "product_name": "Wireless Headphones",
        "variant_name": "Blue - Large",
        "sku": "WH-BL-L",
        "quantity": 2,
        "unit_price": 9999,
        "list_price": 9999,
        "subtotal": 19998,
        "discounts": [
          {
            "promotion_id": "promo_summer20",
            "code": "SUMMER20",
            "amount": 2000,
            "type": "percentage"
          }
        ],
        "final_price": 17998,
        "image_url": "https://images.stateset.com/products/wh-blue-large.jpg",
        "inventory_status": "in_stock",
        "available_quantity": 50,
        "metadata": {}
      },
      {
        "id": "ci_def456",
        "product_id": "prod_456",
        "variant_id": null,
        "product_name": "USB-C Cable",
        "variant_name": null,
        "sku": "USBC-6FT",
        "quantity": 1,
        "unit_price": 1999,
        "list_price": 1999,
        "subtotal": 1999,
        "discounts": [],
        "final_price": 1999,
        "image_url": "https://images.stateset.com/products/usbc-cable.jpg",
        "inventory_status": "in_stock",
        "available_quantity": 200,
        "metadata": {}
      }
    ],
    "item_count": 3,
    "unique_item_count": 2,
    "subtotal": 21997,
    "discount_amount": 2000,
    "tax_amount": 1755,
    "tax_breakdown": [
      {
        "name": "CA State Tax",
        "rate": 0.0725,
        "amount": 1450
      },
      {
        "name": "SF County Tax",
        "rate": 0.0175,
        "amount": 305
      }
    ],
    "shipping_amount": 599,
    "total": 20351,
    "shipping_address": {
      "line1": "123 Main St",
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94105",
      "country": "US"
    },
    "selected_shipping_method": {
      "id": "ship_standard",
      "name": "Standard Shipping",
      "amount": 599,
      "estimated_days": 5
    },
    "available_shipping_methods": [
      {
        "id": "ship_standard",
        "name": "Standard Shipping",
        "amount": 599,
        "estimated_days": 5
      },
      {
        "id": "ship_express",
        "name": "Express Shipping",
        "amount": 1299,
        "estimated_days": 2
      }
    ],
    "applied_coupons": [
      {
        "code": "SUMMER20",
        "promotion_id": "promo_summer20",
        "discount_amount": 2000
      }
    ],
    "applied_promotions": [
      {
        "id": "promo_summer20",
        "name": "Summer Sale",
        "type": "percentage",
        "amount": 10
      }
    ],
    "abandoned_at": null,
    "expires_at": "2024-07-20T10:00:00Z",
    "created_at": "2024-06-20T10:00:00Z",
    "updated_at": "2024-06-20T14:30:00Z",
    "last_activity": "2024-06-20T14:30:00Z",
    "metadata": {
      "source": "product_page",
      "utm_campaign": "summer_sale"
    }
  }
  ```
</ResponseExample>
