Documentation Index
Fetch the complete documentation index at: https://docs.henrylabs.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Henry cart is a persistent server-side object that holds items from any merchant in a single checkout experience. Creating a cart immediately returns both acartId and a checkoutUrl - there’s no separate step to generate a checkout link.
Prerequisites
Create a cart
cart.create is the starting point. Pass an array of items using product link URLs (from search results or any product page), and optionally configure cart settings and tags. Each item can also include an affiliateProductLink, selected options, shipping, coupons, and metadata.
The
checkoutUrl is your hosted checkout link - share it with your user directly. See Checkout for how to embed it.Cart creation response
Manage cart items
Add an item
Add a product to an existing cart. Use the productlink URL as the identifier.
Update an item quantity
Setting
quantity to 0 via cart.item.update also removes the item from the cart.Remove an item
Fetch carts
Henry exposes two retrieval methods with different shapes:| Method | Returns | Use when |
|---|---|---|
cart.list({ cartId?, tags? }) | Array of carts | Looking up by tags, or paging through many carts |
cart.fetch(cartId, { buyer? }) | A single cart | You know the cartId and optionally want to prefill checkout |
List carts
Fetch a single cart (with optional buyer prefill)
cart.fetch returns one cart by id. Pass an optional buyer to prefill the hosted checkout - the returned checkoutUrl will embed the buyer details as query params so fields render pre-filled when the user opens it.
buyer is purely a UX convenience for hosted checkout - it does not persist on the cart. To actually commit buyer info, use Headless Checkout via cart.checkout.purchase.Delete a cart
Remove a cart entirely when it’s no longer needed (e.g. on session logout).Cart item fields reference
| Field | Type | Required | Description |
|---|---|---|---|
link | string | Y | Direct product URL from any merchant |
affiliateProductLink | string | - | Optional affiliate or redirect URL used for fulfillment. If omitted, link is used. |
quantity | number | - | Defaults to 1 |
selectedOptions | string[] | - | Ordered array of option values e.g. ['regular', 'black', '10-w'] |
selectedShipping | { id?, value? } | - | Preferred shipping method |
coupons | string[] | - | Coupon codes to apply at checkout |
metadata | object | - | Arbitrary key/value data passed through to orders |
Cart tags
Attach key-valuetags when creating a cart to associate it with your own identifiers (e.g. user IDs, regions, campaigns). You can then filter carts by tags with cart.list.
Cart settings reference
| Field | Type | Description |
|---|---|---|
options.allowPartialPurchase | boolean | Let buyers remove items during checkout |
options.collectBuyerEmail | "off" | "required" | "optional" | Email collection behavior |
options.collectBuyerAddress | "off" | "required" | "optional" | Address collection behavior |
options.collectBuyerPhone | "off" | "required" | "optional" | Phone collection behavior |
commissionFeePercent | number | Commission as a percentage of the order total (0-100) |
commissionFeeFixed | { value, currency } | Fixed commission amount added to the order |
events | CartEvent[] | Triggers to fire when cart events occur |
Cart events
settings.events lets you attach triggers to cart lifecycle events. Each entry declares an event type to listen for, an optional conditional, and a list of actions (data) to fire when it occurs.
Supported event types
Order events
| Event type | Fires when |
|---|---|
order | Any order event |
order.purchase | Any purchase event (full or partial, any outcome) |
order.purchase.pending | Purchase created, awaiting payment confirmation |
order.purchase.processing | Payment confirmed, placing with merchants |
order.purchase.complete | Purchase completed (full or partial) |
order.purchase.cancelled | Purchase cancelled (full or partial) |
order.purchase.full | A full purchase resolves to any outcome |
order.purchase.full.pending | Full purchase pending payment confirmation |
order.purchase.full.processing | Full purchase confirmed, placing with merchants |
order.purchase.full.complete | All items placed successfully |
order.purchase.full.cancelled | Full purchase cancelled |
order.purchase.partial | A partial purchase resolves to any outcome |
order.purchase.partial.pending | Partial purchase pending |
order.purchase.partial.processing | Partial purchase processing |
order.purchase.partial.complete | Partial purchase completed |
order.purchase.partial.cancelled | Partial purchase cancelled |
order.item | Any item-level event |
order.item.pending | Individual item pending |
order.item.processing | Individual item processing |
order.item.complete | Individual item placed successfully |
order.item.failed | Individual item failed |
order.update | Any order update event |
order.update.3ds-required | 3DS authentication required |
order.update.adding-to-cart | Adding item to merchant cart |
order.update.filling-address-details | Filling in address details |
order.update.filling-card-details | Filling in card details |
order.update.submitting-order | Submitting the order |
order.update.changing-quantity | Changing item quantity |
order.update.applying-coupon | Applying a coupon code |
order.update.selecting-shipping | Selecting shipping option |
order.update.selecting-options | Selecting product options |
Points & tier events
| Event type | Fires when |
|---|---|
points | Any points event |
points.give | Points awarded to a buyer |
points.remove | Points removed from a buyer |
tier | Any tier event |
tier.give | A tier assigned to a buyer |
tier.remove | A tier removed from a buyer |
Supported action types
| Action type | Description | Required fields |
|---|---|---|
send_webhook | POST the event payload to a registered webhook | webhookUUID |
send_email | Send a notification email | - |
give_points_fixed | Award a fixed number of points to the buyer | points |
give_points_per_spent | Award points proportional to the order amount | points, perAmount |
remove_points_fixed | Deduct a fixed number of points from the buyer | points |
remove_points_per_spent | Deduct points proportional to the order amount | points, perAmount |
give_tier | Assign a loyalty tier to the buyer | tierUUID |
remove_tier | Remove the buyer’s current tier | - |
Example - webhook on successful purchase
Example - award points on purchase
Conditionals
Add aconditional to a trigger to gate it on the buyer’s current tier or points balance:
Register and manage webhooks in the Henry Dashboard. The
webhookUUID is the identifier assigned when you create a webhook endpoint. See
Webhooks for payload shape, verification, and the full event reference.Error handling
| Error | Cause |
|---|---|
400 Bad Request | Missing required fields or invalid URL in link |
401 Unauthorized | Invalid API key |
404 Not Found | cartId does not exist or belongs to a different app |
Next steps
Once your cart is ready, proceed to checkout:Checkout
Embed the hosted checkout or call the headless purchase API
Order Management
Track and list orders after checkout completes