Skip to main content
POST
/
cart
/
items
JavaScript
import HenrySDK from '@henrylabs/sdk';

const client = new HenrySDK({
  apiKey: process.env['HENRY_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.cart.items.add({
  productsDetails: [
    {
      name: "Men's Trail Runners",
      price: '100',
      productLink:
        'https://www.on.com/en-us/products/cloud-6-versa-m-3mf1004/mens/black-eclipse-shoes-3MF10040106',
      quantity: 1,
    },
  ],
  'x-user-id': 'x-user-id',
});

console.log(response.message);
{
  "success": true,
  "status": "<string>",
  "message": "<string>",
  "data": {
    "added_products": [
      {
        "productId": "<string>",
        "name": "<string>",
        "price": "<string>",
        "quantity": 123
      }
    ],
    "updated_products": [
      {
        "productId": "<string>",
        "name": "<string>",
        "price": "<string>",
        "quantity": 123,
        "previousQuantity": 123,
        "addedQuantity": 123
      }
    ],
    "cart_summary": {
      "total_items": 123,
      "total_unique_products": 123
    },
    "variant_checks": [
      {
        "productId": "<string>",
        "variantCheckRequestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
        "status": "<string>"
      }
    ]
  }
}

Authorizations

x-api-key
string
header
required

Headers

x-user-id
string
required

Body

application/json
productsDetails
object[]
required
Minimum array length: 1
checkVariantAvailability
boolean

Whether to check variant availability after adding to cart. If true, variant check requests will be created for products with metadata and requestIds returned.

Example:

false

Response

Product added to the cart successfully.

success
boolean
required
status
string
required
message
string
required
data
object