Backend API
Subscriptions allow charging a customer on a recurring basis. A subscription is a product with a subscription purchase_option defined. In addition to the plan, subscriptions can have line items that are charged on a recurring basis or just once—depending on the use case. Orders can be automatically generated every time a subscription is charged by subscribing to a plan with bundle_items.
A subscription product is achieved by creating a product with a defined subscription purchase option.
Fields
id
objectIdUnique identifier for the product.
name
stringrequiredHuman-friendly name of the product.
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.
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.
active
booleanIndicates whether the product is active and available in the storefront.
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.
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
{
"purchase_options": {
"standard": {
"active": true,
"price": 75,
"sale": true,
"sale_price": 60,
"prices": [
{
"account_group": "vip",
"price": 65,
"quantity_max": null,
"quantity_min": null,
"$locale": {
"en-US": {
"description": ""
},
"ja": {
"description": ""
}
}
}
]
},
"subscription": {
"active": true,
"plans": [
{
"name": "Monthly",
"description": null,
"price": 75,
"billing_schedule": {
"interval": "monthly",
"interval_count": 1,
"limit": null,
"trial_days": 1
},
"id": "62b1e30767145000197b2bc0",
"active": true,
"$locale": {
"en-US": {
"description": null,
"name": "Monthly"
},
"ja": {
"description": ""
}
}
}
]
}
},
"name": "Skooma",
"sku": "0004E0A9",
"active": true,
"images": [
{
"file": {
"id": "62b1e2b34bf1a70019cbf610",
"date_uploaded": "2022-06-21T15:24:35.166Z",
"length": 7024,
"md5": "4b39c328dc2652792c048d0fd3f8a426",
"filename": null,
"content_type": "image/png",
"metadata": null,
"url": "https://cdn.schema.io/launch-storefront/62b1e2b34bf1a70019cbf610/4b39c328dc2652792c048d0fd3f8a426",
"width": 64,
"height": 64
},
"id": "62b1e30767145000197b2bc1",
"$locale": {
"en-US": {
"file": {
"id": "62b1e2b34bf1a70019cbf610",
"date_uploaded": "2022-06-21T15:24:35.166Z",
"length": 7024,
"md5": "4b39c328dc2652792c048d0fd3f8a426",
"filename": null,
"content_type": "image/png",
"metadata": null,
"url": "https://cdn.schema.io/launch-storefront/62b1e2b34bf1a70019cbf610/4b39c328dc2652792c048d0fd3f8a426",
"width": 64,
"height": 64
}
}
}
}
],
"cost": 60,
"variable": false,
"description": "Damage Intelligence 2 pts<br>Drain Agility 60 pts for 20 secs<br>Fortify Speed and Strength 60 pts for 20 secs",
"tags": [],
"meta_title": null,
"meta_description": "Several skooma dealers can be found in and around Cyrodiil, usually in hidden and out of sight spots, such as Shady Sam and Nordinor. A skooma den can also be found right above Carandial's house in Bravil. There is also a skooma smuggling ring led by Dulfish gro-Orum that can be uncovered in Cheydinhal through investigation by the player.",
"slug": "skooma",
"attributes": {
"rooms": [
"Kitchen"
],
"room_usage": [
"Kitchen",
"Dining room",
"Bedroom",
"Bathroom",
"Ballroom"
]
},
"delivery": "shipment",
"bundle": null,
"price": 75,
"stock_tracking": false,
"options": [],
"currency": "USD",
"type": "standard",
"tax_class": "standard",
"date_created": "2022-06-21T15:25:59.518Z",
"stock_status": null,
"category_index": {
"sort": {
"628bb55d499bba0019b1ab91": 0
},
"id": [
"628bb55d499bba0019b1ab91"
]
},
"date_updated": "2023-07-22T15:27:54.751Z",
"popularity": 41,
"prices": [
{
"account_group": "vip",
"price": 65,
"quantity_max": null,
"quantity_min": null,
"$locale": {
"en-US": {
"description": ""
},
"ja": {
"description": ""
}
}
}
],
"sale": true,
"sale_price": 60,
"stock_level": -1,
"engraving": "To my dearest Caedmon, you shall always be the greatest blacksmith",
"magic_level": 660,
"your_engraving": "To my dearest Caedmon, you shall always be the greatest blacksmith",
"content": {
"your_engraving": "To my dearest Caedmon, you shall always be the greatest blacksmith",
"enchanted": "nope"
},
"cuztomization": {
"engraving": true,
"engraving_text": "Get stuffed Mariel"
},
"cross_sells": [
{
"id": "63628888adb6305fff690058",
"product_id": "628ba4811869c10019b41f62",
"discount_type": "fixed",
"discount_amount": null
}
],
"up_sells": [
{
"id": "63628882adb6305fff690057",
"product_id": "628ba701499bba0019b1a9bb"
}
],
"things": [
{
"date": "2023-04-13T17:00:00.000Z",
"log": "Something happened",
"id": "6437102e171326001374f584"
}
],
"id": "62b1e30767145000197b2bbf",
"$locale": {
"en-US": {
"name": "Skooma",
"description": "Damage Intelligence 2 pts<br>Drain Agility 60 pts for 20 secs<br>Fortify Speed and Strength 60 pts for 20 secs",
"tags": [],
"meta_title": null,
"meta_description": "Several skooma dealers can be found in and around Cyrodiil, usually in hidden and out of sight spots, such as Shady Sam and Nordinor. A skooma den can also be found right above Carandial's house in Bravil. There is also a skooma smuggling ring led by Dulfish gro-Orum that can be uncovered in Cheydinhal through investigation by the player."
}
}
}
When creating a product, utilizing the subscription purchase option will allow a customer to buy that product on a recurring subscription.
A recurring subscription order will be created when a customer purchases a product's subscription pricing option. When trial_days or date_trial_end are set, no invoices will be created, otherwise, the customer's default billing card will be charged immediately. If the charge fails, this will return a validation error describing the failure and an invoice will not be created. If the charge succeeds, an invoice will be created and paid by the charge immediately.
Arguments
name
stringrequiredHuman-friendly name of the product.
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.
attributes
objectAn object containing custom attribute key/value pairs. See attributes for more details.
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.
description
stringA long form description of the product. May have HTML or other markup.
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.
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:
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.
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.
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 request = require('request');
const url = 'https://api.swell.store/products';
const data = {
name: 'Skooma',
purchase_options: {
subscription: {
active: true,
plans: [{
name: 'Monthly',
description: null,
price: 75,
billing_schedule: {
interval: 'monthly',
interval_count: 1,
limit: null,
trial_days: 1
}
}]
}
}
};
The product model
{
"id": "60f199509111e7000000009a",
"account_id": "60f199509111e700000000a9",
"product_id": "60f199509111e700000000aa",
"active": true,
"cancel_at_end": false,
"cancel_reason": null,
"canceled": false,
"currency": "USD",
"date_canceled": null,
"date_created": "2021-07-16T14:36:00.483Z",
"date_payment_expiring": "2031-01-01T08:00:00.000Z",
"date_payment_failed": null,
"date_payment_retry": null,
"date_period_end": "2019-03-24T04:28:12.962Z",
"date_period_start": "2019-02-24T04:28:12.962Z",
"date_trial_end": "2019-02-24T04:28:12.962Z",
"date_trial_start": "2019-01-24T04:28:12.962Z",
"date_updated": "2021-07-16T14:36:00.483Z",
"discount_total": 0,
"discounts": null,
"grand_total": 148.8946,
"interval": "monthly",
"interval_count": 1,
"invoice_total": 99,
"item_discount": 0,
"item_tax": 0,
"item_total": 49.8946,
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"date_created": "2019-03-24T22:56:33.467Z",
"description": "Remaining time on Example Subscription",
"proration": true,
"quantity": 1,
"price": 49.8946,
"price_total": 49.8946,
"recurring_price": 0,
"recurring_price_total": 0,
"discount_total": 0,
"discount_each": 0,
"recurring_discount_total": 0,
"recurring_discount_each": 0,
"tax_total": 0,
"tax_each": 0,
"recurring_tax_total": 0,
"recurring_tax_each": 0
}
],
"notes": null,
"options": [
{
"id": "5becb84fac207653a4816ee5",
"name": "Plan",
"value": "Monthly"
}
],
"order_id": "60f199509111e7000000009d",
"order_item_id": "60f199509111e7000000009e",
"paid": true,
"payment_balance": 0,
"payment_total": 99,
"price": 99,
"price_total": 99,
"product_discount_each": 0,
"product_discount_total": 0,
"product_discounts": null,
"product_tax_each": 0,
"product_tax_total": 0,
"product_taxes": null,
"quantity": 1,
"recurring_discount_total": 0,
"recurring_item_discount": 0,
"recurring_item_tax": 0,
"recurring_item_total": 0,
"recurring_tax_included_total": 0,
"recurring_tax_total": 0,
"recurring_total": 99,
"refund_total": 0,
"status": "active",
"sub_total": 148.8946,
"tax_included_total": 0,
"tax_total": 0,
"taxes": null,
"trial": false,
"trial_days": 14,
"unpaid": false,
"variant_id": "60f199509111e7000000009f"
}
Retrieve an existing subscription 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}');
The product model
{
"id": "60f199509111e700000000b1",
"account_id": "60f199509111e700000000b2",
"product_id": "60f199509111e700000000b3",
"active": true,
"cancel_at_end": false,
"cancel_reason": null,
"canceled": false,
"currency": "USD",
"date_canceled": null,
"date_created": "2021-07-16T14:36:00.483Z",
"date_payment_expiring": "2031-01-01T08:00:00.000Z",
"date_payment_failed": null,
"date_payment_retry": null,
"date_period_end": "2019-03-24T04:28:12.962Z",
"date_period_start": "2019-02-24T04:28:12.962Z",
"date_trial_end": "2019-02-24T04:28:12.962Z",
"date_trial_start": "2019-01-24T04:28:12.962Z",
"date_updated": "2021-07-16T14:36:00.483Z",
"discount_total": 0,
"discounts": null,
"grand_total": 148.8946,
"interval": "monthly",
"interval_count": 1,
"invoice_total": 99,
"item_discount": 0,
"item_tax": 0,
"item_total": 49.8946,
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"date_created": "2019-03-24T22:56:33.467Z",
"description": "Remaining time on Example Subscription",
"proration": true,
"quantity": 1,
"price": 49.8946,
"price_total": 49.8946,
"recurring_price": 0,
"recurring_price_total": 0,
"discount_total": 0,
"discount_each": 0,
"recurring_discount_total": 0,
"recurring_discount_each": 0,
"tax_total": 0,
"tax_each": 0,
"recurring_tax_total": 0,
"recurring_tax_each": 0
}
],
"notes": null,
"options": [
{
"id": "5becb84fac207653a4816ee5",
"name": "Plan",
"value": "Monthly"
}
],
"order_id": "60f199509111e7000000009d",
"order_item_id": "60f199509111e7000000009e",
"paid": true,
"payment_balance": 0,
"payment_total": 99,
"price": 99,
"price_total": 99,
"product_discount_each": 0,
"product_discount_total": 0,
"product_discounts": null,
"product_tax_each": 0,
"product_tax_total": 0,
"product_taxes": null,
"quantity": 1,
"recurring_discount_total": 0,
"recurring_item_discount": 0,
"recurring_item_tax": 0,
"recurring_item_total": 0,
"recurring_tax_included_total": 0,
"recurring_tax_total": 0,
"recurring_total": 99,
"refund_total": 0,
"status": "active",
"sub_total": 148.8946,
"tax_included_total": 0,
"tax_total": 0,
"taxes": null,
"trial": false,
"trial_days": 14,
"unpaid": false,
"variant_id": "60f199509111e7000000009f"
}
Update an existing subscription 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
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
objectIdrequiredID of the purchase option.
standard.name
stringrequiredThe name of the purchase option.
standard.account_groups
array of child_scalarArray of account groups that are eligible to access the purchase option within the storefront.
standard.active
booleanIndicates whether the purchase option is available for customers to purchase. Inactive products will not be returned on the Frontend.
standard.description
stringA long-form description of the product. May contain HTML or other markup languages.
standard.orig_price
currencyReflects the non-sale price of the product
standard.price
currencyList price used when sale=false or sale_price is not defined.
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.
discount_percent
floatstandard.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.
purchase_options.subscription
objectDesignates purchase option for a subscription plan.
subscription.id
objectIdrequiredautoID 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 child_scalarArray of account_group names for which the purchase option is available.
subscription.plans
array of objectArray defining subscription plans and their respective configurations.
id
objectIdautoID 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
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
intorder_schedule
objectorder_schedule.interval
enumPossible enum values:
order_schedule.interval_count
intorder_schedule.limit
intpurchase_options.trial
objecttrial.id
objectIdrequiredtrial.active
booleantrial.price
currencytrial.auth_amount
currencytrial.trial_days
inttrial.prices
array of objectprice
currencyrequiredauth_amount
currencytrial_days
intrequiredaccount_group
stringrequireddescription
stringA long-form description of the product. May contain HTML or other markup languages.
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.
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. 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.
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.
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 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.
discount_percent
floatThe discount percent, if applicable.
stock
array of StockExpandable list of stock adjustments for the product.
stock_level
intQuantity of the product currently in stock (including all variants), based on the sum of the stock entries.
tags
array of child_scalarArray of searchable tags to aid in search discoverability.
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.
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.
name
stringrequiredHuman-friendly name of the product.
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
ProductExpandable link to all related product categories.
category_index
objectIndex of categories used for fast lookup operations.
category_index.id
array of child_scalarrequiredList of related product category IDs.
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) 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.
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:
discontinued
booleanIndicates whether the product has been discontinued.
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.
orig_price
currencyReflects the non-sale price of the product
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
objectProduct dimensions when packed for shipping. Typically used by third-party carriers in box packing algorithms to optimize shipping costs.
shipment_dimensions.length
floatLength of the product in unit.
shipment_dimensions.width
floatWidth of the product in unit.
shipment_dimensions.height
floatHeight of the product in unit.
shipment_dimensions.unit
enumEither 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
stringStock keeping unit (SKU) used to track inventory in a warehouse.
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.
stock_backorder
booleanIndicates whether the product can be backordered if out of stock.
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.
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.
variable
booleanIndicates whether the product has variant generation enabled.
virtual
booleanIndicates whether the product is virtual.
const request = require('request');
const url = 'https://api.swell.store/products/{id}';
const data = {
purchase_options: {
subscription: {
active: true,
plans: [{
name: encodeURIComponent('Weekly'),
price: 105,
billing_schedule: {
interval: encodeURIComponent('weekly'),
trial_days: 0
}
}]
}
}
};
const encodedData = JSON.stringify(data);
request({
url,
method: 'POST',
body: encodedData
});
The product model
{
"name": "Skooma",
"purchase_options": {
"subscription": {
"active": true,
"plans": [
{
"name": "Weekly",
"description": null,
"price": 105,
"billing_schedule": {
"interval": "weekly",
"interval_count": 1,
"limit": null,
"trial_days": 0
},
"id": "64e799c1307e48001237eef5",
"active": true,
"$locale": {
"en-US": {
"name": "Monthly",
"description": null
}
}
}
]
}
},
"currency": "USD",
"slug": "skooooma",
"price": 75,
"type": "standard",
"delivery": "shipment",
"tax_class": "standard",
"date_created": "2023-08-24T17:56:17.162Z",
"active": false,
"stock_status": null,
"id": "64e799c1307e48001237eef4",
"$locale": {
"en-US": {
"name": "Skooma"
}
}
}
Return a list of subscriptions products.
Fields
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', {
limit: 25,
page: 1,
headers: {
'filter': JSON.stringify({
'key': 'subscription',
'value': 'true'
})
}
});
Response
{
"count": 15,
"page_count": 1,
"page": 1,
"results": [
{
"name": "Skooma",
"purchase_options": {
"subscription": {
"active": true,
"plans": [
{
"name": "Monthly",
"description": null,
"price": 75,
"billing_schedule": {
"interval": "monthly",
"interval_count": 1,
"limit": null,
"trial_days": 1
},
"id": "64e799c1307e48001237eef5",
"active": true,
"$locale": {
"en-US": {
"name": "Monthly",
"description": null
}
}
}
]
}
},
"currency": "USD",
"slug": "skooma",
"price": 75,
"type": "standard",
"delivery": "shipment",
"tax_class": "standard",
"date_created": "2023-08-24T17:56:17.162Z",
"active": false,
"stock_status": null,
"id": "64e799c1307e48001237eef4"
}
]
}
. . .
Delete a subscription product permanently. The method outlined removes the entire product. Alternatively, you can also remove the subscription purchase_option, should you wish to retain the product and any other associated purchase options.
This is not recommended if there are currently active subscription plans that reference this product. Update the subscription plans prior to deleting the subscription product.
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}', {
});
The subscription model
{
"id": "60f199509111e700000000c7",
"account_id": "60f199509111e700000000c8",
"product_id": "60f199509111e700000000c9",
"active": true,
"cancel_at_end": false,
"cancel_reason": null,
"canceled": false,
"currency": "USD",
"date_canceled": null,
"date_created": "2021-07-16T14:36:00.483Z",
"date_payment_expiring": "2031-01-01T08:00:00.000Z",
"date_payment_failed": null,
"date_payment_retry": null,
"date_period_end": "2019-03-24T04:28:12.962Z",
"date_period_start": "2019-02-24T04:28:12.962Z",
"date_trial_end": "2019-02-24T04:28:12.962Z",
"date_trial_start": "2019-01-24T04:28:12.962Z",
"date_updated": "2021-07-16T14:36:00.483Z",
"discount_total": 0,
"discounts": null,
"grand_total": 148.8946,
"interval": "monthly",
"interval_count": 1,
"invoice_total": 99,
"item_discount": 0,
"item_tax": 0,
"item_total": 49.8946,
"items": [
{
"id": "5ca537326a0ec32a521139dd",
"date_created": "2019-03-24T22:56:33.467Z",
"description": "Remaining time on Example Subscription",
"proration": true,
"quantity": 1,
"price": 49.8946,
"price_total": 49.8946,
"recurring_price": 0,
"recurring_price_total": 0,
"discount_total": 0,
"discount_each": 0,
"recurring_discount_total": 0,
"recurring_discount_each": 0,
"tax_total": 0,
"tax_each": 0,
"recurring_tax_total": 0,
"recurring_tax_each": 0
}
],
"notes": null,
"options": [
{
"id": "5becb84fac207653a4816ee5",
"name": "Plan",
"value": "Monthly"
}
],
"order_id": "60f199509111e7000000009d",
"order_item_id": "60f199509111e7000000009e",
"paid": true,
"payment_balance": 0,
"payment_total": 99,
"price": 99,
"price_total": 99,
"product_discount_each": 0,
"product_discount_total": 0,
"product_discounts": null,
"product_tax_each": 0,
"product_tax_total": 0,
"product_taxes": null,
"quantity": 1,
"recurring_discount_total": 0,
"recurring_item_discount": 0,
"recurring_item_tax": 0,
"recurring_item_total": 0,
"recurring_tax_included_total": 0,
"recurring_tax_total": 0,
"recurring_total": 99,
"refund_total": 0,
"status": "active",
"sub_total": 148.8946,
"tax_included_total": 0,
"tax_total": 0,
"taxes": null,
"trial": false,
"trial_days": 14,
"unpaid": false,
"variant_id": "60f199509111e7000000009f"
}