Add a product to a cart
cart_add_itemAdds units of one product to an anonymous Trailhead Supply cart and returns the whole cart. Without cart_token a new cart is opened and its cart_token returned. Each call adds its units again, so repeating a call raises the quantity. Only products sold online can be added, at the price a visitor pays. The answer's cart_url opens the store's website with the products in the shopper's own cart; nothing is ordered or paid here.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"product": "<product>"
},
"name": "cart_add_item"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| qty | No | Units to add (default 1). | |
| locale | No | Answer language: en (default en). Names, labels and URLs follow it. | |
| product | Yes | The product: its public_id from an earlier answer, its page URL or slug on the store's website, or the manufacturer model number. | |
| cart_token | No | The cart to add to, from an earlier cart answer; omit it to open a new cart. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lines | Yes | ||
| total | No | What the cart costs before delivery, discounts taken off; the store's website shows the same. | |
| limits | Yes | ||
| cart_url | Yes | Opens the store's website with these products in the shopper's own cart, where they review and order; nothing is ordered before that. | |
| currency | Yes | ||
| subtotal | Yes | Before delivery and the bundle saving. | |
| truncated | No | Present and true only when the answer outgrew the size budget and its last list items were left out; ask narrower to see them. | |
| cart_token | Yes | Pass it to the other cart tools. A secret: whoever holds it can change this cart. | |
| expires_at | Yes | ISO 8601; every change pushes it back. | |
| item_count | Yes | Units over all lines. | |
| answer_type | No | What this answer is, for rendering. | |
| vat_included | Yes | ||
| delivery_hint | Yes | How delivery is charged, in the answer language. | |
| discount_total | No | The bundle saving; 0 without a whole bundle. |