Filter
Results
Backend API
Subscription plans are products with type=subscription. When creating a plan, consider whether it's needed to ship physical items or not.
Create a subscription plan without physical items.
Arguments
name
stringrequiredHuman-friendly name of the product.
options
objectrequiredSpecify the billing options available on the plan.
options.name
stringrequiredName of the billing option.
options.subscriptions
booleanrequiredMust be true for subscription options.
options.values
objectrequiredList of possible values for this option.
values.name
stringrequiredHuman-friendly name of the option value.
values.price
currencyrequiredPrice used when the option is selected.
values.subscription_interval
enumrequiredSet the billing interval used when this option is selected. Can be monthly, yearly, weekly, or daily.
values.subscription_interval_count
intThis 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. Defaults to 1.
values.subscription_trial_days
intA number of days offered as a trial before an invoice is issued.
options.variant
booleanrequiredMust be true for subscription options.
type
stringrequiredSet to subscription to indicate the product is a subscription plan.
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
category_id
objectIdPrimary category, commonly used as a navigation anchor.
description
stringA long-form description of the product. Can contain HTML or other markup languages.
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
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 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.
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.
tags
stringList of arbitrary tags typically used as metadata to improve search results or associate custom behavior with a product.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/products', {
name: 'Pro plan',
type: 'subscription',
options: [
{
name: 'Plan',
variant: true,
subscription: true,
values: [
{
name: 'Monthly',
subscription_interval: 'monthly',
price: 99,
},
{
name: 'Yearly',
subscription_interval: 'yearly',
price: 999,
},
],
},
],
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"delivery": "subscription"
"name": "Pro plan",
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Plan",
"variant": true,
"subscription": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "Monthly",
"subscription_interval": "monthly",
"price": 99
},
{
"id": "5ca24ad59c077817e5fe2ba4",
"name": "Yearly",
"subscription_interval": "yearly",
"price": 999
}
]
}
],
"slug": "pro-plan",
"type": "subscription"
}
In order to support shipping physical goods, create standard products with all the details needed for shipment, then create a subscription plan (product) and set the bundle_items with the products you want to have shipped when the subscription is charged.
Arguments
bundle
booleanrequiredSet true to indicate the plan has physical items.
bundle_items
array of objectSpecify the items to be fulfilled when the plan is charged.
.product_id
objectIdID of the bundled product.
.quantity
intQuantity of the bundled product. Defaults to 1.
.variant_id
objectIdID of the bundled variant, if applicable.
name
stringrequiredHuman-friendly name of the product.
options
objectrequiredSpecify the billing options available on the plan.
options.name
stringrequiredName of the billing option.
options.subscriptions
booleanrequiredMust be true for subscription options.
options.values
objectrequiredList of possible values for this option.
values.name
stringrequiredHuman-friendly name of the option value.
values.price
currencyrequiredPrice used when the option is selected.
values.subscription_interval
enumrequiredSet the billing interval used when this option is selected. Can be monthly, yearly, weekly, or daily.
values.subscription_interval_count
intThis 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. Defaults to 1.
values.subscription_trial_days
intA number of days offered as a trial before an invoice is issued.
options.variant
booleanrequiredMust be true for subscription options.
type
stringrequiredSet to subscription to indicate the product is a subscription plan.
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
category_id
objectIdPrimary category, commonly used as a navigation anchor.
description
stringA long-form description of the product. Can contain HTML or other markup languages.
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
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 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.
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.
tags
stringList of arbitrary tags typically used as metadata to improve search results or associate custom behavior with a product.
const swell = require('swell-node').init('store-id', 'secret-key');
await swell.post('/products', {
name: 'Coffee club',
type: 'subscription',
bundle_items: [
{
product_id: '5ca24abb9c077817e5fe2b36',
quantity: 1
}
],
options: [
{
name: 'Plan',
variant: true,
subscription: true,
values: [
{
name: 'Weekly',
subscription_interval: 'weekly',
price: 15,
},
{
name: 'Monthly',
subscription_interval: 'monthly',
price: 19,
},
],
},
],
});
Response
{
"id": "5cad15bc9b14d1990724663a",
"delivery": "subscription"
"name": "Coffee club",
"bundle_items": [
{
"product_id": "5ca24abb9c077817e5fe2b36",
"quantity": 1
}
],
"options": [
{
"id": "5ca24ab32599d4179c24a624",
"name": "Plan",
"variant": true,
"subscription": true,
"values": [
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "Weekly",
"subscription_interval": "weekly",
"price": 15
},
{
"id": "5ca24ad59c077817e5fe2ba3",
"name": "Monthly",
"subscription_interval": "monthly",
"price": 19
}
]
}
],
"slug": "coffee-club",
"type": "subscription"
}