- Handle gift cards with recipient information and delivery scheduling.
- Use geographic coordinates for location-aware services, such as local-inventory checking and delivery-radius validation.
- Support multi-item carts with create, update, and per-item error handling.
Note: You can view the complete protocol reference for the Cart API and the Complete Checkout API.
Gift cards
Create a cart containing a gift card with recipient details and scheduled delivery.Geographic coordinates
Some merchants offer location-based services that require precise geographic positioning beyond standard postal addresses. The Cart API supports optional latitude/longitude coordinates to enable features like local inventory checking, distance-based pricing, delivery radius validation, and enhanced shipping calculations. This geographic data operates independently from shipping addresses, allowing you to provide location-aware commerce experiences while maintaining clean separation between postal and coordinate data.Latitude and longitude support strategy
Geographic coordinates are optional. This feature is for merchants who can provide enhanced location services. Geographic coordinates are provided in a separategeo_coordinates field, distinct from the shipping_address object. This clean separation allows:
- Postal addresses to remain focused on standard shipping data
- Geographic coordinates to provide precise location enhancement
- Independent handling of address and coordinate data
- Graceful degradation when coordinates aren’t supported
Geographic fields
Thegeo_coordinates object contains precise location data that enhances address information for location-aware services.
| Field | Description | Example |
|---|---|---|
latitude and longitude | Precise WGS84 coordinates in decimal degrees | latitude: "37.3349", longitude: "-122.0090" |
subdivision | Administrative division (state, province, region) using ISO 3166-2 format | subdivision: "CA" (California) |
country_code | ISO 3166-1 alpha-2 country code for the coordinate location | country_code: "US" |
Multi-item carts
The Cart API supports carts with multiple items. You can create a cart with several products in a single request, update the cart by replacing the full items list, and receive per-item error reporting when issues occur.Create a cart with multiple items
Include multiple items in theitems array, each with its own variant_id, quantity, and pricing.
Update cart items
To update a cart, send the complete items list in the request. The merchant compares this list to the existing cart and applies the differences. A single update can add new items, remove existing items, and change quantities.SHIRT-BLUE-M quantity increased from 2 to 3, JEANS-SLIM-32 was removed, and HAT-BLACK-OS was added.
Error handling for multiple items
Return a separate validation issue for each item that fails, and include thevariant_id so the AI agent can identify the affected item. Errors can be reported in two ways:
200/201withINCOMPLETEstatus — the cart was created or updated, but some items have issues. Report them in thevalidation_issuesarray.422 Unprocessable Entity— the cart could not be created or the update could not be applied. Report per-item errors indetails[].business_context.
INCOMPLETE response where 2 out of 3 items have inventory issues: