---
name: cart-add
description: Add products to the shopping cart in DemoShop. Use when the user says they want to buy, add to cart, or purchase a product identified by its ID.
version: 1.0.0
license: MIT
homepage: https://demoshop-88e.pages.dev
---

# cart-add

Add items to the DemoShop cart.

## When to use

- The user says "agregar al carrito", "quiero comprar el producto X", "añadir N unidades del producto Y".
- The user has already identified a product by ID (e.g., from a previous search).

Do NOT use this skill if the user is only browsing — use `product-search` instead.

## Base URL

```
https://demoshop-88e.pages.dev
```

## Endpoint

### POST /api/cart

Adds one or more units of a product to the cart.

## Request body (JSON)

| Field | Type | Required | Description |
|---|---|---|---|
| `product_id` | integer | Yes | ID of the product to add |
| `quantity` | integer | Yes | Number of units (min 1) |

## Example

```python
import urllib.request, json

url = "https://demoshop-88e.pages.dev/api/cart"
payload = json.dumps({"product_id": 1, "quantity": 2}).encode("utf-8")
req = urllib.request.Request(url, data=payload, headers={
    "Content-Type": "application/json",
    "Accept": "application/json",
}, method="POST")
with urllib.request.urlopen(req, timeout=15) as resp:
    data = json.loads(resp.read().decode("utf-8"))
    print(data["message"])
```

## Output the agent should produce

After adding, confirm to the user:

```
Agregado 2 x Auriculares Bluetooth al carrito.
```

If the product ID is unknown, ask the user to search first.

## Failure modes

- `400`: `product_id` or `quantity` missing/invalid. Re-prompt the user.
- The cart is ephemeral (demo) — no persistence across requests.

