MobiariDocs

Set a cart line

POST
/storefront-api/{store_slug}/api/cart/items

Sets the variant's quantity in the cart (adding the line if needed); 0 removes it. Stock is reserved for the cart and any selected freight is cleared, since the parcel changed. Creates the cart when the shopper has none. Answers with the whole cart.

Path Parameters

store_slug*string

Store slug

Header Parameters

x-cart-id?|

The shopper's cart; the cart_id cookie or body field works too

Formatuuid
Idempotency-Key?string

A unique value (e.g. a UUID) per logical request. Retrying with the same key within 24 hours replays the first response instead of repeating the side effect; the replay carries Idempotent-Replayed: true. Reusing a key for a different request is a 422 idempotency_key_reused; retrying while the first is still running is a 409 idempotency_request_in_progress. JSON bodies up to 1 MB.

Lengthlength <= 255

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/storefront-api/string/api/cart/items" \  -H "Content-Type: application/json" \  -d '{    "quantity": 0,    "variant_id": "string"  }'
{
  "contact_draft": {
    "additional_info": "string",
    "city": "string",
    "email": "string",
    "name": "string",
    "neighborhood": "string",
    "number": "string",
    "phone": "string",
    "state": "string",
    "street": "string",
    "zip_code": "string"
  },
  "currency": "string",
  "destination_postal_code": "string",
  "discount_cents": 0,
  "freight_options": [
    {
      "carrier_name": "string",
      "delivery": "string",
      "delivery_days": 0,
      "dispatch": "string",
      "is_required_term": true,
      "logo": "string",
      "modal": "string",
      "option_id": "string",
      "price": 0,
      "provider_code": "string",
      "raw": {},
      "service_name": "string",
      "service_type": "string",
      "shipping_carrier": "string",
      "shipping_carrier_document": "string",
      "shipping_cents": 0
    }
  ],
  "fulfillment_method": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "item_count": 0,
  "items": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "product_id": "0d012afa-f885-4e65-aeca-37e27701e2d1",
      "quantity": 0,
      "sku": "string",
      "title": "string",
      "total_cents": 0,
      "unit_price_cents": 0,
      "variant_id": "8a2d415d-59aa-4132-bef3-011f97c4a0f6"
    }
  ],
  "pickup_location_id": "5eb4dd60-b565-4dc0-8014-f7a790828fbb",
  "requires_shipping": true,
  "selected_freight_option_id": "string",
  "shipping_cents": 0,
  "store_id": "7fe87115-950c-4ae8-bd7e-970406bc9ac0",
  "subtotal_cents": 0,
  "tax_cents": 0,
  "total_cents": 0
}
{
  "code": "not_found",
  "details": {},
  "error": "Order not found"
}
{
  "code": "not_found",
  "details": {},
  "error": "Order not found"
}
{
  "code": "not_found",
  "details": {},
  "error": "Order not found"
}
{
  "code": "not_found",
  "details": {},
  "error": "Order not found"
}
{
  "code": "not_found",
  "details": {},
  "error": "Order not found"
}