Backend API
Products represent items that can be sold to a customer, either as one-off sales or as subscriptions. For more complex subscription products and when physical items are involved, it's recommended to create a subscription plan.
Fields
id
objectIdUnique identifier for the product.
name
stringrequiredHuman-friendly name of the product.
active
booleanIndicates whether the product is active and available in the storefront.
purchase_options
objectConfiguration of one or more purchase options for the product. Can be standard for one-time purchases or subscription for a subscription plan. Products can support both purchase options simultaneously.
purchase_options.standard
objectDesignates purchase option as a one-time purchase.
standard.id
objectIdID of the purchase option.
standard.name
stringrequiredThe name of the purchase option.
standard.description
stringA long-form description of the product. May contain HTML or other markup languages.
standard.active
booleanIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
standard.price
currencyList price used when sale=false or sale_price is not defined.
standard.sale
booleanIndicates whether the product option is on sale. If true, the sale_price will be used by default when the product is added to a cart.
standard.sale_price
currencySale price used by default when sale=true, overriding price. Overrides product sale price.
standard.prices
array of objectPrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
.price
currencyrequiredPrice applied when conditions are met.
.account_group
stringCustomer account group as a condition to apply price.
.quantity_max
intMaximum quantity as a condition to apply price.
.quantity_min
intMinimum quantity as a condition to apply price.
standard.account_groups
array of stringArray of account groups that are eligible to access the purchase option within the storefront.
purchase_options.subscription
objectDesignates purchase option for a subscription plan.
subscription.id
objectIdautoID of the subscription plan purchase option.
subscription.name
stringrequiredName of the subscription plan purchase option.
subscription.description
stringA long-form description of the purchase option. May contain HTML or other markup languages.
subscription.active
booleanIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
subscription.account_groups
array of stringArray of account_group names for which the purchase option is available.
subscription.plans
array of plansArray defining subscription plans and their respective configurations.
plans.id
objectIdID of the purchase option subscription plan.
plans.name
stringrequiredName of the subscription plan.
plans.description
stringA long-form description of the subscription plan. May contain HTML or other markup languages.
plans.active
booleanIndicates whether the subscription plan is available for customers to purchase. Inactive products will not be returned on the Frontend.
plans.price
currencyList price used when sale=false or sale_price is not defined.
plans.prices
array of objectPrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
.price
currencyrequiredPrice applied when conditions are met.
.account_group
stringCustomer account group as a condition to apply price.
.quantity_max
intMaximum quantity as a condition to apply price.
.quantity_min
intMinimum quantity as a condition to apply price.
plans.billing_schedule
objectrequiredDetermines the billing schedule for the subscription plan.
billing_schedule.interval
enumSubscription plan billing interval. Can be daily, weekly, monthly, or yearly.
Possible enum values:
billing_schedule.interval_count
intrequiredMultiplier for billing interval. For example, to make the billing cycle once every two weeks, set interval=weekly and interval_count=2.
billing_schedule.limit
intSpecifies a limit to the number of billing cycles for the subscription plan. For example, limit=10 would stop billing the customer after the tenth billing cycle.
billing_schedule.trial_days
intNumber of days offered as a free trial on the subscription plan before the customer is billed. If a subscription is canceled by the last day of the trial period, an invoice won't be issued.
attributes
objectAn object containing custom attribute key/value pairs.
bundle
booleanIndicates whether the product is a bundle of other products.
bundle_items
array of objectList of products sold as a bundle. Applicable only when bundle=true.
id
objectIdautoUnique identifier for the bundle item.
product_id
objectIdrequiredID of the bundled product.
product
productExpandable link to the bundled product.
quantity
intQuantity of the bundled product. Defaults to 1.
variant_id
objectIdID of the bundled variant, if applicable.
variant
variantExpandable link to the bundled product variant, if applicable.
product_name
stringThis field is a copy of the item's product.name.
category
CategoryExpandable link to the primary category.
category_id
objectIdPrimary category, commonly used as a navigation anchor.
categories
CategoryExpandable link to all related product categories.
category_index
objectIndex of categories used for fast lookup operations.
category_index.id
array of child_scalarList of related product category IDs.
category_index.sort
objectIndex of category IDs and their respective sort positions.
code
stringUnique code to identify the gift card product.
cost
currencyCost of goods (COGS) used to calculate gross margins.
cross_sells
array of objectList of products to display as cross-sells on a shopping cart page.
id
objectIdautoUnique identifier for the cross-sell object.
product_id
objectIdrequiredID of the cross-sell product.
product
productExpandable link to the cross-sell product.
discount_type
enumType of discount to apply, either fixed or percent.
Possible enum values:
discount_amount
currencyDiscount to apply as a fixed amount. Applicable only when discount_type=fixed.
discount_percent
floatDiscount to apply as a percentage. Applicable only when discount_type=percent.
currency
stringThree-letter ISO currency code in uppercase. Defaults to your store's base currency.
customizable
booleanIndicates whether the product has custom options enabled.
date_created
dateautoDate and time the product was created.
date_updated
dateautoDate and time the product was last updated.
delivery
enumautoMethod of fulfillment automatically assigned based on type:
- shipment means the product will be physically shipped to a customer.
- subscription means the product will be fulfilled as a subscription when an order is placed. giftcard delivery means the product will be fulfilled as a gift card when an order is placed.
- null means the product will not be fulfilled by one of the above methods.
Note: A bundle has its child products fulfilled individually; each product in the bundle must have its own fulfillment method.
Possible enum values:
description
stringA long-form description of the product. May contain HTML or other markup languages.
discontinued
booleanIndicates whether the product has been discontinued.
images
array of objectList of images depicting the bundle.
id
objectIdautoUnique identifier for the image.
caption
stringA brief description of the image, intended for display as a caption or alt text.
file
objectAn object representing the image's source file.
file.id
objectIdUnique identifier for the file.
file.filename
stringOptional file name.
file.data
filedataA reference to the raw file data.
file.content_type
stringMIME content type of the file.
file.date_uploaded
dateDate the file was uploaded.
file.height
intImage height in pixels, if applicable.
file.length
intSize of the file in bytes.
file.metadata
objectA set of arbitrary data that is typically used to store custom values.
file.md5
stringAn MD5 hash of the file contents. This can be used to uniquely identify the file for caching purposes.
file.private
booleanIndicates whether the file is private.
file.url
stringA public URL to reference the file. Updated automatically if file content changes.
file.width
intImage width in pixels, if applicable.
meta_title
stringPage title used to override product name in storefronts.
meta_keywords
stringPage keywords used for search engine optimization purposes.
meta_description
stringPage description used for search engine optimization purposes.
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
objectIdautoUnique identifier for the object.
name
stringrequiredHuman-friendly name of the option.
input_hint
stringSome brief hint text to help the user understand this option.
input_type
enumType of user input to display for this option in a storefront. The select type is ideal for dropdown or radio selections, toggle can be used either to show another option or as a price modifier, and text fields can capture user input like a message.
Possible enum values:
parent_id
objectIdSpecifies another option ID that affects visibility of this option. The option will only appear when one of the parent_value_ids is selected.
parent_value_ids
array of child_scalarIDs of parent option values that will make the option appear if selected.
price
currencyExtra price for the option, added to the product's price/sale_price. If the option is part of a variant, the variant's price/sale_price will override this value.
required
booleanIndicates whether the option requires a value when the product is added to a cart.
subscription
booleanIndicates whether the option specifies the billing interval of a subscription plan.
values
array of objectList of possible values for this option.
id
objectIdautoUnique identifier for the object.
name
stringrequiredHuman-friendly name of the option value.
color
stringName of the product color.
description
stringA brief description of the option value, intended for displaying to customers.
price
currencyExtra price added to the product's price/sale_price if the option value is selected. Overrides option price.
shipment_weight
floatExtra weight added to the product's shipment_weight if the option value is selected. The unit should match the store's default as configured in general settings.
subscription_interval
enumWhen product type=subscription, this is the billing interval used when this option value is selected. Can be monthly, yearly, weekly, or daily.
Possible enum values:
subscription_interval_count
intWhen product type=subscription, this number multiplies subscription_interval to determine the billing frequency when this option is selected. For example, to make a subscription bill every two weeks, set subscription_interval=weekly and subscription_interval_count=2.
subscription_trial_days
intWhen product type=subscription, refers to a number of days offered as a trial before an invoice is issued.
image
objectImage depicting the product.
image.id
objectIdUnique identifier for the object.
image.data
filedataA reference to the raw file data.
image.date_uploaded
dateDate the file was uploaded.
image.length
intSize of the file in bytes.
image.md5
stringAn MD5 hash of the file contents. This can be used to uniquely identify the file for caching purposes.
image.filename
stringOptional file name.
image.content_type
stringMIME content type of the file.
image.metadata
objectArbitrary data
image.private
booleanimage.url
stringimage.width
intimage.height
intimages
array of objectid
objectIdautocaption
stringfile
objectfile.id
objectIdfile.date_uploaded
datefile.length
intfile.md5
stringfile.filename
stringfile.content_type
stringfile.metadata
objectfile.data
filedatafile.private
booleanfile.url
stringfile.width
intfile.height
intattribute_id
stringUnique identifier for the attribute.
description
stringDescription for the product options.
active
booleanIndicates the options are active.
input_multi
booleanIndicates there are multiple selections for options.
variant
booleanIndicates the option is a variant.
orig_price
currencyReflects the non-sale price of the product
price
currencyList price used when sale=false or sale_price is not defined. This value is intended for use via the frontend. See the purchase_options array to manage a product's price.
prices
array of pricePrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
price.price
currencyrequiredPrice applied when conditions are met.
price.account_group
stringCustomer account group as a condition to apply price.
price.quantity_max
intMaximum quantity as a condition to apply price.
price.quantity_min
intMinimum quantity as a condition to apply price.
quantity_min
intMinimum quantity of the product that can be sold at once.
quantity_inc
intSpecifies a quantify multiple the product must be sold in.
related_product_ids
array of child_scalarArray of related product IDs.
sale
booleanIndicates whether the product is on sale. If true, the sale_price will be used by default when the product is added to a cart.
sale_price
currencySale price used to override list price when sale=true.
shipment_dimensions
objectrequiredProduct dimensions when packed for shipping. Typically used by third-party carriers in box packing algorithms to optimize shipping costs.
shipment_dimensions.length
floatrequiredLength of the product in unit.
shipment_dimensions.width
floatrequiredWidth of the product in unit.
shipment_dimensions.height
floatrequiredHeight of the product in unit.
shipment_dimensions.unit
enumrequiredEither in(inches) or cm(centimeters).
Possible enum values:
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_package_quantity
floatIf specified, shipping is calculated using this as the maximum number of items per package. Otherwise, Swell assumes any quantity fits into a single package.
shipment_prices
array of objectProduct shipping price rules to override default shipping rules.
service
stringrequiredShipping service required for this rule to apply.
account_group
stringCustomer group required for this rule to apply.
country
stringShipping country required for this rule to apply.
fee_amount
currencyFixed amount to add when rule is applied. Only applicable when fee_type=fixed.
fee_percent
floatPercentage of the shipping price to add when rule is applied. Only applicable when fee_type=percent.
fee_type
enumType of fee to apply in addition to price, either fixed or percent.
Possible enum values:
package_quantity
intMaximum package quantity when rule is applied.
price
currencyShipping price when rule is applied.
state
stringShipping state required for this rule to apply.
total_max
currencyMaximum order subtotal for this rule to apply.
total_min
currencyMinimum order subtotal for this rule to apply.
weight_max
floatMaximum order item weight for this rule to apply.
weight_min
floatMinimum order item weight for this rule to apply.
zip
stringShipping zip/postal code required for this rule to apply.
shipment_weight
floatIf specified, shipping is calculated using this weight. Otherwise, Swell assumes 1 lb/oz/kg—depending on the store's default weight unit.
subscription_interval
enumThe default billing interval when this product is used as a subscription plan. Can be monthly, yearly, weekly, or daily.
Possible enum values:
subscription_interval_count
intMultiplier when combined with subscription_interval. For example, to make a subscription bill every two weeks, set subscription_interval=weekly and subscription_interval_count=2.
subscription_trial_days
intNumber of days offered as a free trial before the customer is billed. If a subscription is canceled by the last day of the trial period, an invoice won't be issued.
sku
stringrequiredStock keeping unit (SKU) used to track inventory in a warehouse.
slug
stringrequiredLowercase, hyphenated identifier typically used in URLs. When creating a product, a slug will be generated automatically from the name. Maximum length of 1,000 characters.
stock
array of StockExpandable list of stock adjustments for the product.
stock_backorder
booleanIndicates whether the product can be backordered if out of stock.
stock_level
intQuantity of the product currently in stock (including all variants), based on the sum of the stock entries.
stock_preorder
booleanIndicates whether the product can be purchased as a preorder.
stock_purchasable
booleanIndicates whether the product's stock is purchasable.
stock_status
enumautoString indicating the product's stock status for the purpose of ordering. When stock_purchasable=true, an order can be placed for this product regardless of current stock status. Otherwise an order submission will be blocked unless stock status is available, preorder, or backorder.
Possible enum values:
stock_tracking
booleanIndicates whether the product has stock tracking enabled.
summary
stringA brief product summary.
tags
array of child_scalarArray of searchable tags to aid in search discoverability.
tax_class
stringIndicates the tax class for the product.
tax_code
stringProduct tax code for tracking with Avalara, TaxJar, etc.
type
stringImplies the ordering and fulfillment options available for the product. Can be standard, subscription, bundle, or giftcard. A standard product is a physical item that will be shipped to a customer.
up_sells
array of objectList of products to display as up-sells on a product detail page.
id
objectIdautoUnique identifier for the up-sell.
product_id
objectIdrequiredID of the up-sell product.
product
productExpandable link to the up-sell product.
variable
booleanIndicates whether the product has variant generation enabled.
variants
array of VariantsExpandable list of variants representing unique variations of the product. Each variant is a combination of one or more options. For example, Size and Color.
virtual
booleanIndicates whether the product is virtual.
The product model
{
"name": "Iron dagger",
"sku": "00090616",
"active": true,
"purchase_options": {
"standard": {
"active": true,
"price": 10,
"sale_price": null,
"sale": false,
"prices": []
},
"subscription": {
"active": true,
"plans": [
{
"name": "Monthly",
"description": "1 dagger/month",
"price": 9,
"billing_schedule": {
"interval": "monthly",
"interval_count": 1,
"limit": null,
"trial_days": 14
},
"id": "627c6f180d375a001296b593",
"active": true
}
]
}
},
"variable": true,
"description": "<h3>Damage: 7</h3><h3>Weight: 8</h3><h3>Health: 98</h3><h3>Speed: 1.4</h3><h3>Reach: 0.6</h3>",
"tags": [],
"meta_title": null,
"meta_description": null,
"slug": "iron-dagger",
"attributes": {
"blade": "",
"dagger": "",
"type": [
"Fine",
"Rusty"
]
},
"delivery": "shipment",
"bundle": null,
"price": 10,
"stock_tracking": false,
"options": [
{
"id": "627c6e36e80393798c171670",
"values": [
{
"id": "627c6f18e80393798c171673",
"name": "Fine",
"price": null,
"shipment_weight": null,
"description": "A better-than-usual iron dagger"
},
{
"id": "627c6f18e80393798c171674",
"name": "Rusty",
"price": 0,
"shipment_weight": null,
"description": "This dagger's seen better days"
}
],
"name": "Type",
"active": true,
"input_type": "select",
"variant": true,
"description": null,
"required": true,
"attribute_id": "type"
}
],
"currency": "USD",
"sale": false,
"sale_price": null,
"prices": [],
"type": "standard",
"tax_class": "standard",
"date_created": "2022-05-12T02:21:12.534Z",
"stock_status": null,
"date_updated": "2022-05-12T02:37:45.666Z",
"category_index": {
"sort": {
"627c6db5632818001272f8ed": 0,
"627c6dc30d375a001296a8b7": 0
},
"id": [
"627c6db5632818001272f8ed",
"627c6dc30d375a001296a8b7"
]
},
"cross_sells": [],
"up_sells": [
{
"id": "627c7225e80393798c17167b",
"product_id": "627c715e632818001274ebd8"
}
],
"id": "627c6f180d375a001296b580"
Create a new product. If you wish to generate your own unique ID for the record, it must use BSON ObjectID format for compatibility.
Arguments
name
stringrequiredHuman-friendly name of the product.
price
currencyList price used when sale=false or sale_price is not defined. This value is intended for use via the frontend. See the purchase_options array to manage a product's price.
attributes
objectAn object containing custom attribute key/value pairs. See attributes for more details.
slug
stringLowercase, hyphenated identifier typically used in URLs. When creating a product, a slug will be generated automatically from the name. Maximum length of 1,000 characters.
purchase_options
objectConfiguration of one or more purchase options for the product. Can be standard for one-time purchases or subscription for a subscription plan. Products can support both purchase options simultaneously.
purchase_options.standard
objectDesignates purchase option as a one-time purchase.
standard.id
objectIdID of the purchase option.
standard.name
stringrequiredThe name of the purchase option.
standard.description
stringA long-form description of the product. May contain HTML or other markup languages.
standard.active
booleanIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
standard.price
currencyList price used when sale=false or sale_price is not defined.
standard.sale
booleanIndicates whether the product option is on sale. If true, the sale_price will be used by default when the product is added to a cart.
standard.sale_price
currencySale price used by default when sale=true, overriding price. Overrides product sale price.
standard.prices
array of objectPrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
.price
currencyrequiredPrice applied when conditions are met.
.account_group
stringCustomer account group as a condition to apply price.
.quantity_max
intMaximum quantity as a condition to apply price.
.quantity_min
intMinimum quantity as a condition to apply price.
standard.account_groups
array of stringArray of account groups that are eligible to access the purchase option within the storefront.
purchase_options.subscription
objectDesignates purchase option as a subscription plan.
subscription.id
objectIdID of the subscription plan purchase option.
subscription.name
stringrequiredName of the subscription plan purchase option.
subscription.description
stringA long-form description of the purchase option. May contain HTML or other markup languages.
subscription.active
booleanIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
subscription.account_groups
array of stringArray of account_group names for which the purchase option is available.
subscription.plans
array of objectArray defining subscription plans and their respective configurations.
.id
objectIdID of the purchase option subscription plan.
.name
stringrequiredName of the subscription plan.
.description
stringA long-form description of the subscription plan. May contain HTML or other markup languages.
.active
booleanIndicates whether the subscription plan is available for customers to purchase. Inactive products will not be returned on the Frontend.
.price
currencyList price used when sale=false or sale_price is not defined.
.prices
array of objectPrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
.price
currencyrequiredPrice applied when conditions are met.
.account_group
stringCustomer account group as a condition to apply price.
.quantity_max
intMaximum quantity as a condition to apply price.
.quantity_min
intMinimum quantity as a condition to apply price.
.billing_schedule
objectrequiredDetermines the billing schedule for the subscription plan.
billing_schedule.interval
enumrequiredSubscription plan billing interval. Can be daily, weekly, monthly, or yearly.
Possible enum values:
billing_schedule.interval_count
intrequiredMultiplier for billing interval. For example, to make the billing cycle once every two weeks, set interval=weekly and interval_count=2.
billing_schedule.limit
intSpecifies a limit to the number of billing cycles for the subscription plan. For example, limit=10 would stop billing the customer after the tenth billing cycle.
active
booleanSet true to make the product visible to customers in a storefront, otherwise it will be hidden.
bundle
booleanIndicates whether the product is a bundle of other products.
bundle_items
array of objectList of products sold as a bundle. Applicable only when bundle=true.
id
objectIdautoID of the bundled product.
product_id
objectIdrequiredID of the bundled product.
product
productExpandable link to the bundled product.
quantity
intQuantity of the bundled product. Defaults to 1.
variant_id
objectIdID of the bundled variant, if applicable.
variant
variantExpandable link to the bundled product variant, if applicable.
categories
CategoryExpandable link to all related product categories.
category
CategoryExpandable link to the primary category.
category_id
objectIdPrimary category, commonly used as a navigation anchor.
category_index
objectIndex of categories used for fast lookup operations.
category_index.sort
objectIndex of category IDs and their respective sort positions.
sort.*
intcode
stringUnique code to identify the gift card product.
cost
currencyCost of goods (COGS) that is used to calculate gross margins.
cross_sells
array of objectList of products to display as cross-sells on a shopping cart page.
id
objectIdautoUnique identifier for the cross-sell object.
product_id
objectIdrequiredID of the cross-sell product.
product
productExpandable link to the cross-sell product.
discount_amount
currencyDiscount to apply as a fixed amount. Applicable only when discount_type=fixed.
discount_percent
floatDiscount to apply as a percentage. Applicable only when discount_type=percent.
discount_type
enumType of discount to apply, either fixed or percent.
Possible enum values:
currency
stringThree-letter ISO currency code in uppercase. Defaults to your store's base currency.
customizable
booleanSet true to enable custom options for this product in the admin panel.
delivery
enumMethod of fulfillment automatically assigned based on type:
- shipment means the product will be physically shipped to a customer.
- subscription means the product will be fulfilled as a subscription when an order is placed. giftcard delivery means the product will be fulfilled as a gift card when an order is placed.
- null means the product will not be fulfilled by one of the above methods.
Note: A bundle has its child products fulfilled individually; each product in the bundle must have its own fulfillment method.
Possible enum values:
description
stringA long form description of the product. May have HTML or other markup.
discontinued
booleanIndicates whether the product has been discontinued.
images
array of objectList of images depicting the bundle.
id
objectIdautoUnique identifier for the image.
caption
stringA brief description of the image, intended for display as a caption or alt text.
file
objectAn object representing the image's source file.
file.id
objectIdUnique identifier for the file.
file.date_uploaded
dateDate the file was uploaded.
file.length
intSize of the file in bytes.
file.md5
stringAn MD5 hash of the file contents. This can be used to uniquely identify the file for caching purposes.
file.filename
stringOptional file name.
file.content_type
stringMIME content type of the file.
file.metadata
objectA set of arbitrary data that is typically used to store custom values.
file.data
filedataSet or overwrite file data. Use the following format when writing a file from binary data (for example an image): data[$binary]=<base64 encoded binary data>.
file.private
booleanIndicates whether the file is private.
file.url
stringA public URL to reference the file. Updated automatically if file content changes.
file.width
intImage width in pixels, if applicable.
file.height
intImage height in pixels, if applicable.
meta_description
stringPage description used for search engine optimization purposes.
meta_keywords
stringPage keywords used for search engine optimization purposes.
meta_title
stringPage title used to override product name in storefronts.
prices
array of objectSet price rules to use when conditions match the customer's account group or product quantity in a cart.
price
currencyrequiredPrice applied when conditions are met.
account_group
stringCustomer account group as a condition to apply price.
quantity_max
intMaximum quantity as a condition to apply price.
quantity_min
intMinimum quantity as a condition to apply price.
quantity_inc
intSpecifies a quantified multiple the product must be sold in.
quantity_min
intMinimum quantity of the product that can be sold at once.
related_product_ids
array of child_scalarArray of related product IDs.
sale
booleanSet true to mark the product "on sale" and to use sale_price when the product is added to a cart.
sale_price
currencySale price used to override list price when sale=true.
shipment_dimensions
objectProduct dimensions when packed for shipping. Typically used by 3rd party carriers in box packing algorithms to optimize shipping costs.
shipment_dimensions.height
floatHeight of the product in unit.
shipment_dimensions.length
floatLength of the product in unit.
shipment_dimensions.unit
enumEither in (inches) or cm (centimeters).
Possible enum values:
shipment_dimensions.width
floatWidth of the product in unit.
shipment_location
stringID of location from /settings/shipping/locations. If specified, shipping is calculated from this origin. Otherwise, the store's default location will be used.
shipment_package_quantity
floatIf specified, shipping is calculated using this as the maximum number of items per package. Otherwise, Swell assumes any quantity fits into a single package.
shipment_prices
array of objectProduct shipping price rules to override default shipping rules.
service
stringrequiredShipping service required for this rule to apply.
package_quantity
intMaximum package quantity when rule is applied.
price
currencyShipping price when rule is applied.
fee_type
enumType of fee to apply in addition to price, either fixed or percent.
Possible enum values:
fee_amount
currencyFixed amount to add when rule is applied. Only applicable when fee_type=fixed.
fee_percent
floatPercentage of the shipping price to add when rule is applied. Only applicable when fee_type=percent.
total_min
currencyMinimum order subtotal for this rule to apply.
total_max
currencyMaximum order subtotal for this rule to apply.
weight_min
floatMinimum order item weight for this rule to apply.
weight_max
floatMaximum order item weight for this rule to apply.
state
stringShipping state required for this rule to apply.
zip
stringShipping zip/postal code required for this rule to apply.
country
stringShipping country required for this rule to apply.
account_group
stringCustomer group required for this rule to apply.
shipment_weight
floatIf specified, shipping is calculated using this weight. Otherwise, Swell assumes 1 lb/oz/kg — depending on store's default weight unit.
sku
stringStock keeping unit (SKU) used to track inventory in a warehouse.
stock
array of StockExpandable list of stock adjustments for the product.
stock_backorder
booleanIndicates whether the product can be backordered if out of stock.
stock_level
intQuantity of the product currently in stock (including all variants), based on the sum of the stock entries.
stock_preorder
booleanIndicates whether the product can be purchased as a preorder.
stock_purchasable
booleanIndicates whether the product's stock is purchasable.
stock_status
enumautoString indicating the product's stock status for the purpose of ordering. When stock_purchasable=true, an order can be placed for this product regardless of current stock status, otherwise an order submission will be blocked unless stock status is available, preorder ,or backorder.
Possible enum values:
stock_tracking
booleanSet true to enable stock tracking this product.
subscription_interval
enumThe default billing interval when this product is used as a subscription plan. Can be monthly, yearly, weekly, or daily.
Possible enum values:
subscription_interval_count
intMultiplier when combined with subscription_interval. For example, to make a subscription bill every 2 weeks, set subscription_interval=weekly and subscription_interval_count=2.
subscription_trial_days
intNumber of days offered as a free trial before the customer is billed. If a subscription is canceled by the last day of the trial period, an invoice won't be issued.
summary
stringA brief product summary.
tax_class
stringIndicates the tax class for the product.
tax_code
stringProduct tax code for tracking with Avalara, TaxJar, etc.
up_sells
array of objectList of products to display as up-sells on a product detail page.
id
objectIdautoUnique identifier for the up-sell.
product_id
objectIdrequiredID of the up-sell product.
product
productExpandable link to the up-sell product.
variable
booleanSet true to generate variants for this product in the admin panel.
variants
array of VariantsExpandable list of variants representing unique variations of the product. Each variant is a combination of one or more options. For example, Size and Color.
virtual
booleanIndicates whether the product is virtual.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/products', {
name: 'T-Shirt',
price: 99.00,
active: true,
options: [
{
name: 'Size',
values: [
{
name: 'Small',
},
{
name: 'Large',
},
],
},
{...},
],
});
Response
{
"id": "5ca24abb9c077817e5fe2b36",
"active": true,
"attributes": {},
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"delivery": "shipment",
"name": "T-Shirt",
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Size",
"variant": true,
"required": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "Small"
},
{
"id": "5ca24ad59c077817e5fe2ba4",
"name": "Medium"
},
{
"id": "5ca24ad59c077817e5fe2ba5",
"name": "Large"
}
]
}
],
"price": 99.00,
"slug": "swell-t-shirt",
"type": "standard"
}
Retrieve an existing product using the ID that was returned when created.
Arguments
id
objectIdrequiredThe id of the product 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('/products/{id}', {
});
Response
{
"id": "5ca24abb9c077817e5fe2b36",
"active": true,
"attributes": {},
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-02T00:26:23.399Z",
"delivery": "shipment",
"description": null,
"images": [
{
"id": "5ca24abb9c077817e5fe2b37",
"file": {
"id": "5ca24abb9c077817e5fe2b38",
"date_uploaded": "2019-04-02T00:26:23.399Z",
"length": 66764,
"md5": "99194f53bfdea832553e7fa8ae8fd80f",
"content_type": "image/png",
"url": "http://cdn.swell.store/test/5ca24abb9c077817e5fe2b36/99194f53bfdea832553e7fa8ae8fd80f",
"width": 940,
"height": 600
}
}
],
"meta_description": null,
"meta_title": null,
"name": "T-Shirt",
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Size",
"variant": true,
"required": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "Small"
},
{
"id": "5ca24ad59c077817e5fe2ba4",
"name": "Medium"
},
{
"id": "5ca24ad59c077817e5fe2ba5",
"name": "Large"
}
]
}
],
"price": 9.99,
"slug": "swell-t-shirt",
"stock_level": 0,
"stock_status": "available",
"stock_tracking": true,
"tags": [],
"type": "standard"
}
Updates an existing product 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 product.
active
booleanSet true to make the product visible to customers in a storefront, otherwise it will be hidden.
attributes
objectAn object containing custom attribute key/value pairs. See attributes for more details.
name
stringHuman-friendly name of the product.
price
currencyList price used when sale=false or sale_price is not defined. This value is intended for use via the frontend. See the purchase_options array to manage a product's price.
slug
stringLowercase, hyphenated identifier typically used in URLs. When creating a product, a slug will be generated automatically from the name. Maximum length of 1,000 characters.
purchase_options
objectConfiguration of one or more purchase options for the product. Can be standard for one-time purchases or subscription for a subscription plan. Products can support both purchase options simultaneously.
purchase_options.standard
objectDesignates purchase option as a one-time purchase.
standard.id
objectIdID of the purchase option.
standard.name
stringrequiredThe name of the purchase option.
standard.description
stringIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
standard.active
booleanWhether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
standard.price
currencyList price used when sale=false or sale_price is not defined.
standard.sale
booleanIndicates whether the product option is on sale. If true, the sale_price will be used by default when the product is added to a cart.
standard.sale_price
currencySale price used by default when sale=true, overriding price. Overrides product sale price.
standard.prices
array of objectPrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
.price
currencyrequiredPrice applied when conditions are met.
.account_group
stringCustomer account group as a condition to apply price.
.quantity_max
intMaximum quantity as a condition to apply price.
.quantity_min
intMinimum quantity as a condition to apply price.
standard.account_groups
array of stringArray of account groups that are eligible to access the purchase option within the storefront.
purchase_options.subscription
objectDesignates purchase option as a subscription plan.
subscription.id
objectIdautoID of the subscription plan purchase option.
subscription.name
stringrequiredName of the subscription plan purchase option.
subscription.description
stringA long-form description of the purchase option. May contain HTML or other markup languages.
subscription.active
booleanIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
subscription.account_groups
array of stringArray of account_group names for which the purchase option is available.
subscription.plans
array of plansArray defining subscription plans and their respective configurations.
plans.id
objectIdID of the purchase option subscription plan.
plans.name
stringName of the subscription plan.
plans.description
stringA long-form description of the subscription plan. May contain HTML or other markup languages.
plans.active
booleanIndicates whether the subscription plan is available for customers to purchase. Inactive products will not be returned on the Frontend.
plans.price
currencyList price used when sale=false or sale_price is not defined.
plans.prices
array of objectPrice rules determined by cart quantity or customer account group. Overrides price and sale_price when conditions match.
.price
currencyPrice applied when conditions are met.
.account_group
stringCustomer account group as a condition to apply price.
.quantity_max
intMaximum quantity as a condition to apply price.
.quantity_min
intMinimum quantity as a condition to apply price.
plans.billing_schedule
objectrequiredDetermines the billing schedule for the subscription plan.
billing_schedule.interval
enumSubscription plan billing interval. Can be daily, weekly, monthly, or yearly.
Possible enum values:
billing_schedule.interval_count
intrequiredMultiplier for billing interval. For example, to make the billing cycle once every two weeks, set interval=weekly and interval_count=2.
billing_schedule.limit
intSpecifies a limit to the number of billing cycles for the subscription plan. For example, "limit"=10 would stop billing the customer after the tenth billing cycle.
bundle
booleanIndicates whether the product is a bundle of other products.
bundle_items
objectList of products sold as a bundle. Applicable only when bundle=true.
bundle_items.product_id
objectIdThe id of the bundled product.
bundle_items.quantity
intQuantity of the bundled product.
bundle_items.variant_id
objectIdThe id of the bundled variant, if applicable.
category_id
objectIdPrimary category, commonly used as a navigation anchor.
cost
currencyCost of goods (COGS) used to calculate gross margins.
cross_sells
objectList of products to display as cross-sells on a shopping cart page.
cross_sells.product_id
objectIdThe id of the cross-sell product.
cross_sells.discount_amount
currencyDiscount to apply as a fixed amount. Applicable only when discount_type=fixed
cross_sells.discount_percent
floatDiscount to apply as a percentage. Applicable only when discount_type=percent.
cross_sells.discount_type
stringType of discount to apply: fixed or percent.
customizable
booleanSet true to enable custom options for this product in the admin panel.
description
stringA long form description of the product. May have HTML or other markup.
images
objectList of images depicting the bundle.
images.caption
stringA brief description of the image, intended for display as a caption or alt text.
images.file
objectAn object representing the image's source file.
file.data
fileSet or overwrite file data. Use the following format when writing a file from binary data (for example an image): data[$binary]=<base64 encoded binary daya>.
file.filename
stringOptional file name.
meta_description
stringPage description used for search engine optimization purposes.
meta_keywords
stringPage keywords used for search engine optimization purposes.
meta_title
stringPage title used to override product name in storefronts.
Options
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.
Options.name
stringHuman-friendly name of the option.
Options.input_hint
stringSome brief hint text to help the user understand this option.
Options.input_type
stringType of user input to display for this option in a storefront. Can be text, textarea, select, multi_select, file or multi_file. select is ideal for dropdown or radio selectors, and multi_select is ideal for checkboxes. A maximum of 10 files can be uploaded by the user, and there are no restrictions on file type.
Options.parent_id
objectIdSpecifies another option ID that affects visibility of this option. The option will only appear when one of the parent_value_ids is selected.
Options.parent_value_ids
array of objectIdThe ids of parent option values that will make the option appear if selected.
Options.price
currencyExtra price for the option, added to the product's price/sale_price. If the option is part of a variant, the variant's price/sale_price will override this value.
Options.subscription
booleanSet true to indicate the option's values specify a subscription billing interval. In this case, option values must have a subscription_interval of monthly, yearly, weekly or daily.
Options.values
objectList of possible values for this option.
values.name
stringHuman-friendly name of the option value.
values.description
stringA brief description of the option value, intended for displaying to customers.
values.images
objectOne or more images depicting the option value.
images.caption
stringA brief description of the image, intended for display as a caption or alt text.
images.file
objectAn object representing the image's source file.
file.data
fileSet or overwrite file data. Use the following format when writing a file from binary data (for example an image): data[$binary]=<base64 encoded binary daya>.
file.filename
stringOptional file name.
values.price
currencyExtra price added to the product's price/sale_price if the option value is selected. Overrides option price.
values.shipment_weight
floatExtra weight added to the product's shipment_weight if the option value is selected. The unit should match the store's default as configured in general settings.
values.subscription_interval
stringWhen product type=subscription, this is the billing interval used when this option value is selected. Can be monthly, yearly, weekly or daily.
values.subscription_interval_count
intWhen product type=subscription, this number multiplies subscription_interval to determine the billing frequency when this option is selected. For example, to make a subscription bill every 2 weeks, set subscription_interval=weekly and subscription_interval_count=2.
values.subscription_trial_days
intWhen product type=subscription, refers to a number of days offered as a trial before an invoice is issued.
Options.variant
booleanSet true to generate variants including this option.
prices
objectSet price rules to use when conditions match the customer's account group or product quantity in a cart.
prices.price
currencySet price to apply when conditions are met.
prices.account_group
stringCustomer account group as a condition to apply price.
prices.quantity_max
intMaximum quantity as a condition to apply price.
prices.quantity_min
intMinimum quantity as a condition to apply price.
quantity_inc
intSpecifies a quantity multiple the product must be sold in.
quantity_min
intMinimum quantity of the product that can be sold at once.
sale
booleanSet true to mark the product "on sale" and to use sale_price when the product is added to a cart.
sale_price
currencySale price used to override list price when sale=true.
shipment_dimensions
objectProduct dimensions when packed for shipping. Typically used by 3rd party carriers in box packing algorithms to optimize shipping costs.
shipment_dimensions.height
floatHeight of the product in unit.
shipment_dimensions.length
floatLength of the product in unit.
shipment_dimensions.unit
stringEither in (inches) or cm (centimeters).
shipment_dimensions.width
floatWidth of the product in unit.
shipment_location
stringID of location from /settings/shipping/locations. If specified, shipping is calculated from this origin. Otherwise, the store default location will be used.
shipment_package_quantity
floatIf specified, shipping is calculated using this as the maximum number of items per package. Otherwise, Swell assumes any quantity fits into a single package.
shipment_prices
objectProduct shipping price rules to override default shipping rules.
shipment_prices.service
stringShipping service required for this rule to apply.
shipment_prices.account_group
stringCustomer group required for this rule to apply.
shipment_prices.country
stringShipping country required for this rule to apply.
shipment_prices.fee_amount
currencyFixed amount to add when rule is applied. Only applicable when fee_type=fixed.
shipment_prices.fee_percent
floatPercentage of the shipping price to add when rule is applied. Only applicable when fee_type=percent.
shipment_prices.fee_type
stringType of fee to apply in addition to price, either fixed or percent.
shipment_prices.package_quantity
intMaximum package quantity when rule is applied.
shipment_prices.price
currencyShipping price when rule is applied.
shipment_prices.state
stringShipping state required for this rule to apply.
shipment_prices.total_max
currencyMaximum order subtotal for this rule to apply.
shipment_prices.total_min
currencyMinimum order subtotal for this rule to apply.
shipment_prices.weight_max
floatMaximum order item weight for this rule to apply.
shipment_prices.weight_min
floatMinimum order item weight for this rule to apply.
shipment_prices.zip
stringShipping zip/postal code required for this rule to apply.
shipment_weight
floatIf specified, shipping is calculated using this weight. Otherwise, Swell assumes 1 lb/oz/kg — depending on store's default weight unit.
sku
stringStock keeping unit (SKU) used to track inventory in a warehouse.
stock_tracking
booleanSet true to enable stock tracking this product.
subscription_interval
stringThe default billing interval when this product is used as a subscription plan. Can be monthly, yearly, weekly or daily.
subscription_interval_count
intMultiplier when combined with subscription_interval. For example, to make a subscription bill every 2 weeks, set subscription_interval=weekly and subscription_interval_count=2.
subscription_trial_days
intNumber of days offered as a free trial before the customer is billed. If a subscription is canceled by the last day of the trial period, an invoice won't be issued.
tags
array of stringList of arbitrary tags typically used as metadata to improve search results or associate custom behavior with a product.
type
stringImplies the ordering and fulfillment options available for the product. Can be standard, subscription, bundle, or giftcard. A standard product is a physical item that will be shipped to a customer.
up_sells
objectList of products to display as up-sells on a product detail page.
up_sells.product_id
objectIdThe id of the up-sell product.
variable
booleanSet true to generate variants for this product in the admin panel.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.put('/products/{id}', {
id: '5c8fb5e1ed2faf8c79da492a',
price: 19.98,
// use $set to override values
$set: {
options: [
...
],
},
});
Response
{
"id": "5ca24abb9c077817e5fe2b36",
"active": true,
"attributes": {},
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"delivery": "shipment",
"description": null,
"images": [
{
"id": "5ca24abb9c077817e5fe2b37",
"file": {
"id": "5ca24abb9c077817e5fe2b38",
"date_uploaded": "2019-04-02T00:26:23.399Z",
"length": 66764,
"md5": "99194f53bfdea832553e7fa8ae8fd80f",
"content_type": "image/png",
"url": "http://cdn.swell.store/test/5ca24abb9c077817e5fe2b36/99194f53bfdea832553e7fa8ae8fd80f",
"width": 940,
"height": 600
}
}
],
"meta_description": null,
"meta_title": null,
"name": "T-Shirt",
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Size",
"variant": true,
"required": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "Small"
},
{
"id": "5ca24ad59c077817e5fe2ba4",
"name": "Medium"
},
{
"id": "5ca24ad59c077817e5fe2ba5",
"name": "Large"
}
]
}
],
"price": 9.99,
"slug": "swell-t-shirt",
"stock_level": 0,
"stock_status": "available",
"stock_tracking": true,
"tags": [],
"type": "standard"
}
Return a list of products.
Arguments
categories
objectIdSupports filtering a single by a single top-level category with id, or also supports an array of categories and their sub-categories. For an array, notate category IDs within brackets: categories: [ ...ids ].
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('/products', {
where: { active: true },
limit: 25,
page: 1,
});
Response
{
"count": 51,
"results": [
{
"id": "5ca24abb9c077817e5fe2b36",
"active": true,
"attributes": {},
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"delivery": "shipment",
"description": null,
"images": [],
"meta_description": null,
"meta_title": null,
"name": "T-Shirt",
"options": [],
"price": 9.99,
"slug": "swell-t-shirt",
"stock_level": 0,
"stock_status": "available",
"stock_tracking": true,
"tags": [],
"type": "standard"
},
{...},
{...}
],
"page": 1,
"pages": {
"1": {
"start": 1,
"end": 25
},
"2": {
"start": 26,
"end": 50
},
"2": {
"start": 51,
"end": 51
}
}
}
Deleting a product that has already been sold will break any links that exist within orders. We recommend only deleting products that have not yet been sold to a customer.
When deleting a record that has child collections such as variants and stock, the contents of those collections are also deleted.
Arguments
id
objectIdrequiredThe id of the product you wish to delete.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.delete('/products/{id}', {
id: '5c8fb5e1ed2faf8c79da492a',
});
Response
{
"id": "5ca24abb9c077817e5fe2b36",
"active": true,
"attributes": {},
"currency": "USD",
"date_created": "2019-04-01T00:00:00.000Z",
"date_updated": "2019-04-01T00:00:00.000Z",
"delivery": "shipment",
"description": null,
"images": [],
"meta_description": null,
"meta_title": null,
"name": "T-Shirt",
"options": [],
"price": 9.99,
"slug": "swell-t-shirt",
"stock_level": 0,
"stock_status": "available",
"stock_tracking": true,
"tags": [],
"type": "standard"
}