Skip to main content
POST
/
cart
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 cart = await client.cart.create({
  items: [
    {
      link: 'https://www.nike.com/u/custom-nike-ja-3-by-you-10002205',
      quantity: 2,
      selectedOptions: ['regular', 'black', '10-w'],
      metadata: { creatorSource: 'Frank Herbert' },
    },
  ],
  settings: {
    options: {
      allowPartialPurchase: true,
      collectBuyerEmail: 'required',
      collectBuyerAddress: 'optional',
      collectBuyerPhone: 'off',
    },
    commissionFeeFixed: { value: 1.99, currency: 'USD' },
    commissionFeePercent: 10,
    events: [],
  },
});

console.log(cart.data);
{
  "success": true,
  "status": "<string>",
  "message": "<string>",
  "data": {
    "cartId": "<string>",
    "checkoutUrl": "<string>",
    "data": {
      "items": [
        {
          "link": "https://www.nike.com/u/custom-nike-ja-3-by-you-10002205",
          "quantity": 1,
          "selectedOptions": [
            "regular",
            "black",
            "10-w"
          ],
          "selectedShipping": {
            "value": "standard"
          },
          "coupons": [
            "SUMMER26",
            "SAVE10"
          ],
          "metadata": {
            "creatorSource": "Frank Herbert"
          }
        }
      ],
      "settings": {
        "options": {
          "allowPartialPurchase": true,
          "collectBuyerEmail": "required",
          "collectBuyerAddress": "optional",
          "collectBuyerPhone": "off"
        },
        "commissionFeeFixed": {
          "value": 1.99,
          "currency": "USD"
        },
        "commissionFeePercent": 10,
        "events": [
          {
            "type": "order",
            "data": [
              {
                "type": "<string>",
                "points": 123
              }
            ],
            "conditional": {
              "type": "<string>",
              "operator": "equals",
              "value": "<string>"
            }
          }
        ]
      },
      "tags": {}
    },
    "metadata": {}
  }
}

Authorizations

x-api-key
string
header
required

Body

application/json
items
object[]
required

Items to include in the cart

Minimum array length: 1
settings
object
tags
object

Key-value tags to associate with the cart

Examples:
{ "region": "us-ny" }
{ "user": "hen-123" }

Response

Cart created successfully

success
boolean
required
status
string
required
message
string
required
data
object
required