Backend API

Subscriptions allow charging a customer on a recurring basis. A subscription ties a customer to a particular subscription plan. 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.

Fields

idobjectId

Unique identifier for the subscription.

account_idobjectId

ID of the subscribed customer's account.

product_idobjectId

ID of the subscription plan product.

accountAccount

Expandable link to the subscribed customer's account.

activeboolean

Indicates the subscription is currently active.

cancel_at_endboolean

When true, indicates the subscription was or will be canceled at the end of the billing period.

cancel_reasonstring

A brief message describing the reason the subscription was canceled, if applicable.

canceledboolean

Indicates the subscription was canceled.

coupon_codestring

Coupon code applied to the subscription. See coupons for details.

coupon_idobjectId

ID of the coupon applied to the subscription.

couponCoupon

Expandable link to the coupon applied to the subscription.

currencystring

Three-letter ISO currency code in uppercase. Defaults to the store's base currency.

date_canceleddate

Date the subscription was canceled, if applicable.

date_createddateauto

Date and time the subscription was created.

date_payment_expiringdateauto

Date when the customer's current default credit card will expire, used to notify the customer to update their payment information before their card expires.

date_payment_faileddate

Date when the last automated payment failed, if applicable.

date_payment_retrydateauto

When automated payment has failed, this is the date when the system will automatically retry.

date_period_enddateauto

End date of the current billing period.

date_prorateddate

Date the subscription was last prorated, if applicable. Used to calculate the charge or credit applied when the subscription is prorated.

date_trial_startdate

Date the trial period started, if applicable.

date_trial_enddate

Date the trial period did end in the past or will end in the future. Changing this value can be used to update the billing period of a subscription with or without a trial. For example, to set the monthly billing date to the 1st of the month, update date_trial_end to the first of the next month.

date_period_startdate

Start date of the current billing period.

date_updateddateauto

Date and time the subscription was last updated.

discount_totalcurrency

Total discount amount.

discountsarray of object

List of all discounts applied to the subscription.

grand_totalcurrency

Grand total of the next invoice including line items and taxes.

intervalenum

Billing interval. Can be monthly, daily, weekly, or yearly.

interval_countint

Multiplier for billing interval. For example, to make the subscription charge once every two weeks, set interval=weekly and interval_count=2.

invoice_totalcurrency

Amount invoiced for the last billing period.

invoicesInvoice

Expandable list of all invoices created by the subscription.

item_discountcurrencyauto

Total discount applied to line items.

item_totalcurrencyauto

Amount invoiced for the last billing period.

itemsarray of object

List of invoice line items added to the subscription. Recurring items are charged repeatedly, otherwise they are charged on the next invoice and then removed from the subscription.

item_taxcurrency

Total taxes applied to line items.

notesstring

Internal admin notes. These are not visible to the customer.

optionsarray of object

Plan options matching one or more of product.options. When setting this value, specify either option id or name (case-insensitive) to identify the option.

order_idobjectId

ID of the order that originated the subscription, if applicable.

order_item_idobjectId

ID of the line item from the order that originated the subscription, if applicable.

ordersOrder

Expandable list of all orders created by the subscription plan. This happens when a plan contains physical products as bundle_items.

paidbooleanauto

Indicates the last invoice was fully paid.

payment_balancecurrencyauto

Balance of payments on the invoice for the last billing period. A negative number indicates payment is owed, while a positive balance indicates refund is due. Zero balance indicates the invoice was fully paid.

payment_totalcurrency

Total amount of payments for the last billing period.

paymentsPayment

Expandable list of all payments made on behalf of the subscription.

pending_invoicesInvoice

Expandable list of invoices that haven't been fully paid.

pricecurrency

Price of the plan. Plan price can be overridden when creating or updating a subscription.

price_totalcurrencyauto

Total price of the plan (price * quantity).

productProduct

Expandable link to the subscription plan product.

product_discount_eachcurrencyauto

Total discount amount of the subscription plan, divided by quantity.

product_discount_totalcurrencyauto

Total discount applied to the subscription plan.

product_discountsarray of object

List of discounts applied to the subscription plan by coupons.

product_tax_eachcurrencyauto

Total tax amount of the subscription plan, divided by quantity.

product_tax_totalcurrencyauto

Total tax applied to the subscription plan.

product_taxesarray of objectauto

List of tax rules applied to the subscription plan based on tax settings.

proratedboolean

When false, indicates the subscription should not be prorated if the plan product is changed, otherwise a prorated charge or credit will be added at the appropriate time.

quantityint

Quantity of the plan to charge.

recurring_discount_totalcurrencyauto

Total recurring discount applied to the subscription including line items.

recurring_item_discountcurrencyauto

Total discount applied to recurring line items.

recurring_item_taxcurrencyauto

Total taxes applied to recurring line items.

recurring_item_totalcurrencyauto

Sum of all recurring line items before discounts and taxes.

recurring_tax_included_totalcurrencyauto

Total of taxes applied separately from the subscription plan and recurring line items.

recurring_tax_totalcurrencyauto

Total taxes applied to the subscription including recurring line items.

recurring_totalcurrencyauto

Recurring total of the subscription including line items and taxes.

refund_totalcurrency

Total amount of refunds for the last billing period.

refundsRefund

Expandable list of all refunds made on behalf of the subscription.

statusenumauto

Current status of the subscription. Can be pending, active, trial, pastdue, unpaid, canceled, or paid.

sub_totalcurrencyauto

Sum of all line items before discounts and taxes.

tax_includedbooleanauto

Indicates the subscription plan price includes taxes.

tax_included_totalcurrencyauto

Total of taxes applied separately from the subscription plan and line items.

tax_totalcurrencyauto

Total taxes applied to the subscription including line items.

taxesarray of objectauto

List of taxes applied to the subscription.

trialbooleanauto

Indicates the subscription is in a trial period and the first invoice will be issued on date_trial_end.

trial_daysint

Number of days the subscription trial period was for. An invoice will not be issued until trial has elapsed.

unpaidbooleanauto

Indicates the last invoice was marked as unpaid. This occurs automatically after all payment attempts are exhausted, as configured in subscription settings.

variant_idobjectId

ID of the subscription plan variant, if applicable.

variantProduct variant

Expandable link to the subscription plan variant, if applicable.

billingobject

Subscription billing details.

taxes_fixedboolean

When true, taxes are not applied to the subscription. When false, taxes are calculated and applied to the subscription.

currency_ratefloat

Currency rate used in calculating the fixed amount.

billing_scheduleobject

Billing schedule for subscription plan.

order_scheduleobject

Order schedule for the subscription plan.

orderingboolean

Indicates the subscription is actively placing orders.

completeboolean

Indicates the subscription plan has completed all cycles.

plan_idobjectId

ID of the subscription plan.

plan_namestring

Name of the subscription plan.

product_namestring

This field is a copy of the item's product.name.

The subscription model
{
  "id": "60f199509111e7000000009a",
  "account_id": "60f199509111e700000000a0",
  "product_id": "60f199509111e700000000a1",
  "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 Skooma 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": "Skooma delivery",
      "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"
}

Subscribe a customer to a plan. 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

account_idobjectIdrequired

ID of the subscribed customer's account.

product_idobjectIdrequired

ID of the subscription plan product. When changing the subscription product, the difference in price is prorated by adding a line item. The customer will be charged or credited the difference on their next invoice.

coupon_codestring

Coupon code applied to the subscription. See coupons for details.

quantityint

Quantity of the plan to charge.

trial_daysint

Number of days the subscription trial period was for. An invoice will not be issued until trial has elapsed.

POST/subscriptions
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.post('/subscriptions', {
  account_id: '60f199509111e700000000a4',
  product_id: '60f199509111e700000000a5',
  quantity: 1,
  trial_days: 14
});
Response
{
  "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 using the ID that was returned when created.

Arguments

idobjectIdrequired

The id of the subscription to retrieve.

expandstring

Expanding 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.

fieldsstring

Return 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.

includestring

Include one or more arbitrary queries in the response, possibly related to the main query.

See including for more details.

GET/subscriptions/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/subscriptions/{id}', {
  id: '60f199509111e700000000ac'
});
Response
{
  "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 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

cancel_at_endboolean

When `true`, indicates the subscription was or will be canceled at the end of the billing period.

canceledboolean

Indicates the subscription was canceled.

coupon_codestring

Coupon code applied to the subscription. See coupons for details.

date_trial_enddate

Date the trial period did end in the past, or will end in the future. Changing this value can be used to update the billing period of a subscription with or without a trial. For example, to set the monthly billing date to the 1st of the month, update `date_trial_end` to the first of the next month.

product_idobjectIdrequired

ID of the subscription plan product. When changing the subscription product, the difference in price is prorated by adding a line item. The customer will be charged or credited the difference on their next invoice.

cancel_reasonstring

A brief message describing the reason the subscription was canceled, if applicable.

PUT/subscriptions/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.put('/subscriptions/{id}', {
  id: '60f199509111e7000000009a'
});
Response
{
  "id": "60f199509111e7000000009a",
  "account_id": "60f199509111e700000000b7",
  "product_id": "60f199509111e700000000b8",
  "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"
}

Return a list of subscriptions.

Fields

expandstring

Expand 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.

fieldsstring

Returns 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.
includeobject

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limitint

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

pageint

The page number of results to return given the specified or default limit.

searchstring

A 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.

sortstring

Expression 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.

whereobject

An 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.

GET/subscriptions
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/subscriptions', {
  limit: 25,
  page: 1
});
Response
{
  "count": 51,
  "results": [
    {
      "id": "60f199509111e7000000009a",
      "account_id": "60f199509111e700000000bf",
      "product_id": "60f199509111e700000000c0",
      "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"
    },
    {...},
    {...}
  ],
  "page": 1,
  "pages": {
    "1": {
      "start": 1,
      "end": 25
    },
    "2": {
      "start": 26,
      "end": 50
    },
    "2": {
      "start": 51,
      "end": 51
    }
  }
}

Delete a subscription permanently.

Arguments

idobjectIdrequired

The id of the subscription to delete.

DELETE/subscriptions/:id
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.delete('/subscriptions/{id}', {
  id: '60f199509111e700000000c2'
});
Response
{
  "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"
}