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.fetch('crt_sa2aEsCz9PRM', {
buyer: {
name: { firstName: 'John', lastName: 'Doe' },
email: 'john@example.com',
phone: '+15551234567',
shippingAddress: {
line1: '123 Main St',
city: 'New York',
province: 'NY',
postalCode: '10001',
countryCode: 'US',
},
},
});
console.log(response.data);curl --request POST \
--url https://api.henrylabs.ai/v1/cart/{cartId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"buyer": {
"name": {
"firstName": "John",
"lastName": "Doe"
},
"email": "john@example.com",
"phone": "+15551234567",
"shippingAddress": {
"line1": "123 Main St",
"city": "New York",
"province": "NY",
"postalCode": "10001",
"countryCode": "US"
}
}
}
'import requests
url = "https://api.henrylabs.ai/v1/cart/{cartId}"
payload = { "buyer": {
"name": {
"firstName": "John",
"lastName": "Doe"
},
"email": "john@example.com",
"phone": "+15551234567",
"shippingAddress": {
"line1": "123 Main St",
"city": "New York",
"province": "NY",
"postalCode": "10001",
"countryCode": "US"
}
} }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.henrylabs.ai/v1/cart/{cartId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'buyer' => [
'name' => [
'firstName' => 'John',
'lastName' => 'Doe'
],
'email' => 'john@example.com',
'phone' => '+15551234567',
'shippingAddress' => [
'line1' => '123 Main St',
'city' => 'New York',
'province' => 'NY',
'postalCode' => '10001',
'countryCode' => 'US'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.henrylabs.ai/v1/cart/{cartId}"
payload := strings.NewReader("{\n \"buyer\": {\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n },\n \"email\": \"john@example.com\",\n \"phone\": \"+15551234567\",\n \"shippingAddress\": {\n \"line1\": \"123 Main St\",\n \"city\": \"New York\",\n \"province\": \"NY\",\n \"postalCode\": \"10001\",\n \"countryCode\": \"US\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.henrylabs.ai/v1/cart/{cartId}")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"buyer\": {\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n },\n \"email\": \"john@example.com\",\n \"phone\": \"+15551234567\",\n \"shippingAddress\": {\n \"line1\": \"123 Main St\",\n \"city\": \"New York\",\n \"province\": \"NY\",\n \"postalCode\": \"10001\",\n \"countryCode\": \"US\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.henrylabs.ai/v1/cart/{cartId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"buyer\": {\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n },\n \"email\": \"john@example.com\",\n \"phone\": \"+15551234567\",\n \"shippingAddress\": {\n \"line1\": \"123 Main St\",\n \"city\": \"New York\",\n \"province\": \"NY\",\n \"postalCode\": \"10001\",\n \"countryCode\": \"US\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"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",
"affiliateProductLink": "https://partner.example.com/click?url=https%3A%2F%2Fwww.nike.com%2Fu%2Fcustom-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"
},
"serviceFeeFixed": {
"value": 1.99,
"currency": "USD"
},
"serviceFeePercent": 10,
"events": [
{
"data": [
{
"type": "<string>",
"points": 123
}
],
"conditional": {
"type": "<string>",
"value": "<string>"
}
}
]
},
"tags": {}
},
"metadata": {}
}
}{
"success": true,
"status": "<string>",
"message": "<string>"
}{
"success": true,
"status": "<string>",
"message": "<string>"
}{
"success": true,
"status": "<string>",
"message": "<string>"
}Cart
Cart Fetch
Fetch a single cart by ID and optionally prefill buyer details in the returned checkout URL.
POST
/
cart
/
{cartId}
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.fetch('crt_sa2aEsCz9PRM', {
buyer: {
name: { firstName: 'John', lastName: 'Doe' },
email: 'john@example.com',
phone: '+15551234567',
shippingAddress: {
line1: '123 Main St',
city: 'New York',
province: 'NY',
postalCode: '10001',
countryCode: 'US',
},
},
});
console.log(response.data);curl --request POST \
--url https://api.henrylabs.ai/v1/cart/{cartId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"buyer": {
"name": {
"firstName": "John",
"lastName": "Doe"
},
"email": "john@example.com",
"phone": "+15551234567",
"shippingAddress": {
"line1": "123 Main St",
"city": "New York",
"province": "NY",
"postalCode": "10001",
"countryCode": "US"
}
}
}
'import requests
url = "https://api.henrylabs.ai/v1/cart/{cartId}"
payload = { "buyer": {
"name": {
"firstName": "John",
"lastName": "Doe"
},
"email": "john@example.com",
"phone": "+15551234567",
"shippingAddress": {
"line1": "123 Main St",
"city": "New York",
"province": "NY",
"postalCode": "10001",
"countryCode": "US"
}
} }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.henrylabs.ai/v1/cart/{cartId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'buyer' => [
'name' => [
'firstName' => 'John',
'lastName' => 'Doe'
],
'email' => 'john@example.com',
'phone' => '+15551234567',
'shippingAddress' => [
'line1' => '123 Main St',
'city' => 'New York',
'province' => 'NY',
'postalCode' => '10001',
'countryCode' => 'US'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.henrylabs.ai/v1/cart/{cartId}"
payload := strings.NewReader("{\n \"buyer\": {\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n },\n \"email\": \"john@example.com\",\n \"phone\": \"+15551234567\",\n \"shippingAddress\": {\n \"line1\": \"123 Main St\",\n \"city\": \"New York\",\n \"province\": \"NY\",\n \"postalCode\": \"10001\",\n \"countryCode\": \"US\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.henrylabs.ai/v1/cart/{cartId}")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"buyer\": {\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n },\n \"email\": \"john@example.com\",\n \"phone\": \"+15551234567\",\n \"shippingAddress\": {\n \"line1\": \"123 Main St\",\n \"city\": \"New York\",\n \"province\": \"NY\",\n \"postalCode\": \"10001\",\n \"countryCode\": \"US\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.henrylabs.ai/v1/cart/{cartId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"buyer\": {\n \"name\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\"\n },\n \"email\": \"john@example.com\",\n \"phone\": \"+15551234567\",\n \"shippingAddress\": {\n \"line1\": \"123 Main St\",\n \"city\": \"New York\",\n \"province\": \"NY\",\n \"postalCode\": \"10001\",\n \"countryCode\": \"US\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"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",
"affiliateProductLink": "https://partner.example.com/click?url=https%3A%2F%2Fwww.nike.com%2Fu%2Fcustom-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"
},
"serviceFeeFixed": {
"value": 1.99,
"currency": "USD"
},
"serviceFeePercent": 10,
"events": [
{
"data": [
{
"type": "<string>",
"points": 123
}
],
"conditional": {
"type": "<string>",
"value": "<string>"
}
}
]
},
"tags": {}
},
"metadata": {}
}
}{
"success": true,
"status": "<string>",
"message": "<string>"
}{
"success": true,
"status": "<string>",
"message": "<string>"
}{
"success": true,
"status": "<string>",
"message": "<string>"
}Authorizations
Path Parameters
Unique identifier for the cart
Example:
"crt_sa2aEsCz9PRM"
Body
application/json
Optional buyer details to prefill at checkout. When provided, the returned checkoutUrl will include these as query params.
Show child attributes
Show child attributes
Was this page helpful?
⌘I