Advanced: a shopping cart
Page 5 of 7
A shopping session lets you fill one cart for the person with several items and quantities, and
hand over its cartUrl. It is the advanced option: for a single offer, the buy link above is
enough. An agent with HTTP access can manage the cart without installing a connector.
-
Keep one shopping session for this shopper. If you do not have one, open it with
POST /ls_journeys/agent_sessionsand{}: one call, no sign-in, no key, no approval. The optional body{"agent": "<your name>"}is only a label for the people who read the journey, never an identity. The answer carriestoken,expiresAtandcartUrl. Keep the token private: it is shown only in this answer. RetaincartUrl. This happens silently, without asking the person for an account, an email or an API key. -
Send
Authorization: Bearer <token>on every cart request. A token from the MCP connector (journey.token) works too: reuse it instead of creating a second session. -
Read
GET /cart/currentbefore editing or answering what is in the cart. OmitknownVersionto get the full answer.cart.linescontains each line'sid, option, title, quantity and price;cart.totalscontainslineCount,unitCount,totalMinorandcurrency. An empty cart has no lines. Never reconstruct its contents from earlier conversation or links. -
Change only what the person requested, using ids returned by the API:
Request Operation Body Add the chosen option POST /cart/lines{"lsOfferOptionId":"<option.id>","quantity":1,"quantityMode":"set"}Change its quantity PATCH /cart/lines/{lineId}{"quantity":2}Remove it DELETE /cart/lines/{lineId}None lineIdiscart.lines[].id, not an offer or option id. Quantity is the desired final count, from 1 to 50; use DELETE to remove a line. For "add another", read the current quantity and set the requested final count. Repeating a set never adds more units. Every successful change returns the current cart; confirm from that answer, with the quantity and total, in one sentence. -
Give the person the returned private
cartUrlto open the same cart and pay. Hand over one link per purchase: thecartUrlonce you have edited a cart, an offer's buy link when you have not. If a response is lost, read the cart before retrying; if a line disappeared, do not try another id.
With the MCP connector, use get_cart, add_to_cart, update_cart and remove_from_cart with
one journeyToken. Its lines carry lineId; its replies include cartUrl. Follow the tool
schemas and returned errors.
A session sees its own cart. It cannot see a separate cart already in the person's browser or
account until the person opens the session's cartUrl and explicitly attaches their account,
or confirms through the connector's identity tools. Never call a fresh empty session their
existing cart. If the token expires, explain that you lost access; do not silently create a new
cart and claim the old one is empty.