less than a minute read • Updated 11 minutes ago
Shipping Payload Reference
The JSON payload structure shared by Custom Shipping Code and Custom Shipping Endpoint.
Overview
Both Custom Shipping Code and Custom Shipping Endpoint receive the same JSON payload representing the current cart. In Custom Shipping Code, it's available as the cart global variable. For the Custom Shipping Endpoint, it's the POST body sent to your URL.
The payload includes everything about the current cart: items, the shipping address and store origin, totals, applied discounts, custom fields, and customer data. It follows the structure of Foxy's Hypermedia API cart resource.
Below is a reference of every section.
Top level fields
All fields at the root of the payload. The _embedded object containing the resources (shipment, items, discounts, etc.) is documented in the sections that follow.
Field | Description |
|---|---|
| Cart currency code (e.g., |
| Display symbol (e.g., |
| Language code for the cart session |
| Locale for number/date formatting (e.g., |
| Subtotal of all items (before shipping and taxes) |
| Total tax amount |
| Total shipping amount |
| Grand total (items + tax + shipping) |
| Total discount amount from coupons |
| Future shipping for subscription items |
| Future item price for subscription items |
| Billing first name |
| Billing last name |
| Billing company |
| Billing street address line 1 |
| Billing street address line 2 |
| Billing city |
| Billing state/province |
| Billing ZIP/postal code |
| Billing country code |
| Billing phone number |
| Shipping first name |
| Shipping last name |
| Shipping company |
| Shipping street address line 1 |
| Shipping street address line 2 |
| Shipping city |
| Shipping state/province |
| Shipping ZIP/postal code |
| Shipping country code |
| Shipping phone number |
| Customer's email address |
| Customer's IP address |
| Country name derived from IP |
| Boolean: whether the customer is using a saved shipping address |
| URI of the template set applied to this cart |
| URI of the customer resource |
| URI of the payment method |
| Session cookie name (e.g., |
| Session ID string |
| Cart creation timestamp |
| Cart last modified timestamp |
For shipping logic, the fx:shipment embedded resource (below) is generally more useful than the top level shipping fields because it also includes the store's origin address, package details, and shipment totals.
fx:shipment
The _embedded["fx:shipment"] object is where you'll spend most of your time. It contains the customer's shipping address, the store's origin address, package details, and rolled up totals for the shipment.
Customer shipping address
Field | Description |
|---|---|
| Customer's first name |
| Customer's last name |
| Company name (empty string if not provided) |
| Customer's email |
| Customer ID |
| Named address label (if using saved addresses) |
| Street address line 1 |
| Street address line 2 |
| City |
| State, province, or region code |
| ZIP or postal code |
| Two letter country code (e.g., |
| Boolean: whether the address is classified as residential |
Origin address
Field | Description |
|---|---|
| Store's origin state/province |
| Store's origin ZIP/postal code |
| Store's origin country code |
Package details
Field | Description |
|---|---|
| Number of packages (based on max package weight setting) |
| Per package weight |
| Package length |
| Package width |
| Package height |
Shipment totals
Field | Description |
|---|---|
| Total number of items in the cart |
| Combined weight of all items |
| Subtotal (item prices before shipping and taxes) |
| Total customs value for international shipments |
| Total handling fees from all categories |
| Total flat rate shipping from all categories |
| Total tax |
| Total shipping (may be 0 when your code runs, since rates haven't been selected yet) |
| Grand total |
Shipping service
Field | Description |
|---|---|
| ID of the currently selected shipping service (0 if none) |
| Description of the selected service (empty if none) |
Accessing in Custom Shipping Code
const shipment = cart['_embedded']['fx:shipment']; const country = shipment['country']; const region = shipment['region']; const postalCode = shipment['postal_code']; const weight = shipment['total_weight']; const subtotal = shipment['total_item_price']; const itemCount = shipment['item_count']; const isResidential = shipment['is_residential']; const originCountry = shipment['origin_country'];
fx:items
The _embedded["fx:items"] array contains each item in the cart. Each item includes its own embedded category and options.
Core item fields
Field | Description |
|---|---|
| Product name |
| Product code/SKU |
| Unit price |
| Quantity in the cart |
| Unit weight |
| Product URL |
| Product image URL |
Dimensions
Field | Description |
|---|---|
| Item length (0 if not set) |
| Item width (0 if not set) |
| Item height (0 if not set) |
Quantity limits
Field | Description |
|---|---|
| Minimum allowed quantity (0 = no minimum) |
| Maximum allowed quantity (0 = no maximum) |
Shipping
Field | Description |
|---|---|
| Ship to address name (for multi ship orders) |
Subscription fields
Field | Description |
|---|---|
| Subscription frequency string (empty if not a subscription) |
| Subscription start date |
| Next renewal date |
| Subscription end date |
| Boolean: whether this is a future dated subscription item |
Discount fields
Field | Description |
|---|---|
| Name of any item level discount |
| Discount type |
| Discount details string |
| Parent product code (for bundled/child items) |
Other
Field | Description |
|---|---|
| URI of the item's category |
| Expiration value (for downloadable items) |
| Item creation timestamp |
| Item last modified timestamp |
Embedded: fx:item_category
Each item embeds its full category object at _embedded["fx:item_category"]. This gives you access to the category's shipping configuration directly from the item.
Field | Description |
|---|---|
| Category code (e.g., |
| Category display name |
| Delivery type: |
| Default weight for products in this category |
| Weight unit ( |
| Length unit ( |
| Flat rate type: |
| Flat rate amount |
| Handling fee type: |
| Handling fee flat amount |
| Minimum handling fee (for percentage types) |
| Handling fee percentage |
| Default customs value |
Embedded: fx:item_options
Each item embeds its options at _embedded["fx:item_options"]. Each option has:
Field | Description |
|---|---|
| Option name (e.g., |
| Option value (e.g., |
| Price modifier applied by this option |
| Weight modifier applied by this option |
Accessing in Custom Shipping Code
const items = cart['_embedded']['fx:items'];
for (const item of items) {
// Core fields
const name = item['name'];
const price = item['price'];
const qty = item['quantity'];
const weight = item['weight'];
// Category
const catCode = item['_embedded']['fx:item_category']['code'];
const deliveryType = item['_embedded']['fx:item_category']['item_delivery_type'];
// Options
const options = item['_embedded']['fx:item_options'] || [];
for (const opt of options) {
console.log(opt['name'], opt['value'], opt['price_mod']);
}
// Subscription check
if (item['subscription_frequency']) {
// This is a subscription item
}
}fx:custom_fields
The _embedded["fx:custom_fields"] array contains custom data passed to shipping via h: session attributes, data-fc-shipping-custom-field checkout fields, or JavaScript events. Each entry is an object with name and value properties.
Note: this is an array, not a key/value object. You need to loop or use .find() to locate a specific field by name.
Accessing in Custom Shipping Code
const fields = cart['_embedded']['fx:custom_fields'] || [];
// Find a specific field
const giftWrap = fields.find(f => f['name'] === 'gift_wrap');
if (giftWrap && giftWrap['value'] === 'yes') {
rates.price('+5');
}See [Passing Custom Fields to Shipping] for how to add custom fields to the payload.
fx:discounts
The _embedded["fx:discounts"] array contains any coupons or discounts applied to the cart. Each entry has code and amount properties.
Accessing in Custom Shipping Code
const discounts = cart['_embedded']['fx:discounts'] || [];
for (const d of discounts) {
if (d['code'] === 'freeshipping') {
rates.hide();
rates.add(11000, 0, '', 'Free Shipping');
}
}fx:shipping_results
The _embedded["fx:shipping_results"] array contains any shipping rates already returned by carriers or the custom endpoint before your Custom Shipping Code runs. This is typically empty when the custom endpoint receives the payload (since it runs in parallel with carriers), but in Custom Shipping Code it may be populated with carrier rates.
fx:customer
The _embedded["fx:customer"] object contains the customer's account data, including embedded attributes.
Field | Description |
|---|---|
| Customer ID |
| Customer first name |
| Customer last name |
| Customer email |
| Tax ID (if provided) |
| Boolean: whether this is a guest checkout |
| Last login timestamp |
| Account creation timestamp |
Customer attributes are embedded at _embedded["fx:customer"]["_embedded"]["fx:attributes"]. Each attribute has name, value, and visibility properties. These are useful for loyalty programs or customer tier based shipping logic:
const customer = cart['_embedded']['fx:customer'];
const attrs = customer['_embedded']['fx:attributes'] || [];
const loyaltyLevel = attrs.find(a => a['name'] === 'Loyalty_Level');
if (loyaltyLevel && loyaltyLevel['value'] === 'Gold') {
rates.add(10001, 0, '', 'Free Gold Member Shipping');
}Example payload
Below is a condensed example showing the key parts of a typical payload. The _links sections (HAL hypermedia links) are omitted for readability as they're not typically used in shipping logic.
{
"_embedded": {
"fx:items": [
{
"name": "Fancy Widget",
"code": "abc123",
"price": 80.95,
"quantity": 1,
"weight": 30,
"length": 0,
"width": 0,
"height": 0,
"shipto": "",
"image": "https://example.com/widget.jpg",
"subscription_frequency": "",
"is_future_line_item": false,
"_embedded": {
"fx:item_options": [
{
"name": "Colour",
"value": "Sparkletoots",
"price_mod": 0,
"weight_mod": 0
}
],
"fx:item_category": {
"code": "DEFAULT",
"name": "Default for all products",
"item_delivery_type": "shipped",
"default_weight": 30,
"default_weight_unit": "LBS",
"shipping_flat_rate_type": "per_order",
"shipping_flat_rate": 5,
"handling_fee_type": "none",
"handling_fee": 0,
"handling_fee_percentage": 0
}
}
}
],
"fx:discounts": [],
"fx:custom_fields": [],
"fx:shipment": {
"first_name": "Jane",
"last_name": "Doe",
"company": "NewCo",
"address1": "555 Mulberry Dr",
"city": "SAN DIEGO",
"region": "CA",
"postal_code": "92107",
"country": "US",
"is_residential": true,
"origin_region": "NY",
"origin_postal_code": "11110",
"origin_country": "US",
"item_count": 1,
"total_weight": 30,
"total_item_price": 80.95,
"total_handling_fee": 0,
"total_flat_rate_shipping": 0,
"package_count": 1,
"package_weight": 30
},
"fx:shipping_results": [],
"fx:customer": {
"id": 3456789,
"first_name": "Jane",
"last_name": "Doe",
"email": "Jane@example.tld",
"is_anonymous": false,
"_embedded": {
"fx:attributes": [
{
"name": "Loyalty_Points",
"value": "5087",
"visibility": "public"
}
]
}
}
},
"total_item_price": 80.95,
"total_tax": 0,
"total_shipping": 0,
"total_order": 80.95,
"total_discount": 0,
"currency_code": "USD",
"currency_symbol": "$",
"locale_code": "en_US",
"billing_city": "SAN DIEGO",
"billing_state": "CA",
"billing_postal_code": "92107",
"billing_country": "US",
"customer_ip": "1.1.1.1",
"ip_country": "United States"
}