create_session, passing a shopper_id and a merchant_id. You pass its ID again when you open checkout with create_checkout, which ties the order back to the run that produced it.
Session tools need a test key. In keyless test mode they return
needs_test_key.Outcomes
Every session has oneoutcome. A new session starts as browsing.
A session that ends without an order is still recorded. A run where the agent searches and leaves tells you as much as one that buys.
The session record
get_session returns the session with its cart and order, if any, plus how long it ran and how many tool calls it made.
endedAt and durationMs are null while the session is still open.
Events
Every tool call the agent makes in a session is stored as an event. Events are append-only: they are never edited or deleted.get_session_events returns them in order.
Debugging with sessions
Use a session’s events to see what an agent did, step by step, and where it stopped. Uselist_sessions with outcome or shopper_id to find patterns across runs. For example, many abandoned sessions can point to friction at approval or checkout.
Session events record what the agent did. Order events, from get_order_events, record what happened to the order afterwards.