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.

circle-info

Cart estimation is not a part of the checkout process and is instead best used as a method for anticipating the behavior of a cart or debugging a failed cart.

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
    }
  ]
}
circle-exclamation

Inventory Information (BETA)

For supported platforms, SKUs may include an inventory object with detailed stock information:

Field
Type
Description

sufficient_inventory

Boolean

Whether there is enough inventory for the requested quantity

available_inventory

Integer

The total quantity available for purchase

circle-info

The inventory object is currently in BETA and may not be available for all merchants or platforms.

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:

  1. Your support team — Full messages help diagnose issues without escalation

  2. End users — Provides context about what went wrong (display directly or use to craft friendly messages)

  3. 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

circle-info

Best Practice: Use structured fields (available, inventory) for validation logic. Log external_error_messages for troubleshooting and display them to users for context. These messages are the most detailed diagnostic information available when platform issues occur.

Non-Tracked Inventory

Some merchants don't track inventory. In these cases:

  • available will be true (the item can be purchased)

  • available_inventory may be 0, 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

circle-exclamation

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

Code
Error
Description

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

Common Use Cases

Use Case
What to Check

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


Estimate Cart

post
Header parameters
X-Violet-TokenstringRequired
X-Violet-App-SecretstringRequired
X-Violet-App-Idinteger · int32Required
Body

Calculate Cart Request

base_currencystring · enum · min: 3 · max: 3Optional

The base currency the cart should be calculated in.

Default: USDPossible values:
Responses
post
/carts/estimate

Last updated

Was this helpful?