Request Format
Method:POST
Headers:
Body:
Common Fields
string
required
The cart operation:
"add", "remove", "update_quantity", or "clear".string
required
Store identifier.
string
required
Session/user identifier. Matches the
userId from the widget config, or an auto-generated ID if none was provided. Use this to look up the correct cart.Actions
Add
Add a product to the cart.string
required
Product SKU to add.
string
Product name (for convenience — you can ignore this and look up by SKU).
number
Quantity to add. Defaults to 1 if not provided.
number
Price as known by the AI (from the last products webhook call). You may use this or look up the current price yourself.
Remove
Remove a product from the cart.string
required
Product SKU to remove.
Update Quantity
Change the quantity of an existing cart item.string
required
Product SKU to update.
number
required
New quantity for the product.
Clear
Remove all items from the cart.Response Format
Return a JSON object withok (boolean) and an optional reason on failure:
Success
Failure
boolean
required
Whether the operation succeeded.
string
Human-readable reason for failure. The AI uses this to inform the customer and may suggest alternatives.
Common Rejection Reasons
You can use any string as the
reason value. The AI reads the reason and responds contextually. Common, descriptive reasons work best — for example, "max_3_per_customer" would lead the AI to say something like “There’s a limit of 3 per customer for this product.”Cart GET Endpoint
In addition to the POST webhook for operations, you can implement a GET endpoint to provide the initial cart state when a new conversation starts. Method:GET
Query Parameters:
Response:
array
required
Handler Examples
Best Practices
- Idempotency: If the same
addrequest arrives twice (due to retries), your handler should handle it gracefully — either add the quantity again or deduplicate. - Session mapping: The
session_idmaps to theuserIdfrom the SDK. If nouserIdwas provided, VIZOCHOK generates one per WebSocket connection. Plan your cart storage accordingly. - Response time: Keep responses under 5 seconds (the default timeout). Cart operations should be fast since they are blocking the AI’s response to the customer.