Public previewSee what changed →
All guides

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.

  1. Keep one shopping session for this shopper. If you do not have one, open it with POST /ls_journeys/agent_sessions and {}: 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 carries token, expiresAt and cartUrl. Keep the token private: it is shown only in this answer. Retain cartUrl. This happens silently, without asking the person for an account, an email or an API key.

  2. 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.

  3. Read GET /cart/current before editing or answering what is in the cart. Omit knownVersion to get the full answer. cart.lines contains each line's id, option, title, quantity and price; cart.totals contains lineCount, unitCount, totalMinor and currency. An empty cart has no lines. Never reconstruct its contents from earlier conversation or links.

  4. Change only what the person requested, using ids returned by the API:

    RequestOperationBody
    Add the chosen optionPOST /cart/lines{"lsOfferOptionId":"<option.id>","quantity":1,"quantityMode":"set"}
    Change its quantityPATCH /cart/lines/{lineId}{"quantity":2}
    Remove itDELETE /cart/lines/{lineId}None

    lineId is cart.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.

  5. Give the person the returned private cartUrl to open the same cart and pay. Hand over one link per purchase: the cartUrl once 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.