A cart is a record, not session data, so it can be restored from a link and merged into an account at sign-in. Every route but the list is open to visitors, with no credentials and no CSRF token. Each has two forms: with the cart’s uuid, /cdna-api/cart/{uuid}/…, for a headless client, and without it, for the visitor’s current cart, found from the cart cookie, which the response sets.
A cart is saved only once something is added: adding an item without a uuid creates it, and its uuid is in the response. Every response returns the whole cart under data.cart. A business failure, such as an unknown SKU or code, is not an HTTP error: the answer is 200, with the reason in data.cart.messages. A product that has variants is refused the same way. A quantity that breaks a purchase control is kept, with the line marked available: false and an error message. Each message has an id for Dismiss a message. With inventory tracking on, an item that no single warehouse can supply in full stays in the cart with a warning in messages, such as “Only 2 in stock” or “Only 2 can be sent from one location”, and Create a checkout refuses it.