Request Format
Method:POST
Headers:
| Header | Value |
|---|---|
Content-Type | application/json |
X-VIZOCHOK-Signature | sha256=<hex_digest> |
X-VIZOCHOK-Timestamp | Unix timestamp (seconds) |
Common Fields
The cart operation:
"add", "remove", "update_quantity", or "clear".Store identifier.
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.Product SKU to add.
Product name (for convenience — you can ignore this and look up by SKU).
Quantity to add. Defaults to 1 if not provided.
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.Product SKU to remove.
Update Quantity
Change the quantity of an existing cart item.Product SKU to update.
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
Whether the operation succeeded.
Human-readable reason for failure. The AI uses this to inform the customer and may suggest alternatives.
Common Rejection Reasons
| Reason | When to Return | AI Behavior |
|---|---|---|
out_of_stock | Product is unavailable | Suggests alternative products |
product_not_found | SKU does not exist | Informs customer, offers to search again |
quantity_exceeded | Not enough stock for requested quantity | Suggests a lower quantity |
not_in_cart | Trying to remove/update an item not in cart | Informs customer |
missing_sku | No SKU provided | Reports error |
missing_params | Required parameters missing | Reports error |
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:
| Parameter | Description |
|---|---|
store_id | Store identifier |
session_id | Session/user identifier |
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.