Estimate Cart
Using the Estimate Cart endpoint you can discover the estimated totals and available shipping methods for any combination of Sku's and a shipping address. This feature can be useful for debugging failed carts where one or more Sku's may have been unavailable in a certain region or no shipping methods were returned for an address.
When using Estimate Cart you do not need to manage the lifecycle of a cart. Violet will handle the creation, modification, and deletion of any external carts that may need to be created while estimating a cart.
When the Estimate Cart process fails in the external commerce platform, Violet will attempt to parse and surface all error messages from the external system so that you are able to fully understand why the estimation failed. The most common reasons for failure will be Sku unavailability and incorrectly formatted shipping addresses.
Response Behavior
SKU Availability
Each SKU in the response includes an available boolean field indicating whether the item can be purchased. When a SKU is unavailable (e.g., out of stock, discontinued, or region-restricted), the available field will be false.
{
"skus": [
{
"sku_id": 10000,
"name": "Nintendo Entertainment System",
"available": true,
"price": 9999,
"quantity": 2,
"line_price": 19998
},
{
"sku_id": 10001,
"name": "Discontinued Controller",
"available": false,
"price": 2999,
"quantity": 1,
"line_price": 2999
}
]
}SKUs with available: false are still included in the response but should not be used in cart creation. Always check this field before proceeding to checkout.
Inventory Information (BETA)
For supported platforms, SKUs may include an inventory object with detailed stock information:
sufficient_inventory
Boolean
Whether there is enough inventory for the requested quantity
available_inventory
Integer
The total quantity available for purchase
External Error Messages
Each estimated cart may include an external_error_messages array containing raw error strings from the commerce platform. These messages provide additional context when estimation fails or encounters issues.
Interpreting Error Messages
The external_error_messages array contains raw error strings from commerce platforms. While these messages vary by platform and aren't suitable for programmatic parsing, they're valuable for:
Your support team — Full messages help diagnose issues without escalation
End users — Provides context about what went wrong (display directly or use to craft friendly messages)
Escalation to Violet — Include these messages when contacting support for faster resolution
Scenario
skus array
external_error_messages
Recommended Action
SKU unavailable
Contains SKU with available: false
May contain product name
Log message for support; show user the SKU is unavailable
Insufficient inventory (BETA)
Contains SKU with inventory.sufficient_inventory: false
May show quantity details
Display message to user; log for troubleshooting
Merchant unreachable
Empty or missing
Contains errors like "HTTP 404 Not Found"
Merchant-level failure — log for ops team; mark all merchant items invalid
Invalid discount
SKUs present (may be available)
Contains discount error
Display to user; discount issue doesn't affect SKU availability
Non-Tracked Inventory
Some merchants don't track inventory. In these cases:
availablewill betrue(the item can be purchased)available_inventorymay be0, negative, or absent
Always trust the available boolean as the primary indicator. Only use inventory fields when they're present AND the merchant tracks inventory.
Handling Estimation Errors
Important: For multi-merchant carts, the API may return HTTP 200 even when individual merchants fail. Always check the errors array regardless of HTTP status code.
Single-Merchant Estimation Errors
When estimating a cart with SKUs from a single merchant fails, the error will be surfaced as an API Exception in the response body with a 400 or 422 HTTP status.
Example: Response when single-merchant estimation fails due to an unavailable SKU.
Multi-Merchant Estimation Errors
When estimating a cart with SKUs from multiple merchants, the response will return HTTP 200 with any errors nested in the errors array. Valid SKUs from successful merchants will still be included in estimated_carts.
Example: Response when one merchant fails while another succeeds. The entity_type of SKU indicates which SKU caused the error, referenced by entity_id.
Common Error Codes
2002
sku_not_found
The requested SKU does not exist in Violet's catalog
2003
sku_not_available
The SKU exists but is currently unavailable
4219
order_sku_not_available
The SKU is no longer available for purchase
4223
insufficient_inventory
Not enough inventory for the requested quantity
4232
invalid_shipping_address
The provided shipping address is invalid
4236
blocked_address
The address has been blocked due to fraud history
Response Examples
Successful Estimation (All SKUs Available)
Partial Availability (Some SKUs Unavailable)
When some SKUs in a single-merchant cart are unavailable, they will be included in the response with available: false. The totals will only reflect the available items.
Insufficient Inventory
When the requested quantity exceeds available stock, the inventory object (when available) provides details:
Best Practices
Recommended Implementation Pattern
Common Use Cases
Pre-checkout validation
available field on each SKU
Inventory management
inventory.sufficient_inventory and inventory.available_inventory
Shipping availability
has_shipping_methods and available_shipping_methods array
Debugging failed carts
errors array and external_error_messages
Multi-merchant carts
Check each estimated_cart individually; some may succeed while others fail
Calculate Cart Request
The base currency the cart should be calculated in.
USDPossible values: success
bad request
unauthorized
not found
internal server error
Last updated
Was this helpful?