Backend API
A cart is a pending request to purchase products from your store. Carts contain all the information needed to fulfill a purchase. Once the customer is ready to complete their purchase, a simple API call is made to convert a cart to an order.
When managing items within a cart, utilize the items.id rather than the product.id
Fields
id
objectIdUnique identifier for the cart.
abandoned
booleanIndicates the cart was abandoned after 3 hours of inactivity. After being marked as abandoned, this field is automatically set back to false after an update to items, billing, or shipping info.
abandoned_notifications
intNumber of abandoned cart notifications sent to the customer.
account
AccountExpandable link to the customer's account.
account_credit_amount
currencyAmount of customer's account credit applied for initial payment, if applicable.
account_credit_applied
booleanIndicates the customer's account credit is applied to the initial payment.
account_id
objectIdID of the customer's account.
account_info_saved
booleanIndicates the customer chose to save shipping and billing information to their account when submitting the order.
account_logged_in
booleanIndicates the customer was logged into their account when placing the order.
active
booleanIndicates the cart has been updated by a customer within the last 3 hours.
billing
objectThe customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
billing.name
stringrequiredBilling full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
billing.first_name
stringBilling first name. If name is updated, then first_name will be automatically updated as the first word of the name.
billing.last_name
stringBilling last name. If name is updated, then last_name will be automatically updated as the last words of the name.
billing.address1
stringBilling address line 1: (street address/PO box/company name).
billing.address2
stringBilling address line 2: (apartment/suite/unit/building).
billing.city
stringrequiredBilling city/district/suburb/town/village.
billing.state
stringBilling state/county/province/region.
billing.zip
stringBilling zip/postal code.
billing.country
stringTwo-letter ISO country code.
billing.phone
stringBilling phone number.
billing.method
stringMethod of payment. Can be card, account, amazon, paypal, or any one of the manual methods defined in payment settings.
billing.card
objectCredit card billing details used when billing.method=card.
card.token
stringrequiredToken generated by Swell Checkout or Stripe.js.
card.exp_month
intTwo-digit number representing the credit card expiration month.
card.exp_year
intFour-digit number representing the credit card expiration year.
card.brand
stringCredit card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
card.last4
stringLast four digits of the card number.
card.gateway
stringID of the payment gateway that should be used to process payments.
card.test
booleanIndicates this is a test card.
card.address_check
stringWhen used with a payment gateway that performs address checks and address1 was provided, can be pass, fail, unavailable, or unchecked.
card.zip_check
stringrequiredWhen used with a payment gateway that performs address checks and zip was provided, can be pass, fail, unavailable, or unchecked.
card.cvc_check
stringWhen used with a payment gateway that performs CVC code checks and cvc was provided, can be pass, fail, unavailable, or unchecked.
billing.default
booleanIndicates billing details represent the customer's default payment method.
billing.account_card_id
objectIdID of the customer's credit card on file, if applicable.
billing.account_card
account_cardExpandable link to the customer's credit card on file, if applicable.
billing.amazon
objectAmazon billing details used when billing.method=amazon.
amazon.access_token
stringrequiredAmazon access token provided when a customer authorizes payment in a storefront.
amazon.order_reference_id
stringrequiredAmazon order reference ID created when a customer initiates payment in a storefront.
billing.paypal
objectPayPal billing details used when billing.method=paypal.
paypal.payer_id
stringPayPal payer ID provided when a customer authorizes payment in a storefront.
paypal.payment_id
stringPayPal payment ID created when a customer initiates payment in a storefront.
paypal.nonce
stringpaypal.authorization_id
stringrequiredbilling.intent
objectStores the necessary information about the payment. This is typically the payment ID returned by the gateway after payment is initialized.
billing.affirm
objectAffirm billing details used when billing.method=affirm.
affirm.checkout_token
stringToken used to communicate payment information to the gateway.
billing.resolve
objectResolve billing details used when billing.method=resolve.
resolve.charge_id
stringCharge ID returned by the payment gateway for the payment.
billing.klarna
objectKlarna billing details used when billing.method=klarna.
klarna.source
stringPayment information returned by the gateway during payment initialization.
billing.ideal
objectIdeal billing details used when billing.method=ideal.
ideal.token
stringToken used to communicate payment information to the gateway.
billing.bancontact
objectBancontact billing details used when billing.method=bancontact.
bancontact.source
stringPayment information returned by the gateway during payment initialization.
billing.google
objectGoogle Pay billing details used when billing.method=google.
google.nonce
stringOne-time use reference element used to communicate payment information to a payment gateway.
google.gateway
stringGateway used to facilitate the transaction. For example, gateway=braintree.
billing.apple
objectApple Pay billing details used when billing.method=apple.
apple.nonce
stringOne-time use reference element used to communicate payment information to a payment gateway.
apple.gateway
stringGateway used to facilitate the transaction. For example, gateway=braintree.
checkout_id
stringCustomer-facing unique identifier for the cart used in URLs and for abandoned cart recovery.
checkout_url
stringURL to checkout for the cart, set automatically when the cart has at least items, shipping, or billing details set. Can also be set explicitly when creating or updating the cart for custom checkouts.
comments
stringCustomer notes provided when placing the order, if any.
coupon
CouponExpandable link to the coupon applied to the cart.
coupon_code
stringCoupon code applied to the cart.
coupon_id
objectIdID of the coupon applied to the cart.
currency
stringThree-letter ISO currency code in uppercase. Defaults to the store's base currency.
currency_rate
floatCurrency percentage used in calculating the fixed amount.
date_abandoned
dateDate the cart was or will be marked as abandoned.
date_abandoned_next
dateNext date the cart will be marked as abandoned when using a series of abandoned cart recovery notices (advanced cart recovery).
date_created
dateautoDate and time the cart was created.
date_updated
dateautoDate and time the cart was last updated.
date_webhook_first_failed
dateDate the order webhook first failed, if applicable. Value is unset after an order webhook is successfully returned for the record.
date_webhook_last_succeeded
dateDate the order webhook last succeeded, if applicable. Value is unset after an order webhook fails to return for the record.
discount_total
currencyTotal discount amount.
discounts
array of objectList of discounts applied to the cart.
id
stringUnique identifier for the object.
amount
currencyFixed discount amount.
rule
objectObject describing the discount rule details. Custom discounts don't require this value.
type
stringType of discount. Can be coupon or promo-<id> referring to the source of the discount. Custom discounts don't require this value.
display_currency
stringThree-letter ISO currency code representing the user's preferred display currency, if applicable.
display_locale
stringLocale code representing the user's preferred display locale, if applicable.
draft
booleanIndicates the cart is a draft. The Swell dashboard uses draft carts to designate entries in the Draft orders section of the dashboard.
gift
booleanIndicates the order is intended as a gift for the recipient.
gift_message
stringOptional message to include with the order when shipping to the recipient.
giftcard_delivery
booleanIndicates the cart has at least one line item with delivery=giftcard.
giftcard_total
currencyautoTotal payment amount applied to the order from giftcards.
giftcards
array of objectList of gift cards applied to the cart.
id
objectIdUnique identifier for the object.
amount
currencyAmount of the gift card balance to spend for initial payment. If not specified, each gift cards will be spent in order until payment is completed.
code
stringGift card code to apply. A validation error will be returned if the code is not valid.
code_formatted
stringFully formatted gift card code for display purposes.
giftcard
giftcardExpandable link to the gift card record.
last4
stringLast four digits of the gift card code.
grand_total
currencyautoGrand total including items, shipping, and taxes.
guest
booleanIndicates the customer was not logged in when placing the order.
item_discount
currencyTotal discount applied to line items.
item_quantity
intautoTotal quantity of all line items.
item_shipment_weight
floatautoTotal shipping weight of all line items.
item_tax
currencyautoTotal taxes applied to line items.
item_tax_included
booleanIndicates line item prices include taxes.
items
array of objectList of line items describing the products ordered.
.id
objectIdautoUnique identifier for the item.
.bundle_items
array of objectList of items offered as a bundle. Defaults to product.bundle_items.
.id
objectIdUnique identifier for the object.
.product_id
objectIdrequiredID of the bundle item product.
.product
productExpandable link to the bundle item product.
.delivery
enumMethod of delivery taken automatically from product.delivery.
Possible enum values:
.options
array of objectOptions that allow for variations of the base product. If the option is part of a variant or required=true, an option value must be set for the product to be added to a cart.
.id
stringUnique identifier for the object.
.name
stringHuman-friendly name of the option.
.value
stringName value of the product option. When adding to the cart, specify either the product option value id or name (case-insensitive) to identify the value.
.variant
booleanIndicates the option refers to a variant aspect.
.price
currencyAdditional price added onto the base price of the product.
.shipment_weight
floatAdditional shipping weight added onto the base weight of the product.
.shipment_weight
floatautoShipping weight taken automatically from product.shipment_weight, if applicable.
.quantity
intQuantity of the bundle item being ordered. Defaults to 1.
.quantity_total
intTotal quantity of the bundle item to be fulfilled, calculated as item.quantity * bundle_item.quantity.
.variant_id
objectIdID of the bundle item variant.
.variant
variantExpandable link to the bundle item variant.
.delivery
enumMethod of fulfillment automatically assigned based on type such as shipment, subscription, giftcard, and null. Each product in the bundle must have its own fulfillment method.
Possible enum values:
.description
stringA long-form description of the product. Can contain HTML or other markup languages.
.discount_each
currencyTotal discount amount divided by quantity.
.discount_total
currencyTotal discount applied to the item.
.discounts
array of objectList of discounts applied to the item by coupons, promotions, or custom logic.
id
stringUnique identifier for the object. Refers to one of the IDs in the cart discounts object.
amount
currencyFixed discount amount.
.metadata
objectArbitrary item data, typically set in a checkout flow to store custom values. See Storefront API for details.
.options
array of objectOptions that allow for variations of the base product. If the option is part of a variant or required=true, an option value must be set for the product to be added to a cart.
id
stringUnique identifier for the object.
name
stringHuman-friendly name of the option.
price
currencyAdditional price added onto the base price of the product.
shipment_weight
floatAdditional shipping weight added onto the base weight of the product.
value
stringName value of the product option. When adding to the cart, specify either the product option value id or name (case-insensitive) to identify the value.
variant
booleanIndicates the option refers to a variant aspect.
.orig_price
currencyDisplays the original item list price and does not reflect discounts or sale pricing.
.price
currencyPrice of the item. If a product price is reduced by a sale or price rule, this would be set to the reduced price automatically. Also, item price can be overridden when adding to a cart. Line item prices don't change unless explicitly edited by a store admin.
.price_total
currencyTotal price added to sub total by multiplying quantity and price.
.product_id
objectIdID of the bundle item product.
.product_name
stringThis field is a copy of the item's product.name.
.product
productExpandable link to the bundle item product.
.quantity
intQuantity of the bundle item being ordered. Defaults to 1.
.shipment_location
stringID of location from /settings/shipping/locations. If specified, shipping is calculated from this location. Otherwise, the store's default location will be used.
.shipment_weight
floatautoShipping weight taken automatically from product.shipment_weight, if applicable.
.subscription_interval
stringRefers to the subscription interval that applies when delivery=subscription.
.subscription_interval_count
intRefers to the subscription interval count that applies when delivery=subscription.
.subscription_trial_days
intRefers to the subscription trial period that applies when delivery=subscription.
.subscription_paid
booleanIndicates the item has been fulfilled as a subscription and marked as paid by reference to this order.
.tax_each
currencyTotal tax amount divided by quantity.
.tax_total
currencyTotal tax applied to the item.
.taxes
array of objectList of tax rules applied to the item based on tax settings or custom logic.
id
stringUnique identifier for the object. Refers to one of the IDs in the cart taxes object.
amount
currencyFixed tax amount.
.trial_price_total
currencyTotal of all trial prices on the order.
.variant_id
objectIdID of the bundle item variant.
.variant
variantExpandable link to the bundle item variant.
metadata
objectArbitrary data, typically set in a checkout flow to store custom values. See Frontend API for more details.
notes
stringInternal admin notes. These are not visible to the customer.
number
stringautoUnique incremental cart number, assigned automatically using a format configured in general settings.
order
OrderExpandable link to the converted order, if applicable.
order_id
objectIdID of the the converted order, if applicable.
orig_price
currencyReflects the automatic price of an item, and indicates whether it's on sale or not, so as to determine if the price was customized by an API call.
promotion_ids
array of child_scalarList of promotion IDs applied to the cart.
promotions
PromotionExpandable list of promotions applied to the cart.
purchase_link_ids
array of stringUnique identifiers for the purchase links.
purchase_links
Purchase LinkExpandable links to the purchase links added to the cart.
purchase_links_errors
array of objectList of purchase link errors applied to the cart. Added when clicking on the purchase link, if any resources are blocking the creation of the cart.
.id
objectIdUnique identifier for the purchase link errors.
.error
objectrequiredA purchase link error object.
error.code
stringrequiredA distinct code indicating the cause of the purchase link error.
error.message
stringrequiredA human-readable description of the purchase link error.
error.resource
objectrequiredAn object describing the resource that blocked the creation of the cart.
resource.id
objectIdResource ID for the error.
resource.model
stringResource model. For example: products or promotions.
resource.name
stringA human-readable resource name.
.purchase_link
purchase_linkExpandable link to the purchase link.
.purchase_link_id
stringrequiredUnique identifier for the purchase link to which the error relates.
recovered
booleanIndicates the cart was recovered and converted to an order after being abandoned.
schedule
objectSchedule for a recurring order.
schedule.interval
enumInterval of recurring orders. Can be weekly, daily, monthly, yearly.
Possible enum values:
schedule.interval_count
intInterval multiplier for scheduled orders. For example, an interval_count=2 paired with an interval=monthly would recur twice a month.
shipment_delivery
booleanIndicates the cart has at least one line item with delivery=shipment.
shipment_discount
currencyShipping discount applied by coupons, promotions, or custom logic.
shipment_price
currencyTotal shipping price before discounts.
shipment_rating
objectObject describing the shipping services and rates available for the cart. Shipping country must be set before retrieving shipping rates.
shipment_rating.date_created
dateautoDate and time the object was created.
shipment_rating.services
array of objectList of shipping services and rates available.
.id
stringUnique identifier for the object.
.name
stringName of the shipment service.
.carrier
stringName of the third party carrier offering the service, if applicable.
.price
currencyPrice of given shipment service.
.pickup
booleanIndicated whether the shipment service is local pick-up.
.tax_code
stringApplicable tax code for shipment service.
shipment_rating.errors
array of objectList of errors generated while retrieving rates, if any. When using third-party shipping services, any system errors will be listed here.
.message
stringBrief description of the error.
.code
stringUnique error code for reference.
shipment_rating.md5
stringMD5 hash value for referencing the shipment rating.
shipment_tax
currencyShipping tax amount, if applicable.
shipment_tax_included
booleanIndicates shipping total includes taxes, if applicable.
shipment_total
currencyTotal shipping price after discounts.
shipping
objectThe customer's shipping details. Defaults to account.shipping. Updating shipping will also update the corresponding account shipping object.
shipping.name
stringShipping full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
shipping.first_name
stringShipping first name. If name is updated, then first_name will be automatically updated as the first word of the name.
shipping.last_name
stringrequiredShipping last name. If name is updated, then last_name will be automatically updated as the last words of the name.
shipping.address1
stringShipping address line 1: (street address/PO box/company name).
shipping.address2
stringShipping address line 2: (apartment/suite/unit/building).
shipping.city
stringShipping city/district/suburb/town/village.
shipping.state
stringShipping state/county/province/region.
shipping.zip
stringShipping zip/postal code.
shipping.country
stringTwo-letter ISO country code.
shipping.phone
stringShipping phone number.
shipping.service
stringID of a shipping service as configured in shipment settings. Normally, this would be applied after retrieving shipping rates by using one of the shipment_rating.services.id values.
shipping.service_name
stringrequiredName of the shipping service. Defaults to shipment_rating.services.name chosen by setting service.
shipping.price
currencyrequiredPrice of the shipping service. Defaults to shipment_rating.services.price chosen by setting service.
shipping.default
booleanrequiredIndicates shipping details represent the customer's default shipping address.
shipping.account_address_id
objectIdrequiredID of the customer's address on file.
shipping.account_address
account_addressExpandable link to the customer's address on file.
shipping.pickup
booleanIndicates whether shipping for local pick-up.
status
enumautoCurrent status of the cart. Can be active, converted, abandoned, or recovered.
Possible enum values:
sub_total
currencySum of all line items before discounts, taxes and shipping.
subscription
SubscriptionExpandable link to the subscription that spawned the order, if applicable.
subscription_delivery
booleanIndicates the cart has at least one line item with delivery=subscription.
subscription_id
objectIdID of the subscription that spawned the order, if applicable.
target_order
OrderExpands into the order that the cart was converted into.
target_order_id
objectIdWhen a cart is converted to an order, this field represents the corresponding order_id.
tax_included_total
currencyTotal with shipping and item taxes included. Allows for an alternate display style, as normally sub_total and tax_total are shown separately.
tax_total
currencyTotal tax amount applied to the cart including line items and shipping.
taxes
array of objectList of taxes applied to the cart.
.id
stringUnique identifier for the object.
.name
stringName of the tax rule. For example, "NY Sales Tax".
.amount
currencyFixed tax amount.
.priority
intPriority indicates the order in which a tax rule was applied. Higher priority rules are added on top of other tax rules with a lower priority. Rules with the same priority are calculated excluding each other.
.rate
floatTax percentage used in calculating the fixed amount.
.shipping
booleanIndicates the tax applies to shipping.
taxes_fixed
booleanIndicates the order is tax-exempt. Taxes will not be calculated or applied when true.
webhook_attempts_failed
intNumber of failed order webhook attempts, if applicable. Value is unset after an order webhook is successfully returned for the record.
webhook_response
stringText response of the last failed order webhook attempt, if applicable. Value is unset after an order webhook is successfully returned for the record.
webhook_status
intHTTP response status of the last failed order webhook attempt, if applicable. Value is unset after an order webhook is successfully returned for the record.
The cart model
{
"id": "60f199509111e7000000000e",
"abandoned": false,
"account_id": "60f199509111e7000000000f",
"account_info_saved": true,
"account_logged_in": true,
"billing": {
"name": "Uriel Septim VII",
"first_name": "Uriel",
"last_name": "Septim",
"address1": "Imperial City Palace",
"city": "Imperial City",
"state": "NY",
"zip": 11201,
"country": "US",
"phone": "(555) 555-5555",
"method": "card",
"card": {
"token": "card_1Ds1K7E30PFlZWil6Q7bJ1PD",
"test": true,
"last4": "4242",
"brand": "Visa",
"address_check": "unchecked",
"zip_check": "unchecked",
"cvc_check": "unchecked",
"exp_month": 1,
"exp_year": 2029,
"fingerprints": "3e63991847bbdaafdbc5c8f110ad803f"
},
"account_card_id": "5c3ac9870b3b171a7dfaf089"
},
"checkout_id": "e785b5ac4355ceef41ae2fd1c47df4bc",
"checkout_url": "https://example.swell.store/checkout/e785b5ac4355ceef41ae2fd1c47df4bc",
"comments": null,
"coupon_code": "DREAMS",
"coupon_id": "60f199509111e70000000010",
"currency": "USD",
"date_created": "2021-07-16T14:36:00.057Z",
"date_updated": "2021-07-16T14:36:00.057Z",
"date_webhook_first_failed": null,
"discount_total": 5,
"discounts": [
{
"id": "coupon-0",
"type": "coupon",
"amount": 5,
"rule": {
"type": "product",
"value_type": "fixed",
"value_amount": 2.5,
"product_id": "5c524166f4e8f3446a10331b"
}
}
],
"gift_message": null,
"giftcards": [
{
"id": "5841c5691c64c63e75d29e43",
"amount": 25,
"code": "B6UQY3DHRCM4BQYU",
"code_formatted": "B6UQ Y3DH RCM4 BQYU",
"last4": "BQYU"
}
],
"gift": true,
"giftcard_total": 25,
"grand_total": 41.98,
"guest": false,
"item_discount": 5,
"item_quantity": 2,
"item_shipment_weight": 2,
"item_tax": 2,
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"product_id": "5c524166f4e8f3446a10331b",
"variant_id": "5c524166f4e8f3446a10331f",
"quantity": 2,
"price": 19.99,
"price_total": 38.98,
"orig_price": 19.99,
"delivery": "shipment",
"shipment_weight": 1,
"options": [
{
"id": "5becb84fac207653a4816ee5",
"name": "Size",
"value": "Small",
"variant": true
},
{
"id": "5becb84fac207653a4816ee6",
"name": "Color",
"value": "Yellow",
"variant": true
}
],
"discounts": [
{
"id": "coupon-0",
"amount": 5
}
],
"discount_each": 2.5,
"discount_total": 5,
"taxes": [
{
"id": "sales-tax",
"amount": 2
}
],
"tax_each": 1,
"tax_total": 2
}
],
"notes": null,
"number": 2039476,
"order_id": "60f199509111e70000000011",
"promotion_ids": null,
"shipment_delivery": true,
"shipment_discount": 0,
"shipment_price": 5,
"shipment_rating": {
"fingerprint": "71e03117e684192f4f33569dab1c74ee",
"services": [
{
"id": "standard",
"name": "Standard Shipping",
"price": 5
},
{
"id": "express",
"name": "Express Shipping",
"price": 10
},
{
"id": "next_day",
"name": "Next Day Shipping",
"price": 20
}
],
"errors": null
},
"shipment_tax": 0,
"shipment_tax_included_total": 5,
"shipment_total": 5,
"shipping": {
"name": "Uriel Septim VII",
"first_name": "Uriel",
"last_name": "Septim",
"address1": "Imperial City Palace",
"city": "Imperial City",
"zip": 11201,
"country": "US",
"phone": "(555) 555-5555",
"price": 5,
"service": "standard",
"service_name": "Standard",
"account_address_id": "5c12c5fdfcd74b34e19cf659"
},
"status": "converted",
"sub_total": 38.98,
"tax_included_total": 2,
"tax_total": 2,
"taxes": [
{
"id": "sales-tax",
"name": "Sales tax",
"priority": 1,
"rate": 0.1,
"amount": 2
}
],
"webhook_attempts_failed": null,
"webhook_response": null,
"webhook_status": 200
}
Create a new cart. If you wish to generate your own unique ID for the record, it must use BSON ObjectID format for compatibility.
When adding shipping.services to a cart, you must first add the products to the cart.
Arguments
account_id
objectIdID of the customer's account.
billing
objectThe customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
billing.account_card_id
objectIdID of the customer's credit card on file, if applicable.
billing.account_card
account_cardExpandable link to the customer's credit card on file, if applicable.
billing.address1
stringBilling address line 1: street address/PO box/company name.
billing.address2
stringBilling address line 2: apartment/suite/unit/building.
billing.amazon
objectAmazon billing details used when billing.method=amazon.
amazon.access_token
stringAmazon access token provided when a customer authorizes payment in a storefront.
amazon.order_reference_id
stringAmazon order reference ID created when a customer initiates payment in a storefront.
amazon.checkout_session_id
stringbilling.card
objectCredit card billing details used when `billing.method=card`.
card.token
stringToken generated by Swell Checkout or Stripe.js.
card.exp_month
intTwo-digit number representing the credit card expiration month.
card.exp_year
intFour-digit number representing the credit card expiration year.
card.brand
stringCredit card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
card.last4
stringLast four digits of the card number.
card.gateway
stringID of the payment gateway that should be used to process payments.
card.test
booleanIndicates this is a test card.
card.address_check
stringWhen used with a payment gateway that performs address checks and address1 was provided, can be pass, fail, unavailable, or unchecked.
card.zip_check
stringWhen used with a payment gateway that performs address checks and zip was provided, can be pass, fail, unavailable, or unchecked.
card.cvc_check
stringWhen used with a payment gateway that performs CVC code checks and cvc was provided, can be pass, fail, unavailable, or unchecked.
billing.city
stringBilling city/district/suburb/town/village.
billing.country
stringTwo-letter ISO country code.
billing.default
booleanIndicates billing details represent the customer's default payment method.
billing.first_name
stringBilling first name. If name is updated, then first_name will be automatically updated as the first word of the name.
billing.last_name
stringBilling last name. If name is updated, then last_name will be automatically updated as the last words of the name.
billing.method
stringMethod of payment. Can becard, account, amazon, paypal, or any one of the manual methods defined in payment settings.
billing.name
stringBilling full name. If `first_name` or `last_name` are updated, then `name` will be automatically updated as a combination of first/last.
billing.paypal
objectPayPal billing details used when billing.method=paypal.
paypal.payer_id
stringPayPal payer ID provided when a customer authorizes payment in a storefront.
paypal.payment_id
stringPayPal payment ID created when a customer initiates payment in a storefront.
paypal.nonce
stringpaypal.authorization_id
stringpaypal.order_id
stringbilling.phone
stringBilling phone number.
billing.state
stringBilling state/county/province/region.
billing.zip
stringBilling zip/postal code.
billing.intent
objectStores the necessary information about the payment. This is typically the payment ID returned by the gateway after payment is initialized.
billing.affirm
objectAffirm billing details used when billing.method=affirm.
affirm.checkout_token
stringToken used to communicate payment information to the gateway.
billing.resolve
objectResolve billing details used when billing.method=resolve.
resolve.charge_id
stringCharge ID returned by the payment gateway for the payment.
billing.klarna
objectKlarna billing details used when billing.method=klarna.
klarna.source
stringPayment information returned by the gateway during payment initialization.
billing.ideal
objectIdeal billing details used when billing.method=ideal.
ideal.token
stringToken used to communicate payment information to the gateway.
billing.bancontact
objectBancontact billing details used when billing.method=bancontact.
bancontact.source
stringPayment information returned by the gateway during payment initialization.
billing.google
objectGoogle Pay billing details used when billing.method=google.
google.nonce
stringOne-time use reference element used to communicate payment information to a payment gateway.
google.gateway
stringGateway used to facilitate the transaction. For example, gateway=braintree.
billing.apple
objectApple Pay billing details used when billing.method=apple.
apple.nonce
stringOne-time use reference element used to communicate payment information to a payment gateway.
apple.gateway
stringGateway used to facilitate the transaction. For example, gateway=braintree.
coupon_code
stringCoupon code applied to the cart. See coupons for details.
items
array of objectList of line items describing the products ordered.
bundle_items
array of objectList of items offered as a bundle. Defaults to product.bundle_items.
id
objectIdID of the bundle item product.
product_id
objectIdrequiredID of the bundle item product.
product
productExpandable link to the bundle product.
quantity
intQuantity of the bundle item being ordered. Defaults to 1.
shipment_weight
floatautoWeight to be used in shipping calculation, if applicable.
variant_id
objectIdID of the bundle item variant.
variant
variantExpandable link to the bundle variant.
delivery
enumMethod of delivery taken automatically from product.delivery.
Possible enum values:
options
array of objectOptions that allow for variations of the base product. If the option is part of a variant or required=true, an option value must be set for the product to be added to a cart.
id
stringUnique identifier for the object.
name
stringHuman-friendly name of the option.
value
stringName value of the product option. When adding to the cart, specify either the product option value id or name (case-insensitive) to identify the value.
variant
booleanIndicates the option refers to a variant aspect.
price
currencyAdditional price added onto the base price of the product.
shipment_weight
floatAdditional shipping weight added onto the base weight of the product.
value_id
objectIdquantity_total
intTotal quantity of the bundle item to be fulfilled, calculated as item.quantity * bundle_item.quantity.
product_name
stringdescription
stringDescription used for custom line items, when product is not defined.
discounts
array of objectList of discounts to apply to the item. Normally populated by applying a coupon or promotions.
id
stringrequiredUnique identifier for the object. Should refer to one of the IDs in the cart discounts object.
amount
currencyrequiredFixed discount amount.
metadata
objectArbitrary item data, typically set in a checkout flow to store custom values. See Storefront API for details.
options
array of objectItem options matching one or more of product.options. When adding to the cart, specify either option id or name (case-insensitive) to identify the option.
Gift card products have two special options that can be used when fulfilling gift cards by email. Use the option ID send_email and value as the recipient email address, and send_note as a custom message from the customer to the recipient sent by email.
id
stringUnique identifier for the object.
name
stringName of the product option. Populated automatically when adding an option by ID.
price
currencyAdditional price added onto the base price of the product.
shipment_weight
floatAdditional shipping weight added onto the base weight of the product.
value
stringName value of the product option. When adding to the cart, specify either the product option value id or name (case-insensitive) to identify the value.
variant
booleanIndicates the option refers to a variant aspect.
value_id
objectIddelivery
enumMethod of delivery taken automatically from product.delivery
Possible enum values:
price
currencyPrice of the item. Override this value to set a custom price. Defaults to product price or sale price.
product_id
objectIdID of the item product.
product
productExpandable link to the product, if applicable.
quantity
intQuantity of the item being ordered. Defaults to 1.
shipment_weight
floatautoWeight to be used in shipping calculation, if applicable.
taxes
array of objectList of tax rules to apply to the item. Normally populated by tax settings.
id
stringrequiredUnique identifier for the object. Should refer to one of the IDs in the cart taxes object.
amount
currencyrequiredFixed tax amount.
variant_id
objectIdID of the item variant, if applicable.
variant
variantExpandable link to the variant, if applicable.
id
objectIdautoUnique identifier for the item.
discount_each
currencyTotal discount amount divided by quantity.
discount_total
currencyTotal discount applied to the item.
orig_price
currencyDisplays the original item list price and does not reflect discounts or sale pricing.
price_total
currencyTotal price added to sub total by multiplying quantity and price.
shipment_location
stringID of location from /settings/shipping/locations. If specified, shipping is calculated from this location. Otherwise, the store's default location will be used.
subscription_interval
stringRefers to the subscription interval that applies when delivery=subscription.
subscription_interval_count
intRefers to the subscription interval count that applies when delivery=subscription.
subscription_trial_days
intRefers to the subscription trial period that applies when delivery=subscription.
tax_each
currencyTotal tax amount divided by quantity.
tax_total
currencyTotal tax applied to the item.
trial_price_total
currencyTotal of all trial prices on the order.
subscription_paid
booleanIndicates the item has been fulfilled as a subscription and marked as paid by reference to this order.
product_name
stringThis field is a copy of the item's product.name.
trial
booleantrial_auth_total
currencypurchase_option
objectpurchase_option.type
enumPossible enum values:
purchase_option.id
objectIdpurchase_option.name
stringpurchase_option.price
currencypurchase_option.auth_amount
currencypurchase_option.trial_days
intpurchase_option.plan_id
objectIdpurchase_option.plan_name
stringpurchase_option.plan_description
stringpurchase_option.billing_schedule
objectbilling_schedule.interval
enumPossible enum values:
billing_schedule.interval_count
intbilling_schedule.trial_days
intbilling_schedule.limit
intpurchase_option.order_schedule
objectorder_schedule.interval
enumPossible enum values:
order_schedule.interval_count
intorder_schedule.limit
inttrial_discount_total
currencytrial_tax_total
currencyshipping
objectThe customer's shipping details. Defaults to account.shipping. Updating shipping will also update the corresponding account shipping object.
shipping.account_address_id
objectIdID of the customer's address on file.
shipping.account_address
account_addressExpandable link to the customer's address on file.
shipping.address1
stringShipping address line 1: (street address/PO box/company name).
shipping.address2
stringShipping address line 2: (apartment/suite/unit/building).
shipping.city
stringShipping city/district/suburb/town/village.
shipping.country
stringTwo-letter ISO country code.
shipping.default
booleanIndicates shipping details represent the customer's default shipping address.
shipping.first_name
stringShipping first name. If name is updated, then first_name will be automatically updated as the first word of the name.
shipping.last_name
stringShipping last name. If name is updated, then last_name will be automatically updated as the last words of the name.
shipping.name
stringShipping full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
shipping.phone
stringShipping phone number.
shipping.price
currencyPrice of the shipping service. Defaults to `shipment_rating.services.price` chosen by setting `service`.
shipping.service
stringID of a shipping service as configured in shipment settings. Normally, this would be applied after retrieving shipping rates by using one of the shipment_rating.services.id values.
shipping.service_name
stringName of the shipping service. Defaults to shipment_rating.services.name chosen by setting service.
shipping.state
stringShipping state/county/province/region.
shipping.zip
stringShipping zip/postal code.
shipping.pickup
booleanIndicates if the shipping is local pick up
abandoned
booleanIndicates the cart was abandoned after 3 hours of inactivity. After being marked as abandoned, this field is automatically set back to false after an update to items, billing, or shipping info.
abandoned_notifications
intNumber of abandoned cart notifications sent to the customer.
account
AccountExpandable link to the customer's account.
account_credit_amount
currencyAmount of customer's account credit applied for initial payment, if applicable.
account_credit_applied
booleanIndicates the customer's account credit is applied to the initial payment.
account_info_saved
booleanSet true when the customer has indicated they want to save shipping and billing information to their account for future use.
account_logged_in
booleanIndicates the customer was logged into their account when placing the order.
active
booleanIndicates the cart has been updated by a customer within the last 3 hours.
checkout_id
stringCustomer-facing unique identifier for the cart used in URLs and for abandoned cart recovery.
checkout_url
stringURL to checkout for the cart, set automatically when the cart has at least items, shipping, or billing details set. Can also be set explicitly when creating or updating the cart for custom checkouts.
comments
stringCustomer notes provided when placing the order, if any.
coupon
CouponExpandable link to the coupon applied to the cart.
coupon_id
objectIdID of the coupon applied to the cart.
currency
stringThree-letter ISO currency code in uppercase. Defaults to the store's base currency.
currency_rate
floatCurrency percentage used in calculating the fixed amount.
date_abandoned
dateDate the cart was or will be marked as abandoned.
date_abandoned_next
dateNext date the cart will be marked as abandoned when using a series of abandoned cart recovery notices (advanced cart recovery).
date_webhook_first_failed
dateDate the order webhook first failed, if applicable. Value is unset after an order webhook is successfully returned for the record.
date_webhook_last_succeeded
dateDate the order webhook last succeeded, if applicable. Value is unset after an order webhook fails to return for the record.
discount_total
currencyTotal discount amount.
discounts
array of objectList of discounts applied to the cart.
id
stringUnique identifier for the object.
amount
currencyFixed discount amount.
rule
objectObject describing the discount rule details. Custom discounts don't require this value.
type
stringType of discount. Can be coupon or promo-<id> referring to the source of the discount. Custom discounts don't require this value.
display_currency
stringThree-letter ISO currency code representing the user's preferred display currency, if applicable.
display_locale
stringLocale code representing the user's preferred display locale, if applicable.
draft_subscription
booleanIndicates cart is a draft subscription.
gift
booleanIndicates the order is intended as a gift for the recipient.
gift_message
stringOptional message to include with the order when shipping to the recipient.
giftcard_delivery
booleanIndicates the cart has at least one line item with delivery=giftcard.
giftcard_total
currencyautoTotal payment amount applied to the order from giftcards.
giftcards
array of objectList of gift cards applied to the cart.
amount
currencyAmount of the gift card balance to spend on this order. Defaults to giftcard.balance.
code
stringSpecify a gift card code to apply to the cart. If the code is not found or invalid, a validation error is returned. Case-insensitive.
id
objectIdUnique identifier for the object.
code_formatted
stringFully formatted gift card code for display purposes.
giftcard
giftcardExpandable link to the gift card record.
last4
stringLast four digits of the gift card code.
grand_total
currencyautoGrand total including items, shipping, and taxes.
guest
booleanIndicates the customer was not logged in when placing the order.
item_discount
currencyTotal discount applied to line items.
item_quantity
intautoTotal quantity of all line items.
item_shipment_weight
floatautoTotal shipping weight of all line items.
item_tax
currencyautoTotal taxes applied to line items.
item_tax_included
booleanIndicates line item prices include taxes.
metadata
objectArbitrary data, typically set in a checkout flow to store custom values. See Storefront API for more details.
notes
stringInternal admin notes. These are not visible to the customer.
number
stringautoUnique incremental cart number, assigned automatically using a format configured in general settings.
order
OrderExpandable link to the converted order, if applicable.
order_id
objectIdID of the the converted order, if applicable.
orig_price
currencyReflects the automatic price of an item, and indicates whether it's on sale or not, so as to determine if the price was customized by an API call.
promotion_ids
array of child_scalarList of promotion IDs applied to the cart.
promotions
PromotionExpandable list of promotions applied to the cart.
purchase_link_ids
array of child_scalarUnique identifiers for the purchase links.
purchase_links
Purchase LinkExpandable links to the purchase links added to the cart.
purchase_links_errors
array of objectList of purchase link errors applied to the cart. Added when clicking on the purchase link, if any resources are blocking the creation of the cart.
id
objectIdautoUnique identifier for the purchase link errors.
error
objectrequiredA purchase link error object.
error.code
stringrequiredA distinct code indicating the cause of the purchase link error.
error.message
stringrequiredA human-readable description of the purchase link error.
error.resource
objectrequiredAn object describing the resource that blocked the creation of the cart.
resource.id
objectIdResource ID for the error.
resource.model
stringResource model. For example: products or promotions.
resource.name
stringA human-readable resource name.
purchase_link
purchase_linkExpandable link to the purchase link.
purchase_link_id
stringrequiredUnique identifier for the purchase link to which the error relates.
recovered
booleanIndicates the cart was recovered and converted to an order after being abandoned.
schedule
objectSchedule for a recurring order.
schedule.interval
enumInterval of recurring orders. Can be weekly, daily, monthly, yearly.
Possible enum values:
schedule.interval_count
intInterval multiplier for scheduled orders. For example, an interval_count=2 paired with an interval=monthly would recur twice a month.
shipment_delivery
booleanIndicates the cart has at least one line item with delivery=shipment.
shipment_discount
currencyShipping discount applied by coupons, promotions, or custom logic.
shipment_price
currencyTotal shipping price before discounts.
shipment_rating
objectObject describing the shipping services and rates available for the cart. Shipping country must be set before retrieving shipping rates.
shipment_rating.fingerprint
stringUnique fingerprint identifying the parameters used to calculate shipping rates. Rates should always be the same given the same parameters and shipping settings.
shipment_rating.services
array of objectList of shipping services and rates available.
id
stringUnique identifier for the object.
name
stringName of the shipment service.
carrier
stringName of the third party carrier offering the service, if applicable.
price
currencyPrice of given shipment service.
pickup
booleanIndicated whether the shipment service is local pick-up.
tax_code
stringApplicable tax code for shipment service.
shipment_rating.errors
array of objectList of errors generated while retrieving rates, if any. When using third-party shipping services, any system errors will be listed here.
message
stringBrief description of the error.
code
stringUnique error code for reference.
shipment_rating.md5
stringMD5 hash value for referencing the shipment rating.
shipment_tax
currencyShipping tax amount, if applicable.
shipment_tax_included
booleanIndicates shipping total includes taxes, if applicable.
shipment_tax_included_total
currencyTotal of taxes applied separately from line items.
shipment_total
currencyTotal shipping price after discounts.
status
enumautoCurrent status of the cart. Can be active, converted, abandoned, or recovered.
Possible enum values:
sub_total
currencySum of all line items before discounts, taxes and shipping.
subscription
SubscriptionExpandable link to the subscription that spawned the order, if applicable.
subscription_delivery
booleanIndicates the cart has at least one line item with delivery=subscription.
subscription_id
objectIdID of the subscription that spawned the order, if applicable.
target_order
OrderExpands into the order that the cart was converted into.
target_order_id
objectIdWhen a cart is converted to an order, this field represents the corresponding order_id.
tax_included_total
currencyTotal with shipping and item taxes included. Allows for an alternate display style, as normally sub_total and tax_total are shown separately.
tax_total
currencyTotal tax amount applied to the cart including line items and shipping.
taxes
array of objectList of taxes applied to the cart.
id
stringUnique identifier for the object.
amount
currencyFixed tax amount.
name
stringName of the tax rule. For example, "NY Sales Tax".
priority
intPriority indicates the order in which a tax rule was applied. Higher priority rules are added on top of other tax rules with a lower priority. Rules with the same priority are calculated excluding each other.
rate
floatTax percentage used in calculating the fixed amount.
shipping
booleanIndicates the tax applies to shipping.
taxes_fixed
booleanIndicates the order is tax-exempt. Taxes will not be calculated or applied when true.
webhook_attempts_failed
intNumber of failed order webhook attempts, if applicable. Value is unset after an order webhook is successfully returned for the record.
webhook_response
stringText response of the last failed order webhook attempt, if applicable. Value is unset after an order webhook is successfully returned for the record.
webhook_status
intHTTP response status of the last failed order webhook attempt, if applicable. Value is unset after an order webhook is successfully returned for the record.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/carts', {
items: [
{
product_id: '5cad15bc9b14d1990724663a',
quantity: 2,
}
],
billing: {
...
},
shipping: {
...
},
coupon_code: 'FREESHIPPING',
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"active": true,
"billing": {...},
"shipping": {...},
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"price": 9.99,
"price_total": 18.98,
"shipment_weight": 1.5,
...
}
],
"coupon_code": "FREESHIPPING",
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"discount_total": 0,
"grand_total": 18.98,
"item_quantity": 2,
"item_shipment_weight": 3.0,
"item_tax": 0,
"number": "100101",
"shipment_price": 0,
"shipment_total": 0,
"status": "active",
"sub_total": 0,
"tax_total": 0,
...
}
Retrieve an existing cart using the ID that was returned when created.
Arguments
id
objectIdrequiredThe id of the cart to retrieve.
expand
stringExpanding link fields and child collections is performed using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
fields
stringReturn only the specified fields in the result. For example fields=name,slug would return only the fields name and slug in the response. Supports nested object and array fields using dot-notation, for example, items.product_id. The category id is always returned.
include
stringInclude one or more arbitrary queries in the response, possibly related to the main query.
See including for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/carts/{id}', {
id: '5cad15bc9b14d1990724663a',
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"active": true,
"billing": {...},
"shipping": {...},
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"price": 9.99,
"price_total": 18.98,
"shipment_weight": 1.5,
...
}
],
"coupon_code": "FREESHIPPING",
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"discount_total": 0,
"grand_total": 18.98,
"item_quantity": 2,
"item_shipment_weight": 3.0,
"item_tax": 0,
"number": "100101",
"shipment_price": 0,
"shipment_total": 0,
"status": "active",
"sub_total": 0,
"tax_total": 0,
...
}
Update an existing cart using the ID that was returned when created. Updating performs a merge operation. To explicitly override values such as arrays, use the $set operator.
Arguments
id
objectIdrequiredUnique identifier for the cart.
account_id
objectIdID of the customer's account.
billing
objectThe customer's billing details. Defaults to account.billing. Updating billing will also update the corresponding account billing object.
billing.account_card_id
objectIdID of the customer's credit card on file, if applicable.
billing.account_card
account_cardExpandable link to the customer's credit card on file, if applicable.
billing.address1
stringBilling address line 1: street address/PO box/company name.
billing.address2
stringBilling address line 2: apartment/suite/unit/building.
billing.amazon
objectAmazon billing details used when billing.method=amazon.
amazon.access_token
stringAmazon access token provided when a customer authorizes payment in a storefront.
amazon.order_reference_id
stringAmazon order reference ID created when a customer initiates payment in a storefront.
amazon.checkout_session_id
stringbilling.card
objectCredit card billing details used when `billing.method=card`.
card.token
stringToken generated by Swell Checkout or Stripe.js.
card.exp_month
intTwo-digit number representing the credit card expiration month.
card.exp_year
intFour-digit number representing the credit card expiration year.
card.brand
stringCredit card brand. Can be American Express, Diners Club, Discover, JCB, MasterCard, UnionPay, Visa, or Unknown.
card.last4
stringLast four digits of the card number.
card.gateway
stringID of the payment gateway that should be used to process payments.
card.test
booleanIndicates this is a test card.
card.address_check
stringWhen used with a payment gateway that performs address checks and address1 was provided, can be pass, fail, unavailable, or unchecked.
card.zip_check
stringWhen used with a payment gateway that performs address checks and zip was provided, can be pass, fail, unavailable, or unchecked.
card.cvc_check
stringWhen used with a payment gateway that performs CVC code checks and cvc was provided, can be pass, fail, unavailable, or unchecked.
billing.city
stringBilling city/district/suburb/town/village.
billing.country
stringTwo-letter ISO country code.
billing.default
booleanIndicates billing details represent the customer's default payment method.
billing.first_name
stringBilling first name. If name is updated, then first_name will be automatically updated as the first word of the name.
billing.last_name
stringBilling last name. If name is updated, then last_name will be automatically updated as the last words of the name.
billing.method
stringMethod of payment. Can becard, account, amazon, paypal, or any one of the manual methods defined in payment settings.
billing.name
stringBilling full name. If `first_name` or `last_name` are updated, then `name` will be automatically updated as a combination of first/last.
billing.paypal
objectPayPal billing details used when billing.method=paypal.
paypal.payer_id
stringPayPal payer ID provided when a customer authorizes payment in a storefront.
paypal.payment_id
stringPayPal payment ID created when a customer initiates payment in a storefront.
paypal.nonce
stringpaypal.authorization_id
stringpaypal.order_id
stringbilling.phone
stringBilling phone number.
billing.state
stringBilling state/county/province/region.
billing.zip
stringBilling zip/postal code.
billing.intent
objectbilling.affirm
objectaffirm.checkout_token
stringbilling.resolve
objectresolve.charge_id
stringbilling.klarna
objectklarna.source
stringbilling.ideal
objectideal.token
stringbilling.bancontact
objectbancontact.source
stringbilling.google
objectgoogle.nonce
stringgoogle.gateway
stringbilling.apple
objectapple.nonce
stringapple.gateway
stringcoupon_code
stringCoupon code applied to the cart. See coupons for details.
items
array of objectList of line items describing the products ordered.
bundle_items
array of objectList of items offered as a bundle. Defaults to product.bundle_items.
id
objectIdID of the bundle item product.
product_id
objectIdrequiredID of the bundle item product.
product
productExpandable link to the bundle product.
quantity
intQuantity of the bundle item being ordered. Defaults to 1.
shipment_weight
floatautoWeight to be used in shipping calculation, if applicable.
variant_id
objectIdID of the bundle item variant.
variant
variantExpandable link to the bundle variant.
delivery
enumMethod of delivery taken automatically from product.delivery.
Possible enum values:
options
array of objectOptions that allow for variations of the base product. If the option is part of a variant or required=true, an option value must be set for the product to be added to a cart.
id
stringUnique identifier for the object.
name
stringHuman-friendly name of the option.
value
stringName value of the product option. When adding to the cart, specify either the product option value id or name (case-insensitive) to identify the value.
variant
booleanIndicates the option refers to a variant aspect.
price
currencyAdditional price added onto the base price of the product.
shipment_weight
floatAdditional shipping weight added onto the base weight of the product.
value_id
objectIdquantity_total
intTotal quantity of the bundle item to be fulfilled, calculated as item.quantity * bundle_item.quantity.
product_name
stringdescription
stringDescription used for custom line items, when product is not defined.
discounts
array of objectList of discounts to apply to the item. Normally populated by applying a coupon or promotions.
id
stringrequiredUnique identifier for the object. Should refer to one of the IDs in the cart discounts object.
amount
currencyrequiredFixed discount amount.
metadata
objectArbitrary item data, typically set in a checkout flow to store custom values. See Storefront API for details.
options
array of objectItem options matching one or more of product.options. When adding to the cart, specify either option id or name (case-insensitive) to identify the option.
Gift card products have two special options that can be used when fulfilling gift cards by email. Use the option ID send_email and value as the recipient email address, and send_note as a custom message from the customer to the recipient sent by email.
id
stringUnique identifier for the object.
name
stringName of the product option. Populated automatically when adding an option by ID.
price
currencyAdditional price added onto the base price of the product.
shipment_weight
floatAdditional shipping weight added onto the base weight of the product.
value
stringName value of the product option. When adding to the cart, specify either the product option value id or name (case-insensitive) to identify the value.
variant
booleanIndicates the option refers to a variant aspect.
value_id
objectIddelivery
enumMethod of delivery taken automatically from product.delivery
Possible enum values:
price
currencyPrice of the item. Override this value to set a custom price. Defaults to product price or sale price.
product_id
objectIdID of the item product.
product
productExpandable link to the product, if applicable.
quantity
intQuantity of the item being ordered. Defaults to 1.
shipment_weight
floatautoWeight to be used in shipping calculation, if applicable.
taxes
array of objectList of tax rules to apply to the item. Normally populated by tax settings.
id
stringrequiredUnique identifier for the object. Should refer to one of the IDs in the cart taxes object.
amount
currencyrequiredFixed tax amount.
variant_id
objectIdID of the item variant, if applicable.
variant
variantExpandable link to the variant, if applicable.
id
objectIdautoUnique identifier for the item.
discount_each
currencyTotal discount amount divided by quantity.
discount_total
currencyTotal discount applied to the item.
orig_price
currencyDisplays the original item list price and does not reflect discounts or sale pricing.
price_total
currencyTotal price added to sub total by multiplying quantity and price.
shipment_location
stringID of location from /settings/shipping/locations. If specified, shipping is calculated from this location. Otherwise, the store's default location will be used.
tax_each
currencyTotal tax amount divided by quantity.
tax_total
currencyTotal tax applied to the item.
trial_price_total
currencyTotal of all trial prices on the order.
subscription_paid
booleanIndicates the item has been fulfilled as a subscription and marked as paid by reference to this order.
product_name
stringThis field is a copy of the item's product.name.
purchase_option
objectpurchase_option.type
enumPossible enum values:
purchase_option.id
objectIdpurchase_option.name
stringpurchase_option.price
currencypurchase_option.auth_amount
currencypurchase_option.trial_days
intpurchase_option.plan_id
objectIdpurchase_option.plan_name
stringpurchase_option.plan_description
stringpurchase_option.billing_schedule
objectbilling_schedule.interval
enumPossible enum values:
billing_schedule.interval_count
intbilling_schedule.trial_days
intbilling_schedule.limit
intpurchase_option.order_schedule
objectorder_schedule.interval
enumPossible enum values:
order_schedule.interval_count
intorder_schedule.limit
intshipping
objectThe customer's shipping details. Defaults to account.shipping. Updating shipping will also update the corresponding account shipping object.
shipping.account_address_id
objectIdID of the customer's address on file.
shipping.account_address
account_addressExpandable link to the customer's address on file.
shipping.address1
stringShipping address line 1: (street address/PO box/company name).
shipping.address2
stringShipping address line 2: (apartment/suite/unit/building).
shipping.city
stringShipping city/district/suburb/town/village.
shipping.country
stringTwo-letter ISO country code.
shipping.default
booleanIndicates shipping details represent the customer's default shipping address.
shipping.first_name
stringShipping first name. If name is updated, then first_name will be automatically updated as the first word of the name.
shipping.last_name
stringShipping last name. If name is updated, then last_name will be automatically updated as the last words of the name.
shipping.name
stringShipping full name. If first_name or last_name are updated, then name will be automatically updated as a combination of first/last.
shipping.phone
stringShipping phone number.
shipping.price
currencyPrice of the shipping service. Defaults to `shipment_rating.services.price` chosen by setting `service`.
shipping.service
stringID of a shipping service as configured in shipment settings. Normally, this would be applied after retrieving shipping rates by using one of the shipment_rating.services.id values.
shipping.service_name
stringName of the shipping service. Defaults to shipment_rating.services.name chosen by setting service.
shipping.state
stringShipping state/county/province/region.
shipping.zip
stringShipping zip/postal code.
shipping.pickup
booleanIndicates if the shipping is local pick up
account_credit_amount
currencyAmount of customer's account credit applied for initial payment, if applicable.
account_info_saved
booleanSet true when the customer has indicated they want to save shipping and billing information to their account for future use.
account_logged_in
booleanIndicates the customer was logged into their account when placing the order.
account
AccountExpandable link to the customer's account.
comments
stringCustomer notes provided when placing the order, if any.
coupon_id
objectIdID of the coupon applied to the cart.
date_abandoned
dateDate the cart was or will be marked as abandoned.
date_abandoned_next
dateNext date the cart will be marked as abandoned when using a series of abandoned cart recovery notices (advanced cart recovery).
discounts
array of objectList of discounts applied to the cart.
id
stringUnique identifier for the object.
amount
currencyFixed discount amount.
rule
objectObject describing the discount rule details. Custom discounts don't require this value.
type
stringType of discount. Can be coupon or promo-<id> referring to the source of the discount. Custom discounts don't require this value.
display_currency
stringThree-letter ISO currency code representing the user's preferred display currency, if applicable.
display_locale
stringLocale code representing the user's preferred display locale, if applicable.
gift_message
stringOptional message to include with the order when shipping to the recipient.
giftcards
array of objectList of gift cards applied to the cart.
amount
currencyAmount of the gift card balance to spend on this order. Defaults to giftcard.balance.
code
stringSpecify a gift card code to apply to the cart. If the code is not found or invalid, a validation error is returned. Case-insensitive.
id
objectIdUnique identifier for the object.
code_formatted
stringFully formatted gift card code for display purposes.
giftcard
giftcardExpandable link to the gift card record.
last4
stringLast four digits of the gift card code.
gift
booleanIndicates the order is intended as a gift for the recipient.
guest
booleanIndicates the customer was not logged in when placing the order.
item_tax_included
booleanIndicates line item prices include taxes.
metadata
objectArbitrary data, typically set in a checkout flow to store custom values. See Storefront API for more details.
notes
stringInternal admin notes. These are not visible to the customer.
promotion_ids
array of child_scalarList of promotion IDs applied to the cart.
recovered
booleanIndicates the cart was recovered and converted to an order after being abandoned.
shipment_discount
currencyShipping discount applied by coupons, promotions, or custom logic.
shipment_tax
currencyShipping tax amount, if applicable.
shipment_tax_included
booleanIndicates shipping total includes taxes, if applicable.
taxes
array of objectList of taxes applied to the cart.
id
stringUnique identifier for the object.
amount
currencyFixed tax amount.
name
stringName of the tax rule. For example, "NY Sales Tax".
priority
intPriority indicates the order in which a tax rule was applied. Higher priority rules are added on top of other tax rules with a lower priority. Rules with the same priority are calculated excluding each other.
rate
floatTax percentage used in calculating the fixed amount.
shipping
booleanIndicates the tax applies to shipping.
abandoned
booleanIndicates the cart was abandoned after 3 hours of inactivity. After being marked as abandoned, this field is automatically set back to false after an update to items, billing, or shipping info.
abandoned_notifications
intNumber of abandoned cart notifications sent to the customer.
active
booleanIndicates the cart has been updated by a customer within the last 3 hours.
checkout_id
stringCustomer-facing unique identifier for the cart used in URLs and for abandoned cart recovery.
checkout_url
stringURL to checkout for the cart, set automatically when the cart has at least items, shipping, or billing details set. Can also be set explicitly when creating or updating the cart for custom checkouts.
coupon
CouponExpandable link to the coupon applied to the cart.
currency
stringThree-letter ISO currency code in uppercase. Defaults to the store's base currency.
currency_rate
floatCurrency percentage used in calculating the fixed amount.
date_webhook_first_failed
dateDate the order webhook first failed, if applicable. Value is unset after an order webhook is successfully returned for the record.
discount_total
currencyTotal discount amount.
giftcard_delivery
booleanIndicates the cart has at least one line item with delivery=giftcard.
giftcard_total
currencyautoTotal payment amount applied to the order from giftcards.
grand_total
currencyautoGrand total including items, shipping, and taxes.
item_discount
currencyTotal discount applied to line items.
item_shipment_weight
floatautoTotal shipping weight of all line items.
item_tax
currencyautoTotal taxes applied to line items.
item_quantity
intautoTotal quantity of all line items.
number
stringautoUnique incremental cart number, assigned automatically using a format configured in general settings.
order_id
objectIdID of the the converted order, if applicable.
order
OrderExpandable link to the converted order, if applicable.
promotions
PromotionExpandable list of promotions applied to the cart.
shipment_delivery
booleanIndicates the cart has at least one line item with delivery=shipment.
shipment_price
currencyTotal shipping price before discounts.
shipment_rating
objectObject describing the shipping services and rates available for the cart. Shipping country must be set before retrieving shipping rates.
shipment_rating.services
array of objectList of shipping services and rates available.
id
stringUnique identifier for the object.
name
stringName of the shipment service.
carrier
stringName of the third party carrier offering the service, if applicable.
price
currencyPrice of given shipment service.
pickup
booleanIndicated whether the shipment service is local pick-up.
tax_code
stringApplicable tax code for shipment service.
shipment_rating.errors
array of objectList of errors generated while retrieving rates, if any. When using third-party shipping services, any system errors will be listed here.
message
stringBrief description of the error.
code
stringUnique error code for reference.
shipment_rating.md5
stringMD5 hash value for referencing the shipment rating.
shipment_total
currencyTotal shipping price after discounts.
status
enumautoCurrent status of the cart. Can be active, converted, abandoned, or recovered.
Possible enum values:
sub_total
currencySum of all line items before discounts, taxes and shipping.
subscription
SubscriptionExpandable link to the subscription that spawned the order, if applicable.
subscription_delivery
booleanIndicates the cart has at least one line item with delivery=subscription.
subscription_id
objectIdID of the subscription that spawned the order, if applicable.
tax_included_total
currencyTotal with shipping and item taxes included. Allows for an alternate display style, as normally sub_total and tax_total are shown separately.
tax_total
currencyTotal tax amount applied to the cart including line items and shipping.
webhook_attempts_failed
intNumber of failed order webhook attempts, if applicable. Value is unset after an order webhook is successfully returned for the record.
webhook_response
stringText response of the last failed order webhook attempt, if applicable. Value is unset after an order webhook is successfully returned for the record.
webhook_status
intHTTP response status of the last failed order webhook attempt, if applicable. Value is unset after an order webhook is successfully returned for the record.
target_order_id
objectIdWhen a cart is converted to an order, this field represents the corresponding order_id.
target_order
OrderExpands into the order that the cart was converted into.
taxes_fixed
booleanIndicates the order is tax-exempt. Taxes will not be calculated or applied when true.
schedule
objectSchedule for a recurring order.
schedule.interval
enumInterval of recurring orders. Can be weekly, daily, monthly, yearly.
Possible enum values:
schedule.interval_count
intInterval multiplier for scheduled orders. For example, an interval_count=2 paired with an interval=monthly would recur twice a month.
account_credit_applied
booleanIndicates the customer's account credit is applied to the initial payment.
date_webhook_last_succeeded
dateDate the order webhook last succeeded, if applicable. Value is unset after an order webhook fails to return for the record.
purchase_links
Purchase LinkExpandable links to the purchase links added to the cart.
purchase_link_ids
array of child_scalarUnique identifiers for the purchase links.
purchase_links_errors
array of objectList of purchase link errors applied to the cart. Added when clicking on the purchase link, if any resources are blocking the creation of the cart.
id
objectIdautoUnique identifier for the purchase link errors.
error
objectrequiredA purchase link error object.
error.code
stringrequiredA distinct code indicating the cause of the purchase link error.
error.message
stringrequiredA human-readable description of the purchase link error.
error.resource
objectrequiredAn object describing the resource that blocked the creation of the cart.
resource.id
objectIdResource ID for the error.
resource.model
stringResource model. For example: products or promotions.
resource.name
stringA human-readable resource name.
purchase_link
purchase_linkExpandable link to the purchase link.
purchase_link_id
stringrequiredUnique identifier for the purchase link to which the error relates.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.put('/carts/{id}', {
id: '5cad15bc9b14d1990724663a',
shipping: {
name: 'Jon Snow',
address1: '1 Main Street',
city: 'Brooklyn',
state: 'NY',
zip: '11201',
country: 'US',
phone: '(555) 555-5555',
},
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"active": true,
"billing": {...},
"shipping": {
"name": "Jon Snow",
"first_name": "Jon",
"last_name": "Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": "11201",
"country": "US",
"phone": "(555) 555-5555"
},
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"price": 9.99,
"price_total": 18.98,
"shipment_weight": 1.5,
...
}
],
"coupon_code": "FREESHIPPING",
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"discount_total": 0,
"grand_total": 18.98,
"item_quantity": 2,
"item_shipment_weight": 3.0,
"item_tax": 0,
"number": "100101",
"shipment_price": 0,
"shipment_total": 0,
"status": "active",
"sub_total": 0,
"tax_total": 0,
...
}
Create a new order from an active cart. This call will map items and other properties from a cart while creating the order and mark the cart as converted. Returns an error if any of the required order properties are missing from the cart, or if product stock is unavailable.
Arguments
cart_id
objectIdID of the cart to convert.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/orders', {
cart_id: '5cad15bc9b14d1990724663a',
});
Response
{
"id": "5cad15bc9b14d1990724663b",
"account_id": "5a9ea7ba3f95740a914267f1",
"billing": {...},
"cart_id": "5cad15bc9b14d1990724663a",
"shipping": {...},
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"price": 9.99,
"price_total": 18.98,
"shipment_weight": 1.5,
...
}
],
"coupon_code": "FREESHIPPING",
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"delivered": false,
"discount_total": 0,
"grand_total": 18.98,
"item_quantity": 2,
"item_shipment_weight": 3.0,
"item_tax": 0,
"number": "100101",
"paid": false,
"payment_balance": -18.98,
"payment_total": 0,
"refund_total": 0,
"refunded": false,
"shipment_price": 0,
"shipment_total": 0,
"status": "payment_pending",
"sub_total": 0,
"tax_total": 0,
...
}
Return a list of carts
Arguments
expand
stringExpand link fields and child collections by using the expand argument.
- For example, expand=account would return a related customer account if one exists.
When the field represents a collection, you can specify the query limit.
- For example, expand=variants:10 would return up to 10 records of the variants collection.
See expanding for more details.
fields
stringReturns only the specified fields in the result.
- For example fields=name,slug would return only the fields name and slug in the response.
Supports nested object and array fields using dot-notation.
- For example, items.product_id. The product id is always returned.
include
objectInclude one or more arbitrary queries in the response which are potentially related to the main query.
See including for more details.
limit
intLimit the number of records returned, ranging between 1 and 1000. Defaults to 15.
page
intThe page number of results to return given the specified or default limit.
search
stringA text search is performed using the search argument. Searchable fields are defined by the model.
- For example, search=red would return records containing the word "red" anywhere in the defined text fields.
See searching for more details.
sort
stringExpression to sort results by using a format similar to a SQL sort statement.
- For example, sort=name asc would return records sorted by name ascending.
See sorting for more details.
where
objectAn object with criteria to filter the result.
- For example, active=true would return records containing a field active with the value true.
It's also possible to use query operators, for example, $eq, $ne, $gt, and more.
See querying for more details.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.get('/carts', {
where: { active: true },
limit: 25,
page: 1,
});
Response
{
"count": 51,
"results": [
{
"id": "5cad15bc9b14d1990724663a",
"active": true,
"billing": {...},
"shipping": {
"name": "Jon Snow",
"first_name": "Jon",
"last_name": "Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": "11201",
"country": "US",
"phone": "(555) 555-5555"
},
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"price": 9.99,
"price_total": 18.98,
"shipment_weight": 1.5,
...
}
],
"coupon_code": "FREESHIPPING",
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"discount_total": 0,
"grand_total": 18.98,
"item_quantity": 2,
"item_shipment_weight": 3.0,
"item_tax": 0,
"number": "100101",
"shipment_price": 0,
"shipment_total": 0,
"status": "active",
"sub_total": 0,
"tax_total": 0,
...
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}
Arguments
id
objectIdrequiredThe id for the cart to delete.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.delete('/carts/{id}', {
id: '5cad15bc9b14d1990724663a',
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"active": true,
"billing": {...},
"shipping": {
"name": "Jon Snow",
"first_name": "Jon",
"last_name": "Snow",
"address1": "1 Main Street",
"city": "Brooklyn",
"state": "NY",
"zip": "11201",
"country": "US",
"phone": "(555) 555-5555"
},
"items": [
{
"id": "5a9ea7ba3f95740a914267f2",
"product_id": "5cad15bc9b14d1990724663b",
"quantity": 2,
"price": 9.99,
"price_total": 18.98,
"shipment_weight": 1.5,
...
}
],
"coupon_code": "FREESHIPPING",
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"discount_total": 0,
"grand_total": 18.98,
"item_quantity": 2,
"item_shipment_weight": 3.0,
"item_tax": 0,
"number": "100101",
"shipment_price": 0,
"shipment_total": 0,
"status": "active",
"sub_total": 0,
"tax_total": 0,
...
}