The headless client. It handles session, connection, cart, wishlist, threads and chat.
public class CartesianClient @JvmOverloads constructor( public val config: CartesianConfig, sessionStore: SessionStore = InMemorySessionStore(),) : Closeable
kotlin
When you use cartesian-ui, get it from Cartesian.client. Create one yourself only for headless use.
State
Property
Type
authState
StateFlow<AuthState>
connection
StateFlow<ConnectionState>
cart
StateFlow<Cart>
wishlist
StateFlow<Wishlist>
threads
StateFlow<List<ThreadSummary>>
chat
ChatSession
hasSavedSession
Boolean
Session
Method
HTTP
Notes
suspend signIn(sessionToken): User
GET /api/auth/session
Saves the token, connects, and loads the cart, wishlist and threads
suspend restore(): AuthState
GET /api/auth/session
Restores the saved token. Network and 5xx errors keep it.
suspend signOut()
POST /api/auth/logout
Clears the stored token
suspend connect() / disconnect()
WS /ws
Usually automatic
close()
Releases the socket and scope
Threads
Method
HTTP
suspend refreshThreads(): List<ThreadSummary>
GET /api/threads
suspend renameThread(threadId, name)
PATCH /api/threads/{id}
suspend deleteThread(threadId)
DELETE /api/threads/{id}
Cart
Method
HTTP
suspend refreshCart(): Cart
GET /api/account/cart
suspend addToCart(product, quantity = 1): Cart
POST /api/account/cart/items (or the thread cart during a conversation)