Docs

The Subscription object

Subscriptions allow you to charge a customer on a recurring basis in USDC.

Attributes

id string

Unique identifier for the object. Zoneless subscription IDs are prefixed with sub_z_.

customer string Expandable This can be expanded into an object with the expand request parameter.

ID of the customer who owns the subscription.

status enum

For collection_method=charge_automatically, a subscription moves into incomplete if the initial USDC wallet payment fails. Once the first invoice is paid, the subscription becomes active. If the first invoice isn't paid within 23 hours, the subscription transitions to incomplete_expired. A subscription in a trial period is trialing and moves to active when the trial ends. A subscription can only enter paused when a trial ends without a payment method. If collection is automatic, the subscription becomes past_due when payment is required but the customer's wallet payment can't be completed; after retries are exhausted it becomes canceled or unpaid depending on your settings.

Possible enum values
incompleteInitial payment hasn't succeeded yet.
incomplete_expiredInitial invoice wasn't paid within 23 hours. Terminal status.
trialingCurrently in a trial period.
activeIn good standing and generating invoices.
past_duePayment is required but hasn't succeeded yet.
canceledCanceled and no longer generating invoices.
unpaidPayment retries exhausted; invoices may remain open.
pausedTrial ended without a payment method; no invoices are generated until resumed.
items object

List of subscription items, each with an attached price.

latest_invoicenullable string Expandable This can be expanded into an object with the expand request parameter.

The most recent invoice this subscription has generated over its lifecycle (for example, when it cycles or is updated).

currency enum

Three-letter ISO currency code, in lowercase. Always usdc for Zoneless.

Difference from Stripe: Uses usdc instead of fiat currency codes like usd.

Possible enum values
usdc
collection_method enum

Either charge_automatically or send_invoice. When charging automatically, Zoneless attempts to pay this subscription at the end of the cycle using the customer's default payment method (typically a crypto wallet). When sending an invoice, Zoneless emails your customer an invoice with payment instructions and marks the subscription as active.

Possible enum values
charge_automatically
send_invoice
cancel_at_period_end boolean

Whether this subscription will (if status=active) or did (if status=canceled) cancel at the end of the current billing period.

billing_cycle_anchor timestamp

The reference point that aligns future billing cycle dates. It sets the day of week for week intervals, the day of month for month and year intervals, and the month of year for year intervals. The timestamp is in UTC format.

default_payment_methodnullable string Expandable This can be expanded into an object with the expand request parameter.

ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source.

trial_endnullable timestamp

If the subscription has a trial, the end of that trial.

trial_startnullable timestamp

If the subscription has a trial, the beginning of that trial.

metadata object

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

descriptionnullable string

The subscription's description, meant to be displayable to the customer. Maximum length is 500 characters.

More attributes

THE SUBSCRIPTION OBJECT
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": null
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": null,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {},
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}

Create a subscription

Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions. When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request. The payment_behavior parameter controls what happens if that initial payment fails.

ENDPOINTS
POST /v1/subscriptions

Parameters

items array of objects Required

A list of up to 20 subscription items, each with an attached price.

customer string Required unless customer_account is provided

The ID of the customer to subscribe.

customer_account string Required unless customer is provided

The ID of the account representing the customer to subscribe.

collection_method enum

Either charge_automatically, or send_invoice. When charging automatically, Zoneless attempts to pay this subscription at the end of the cycle using the default payment method attached to the customer. When sending an invoice, Zoneless emails your customer an invoice with payment instructions and marks the subscription as active. Defaults to charge_automatically.

Possible enum values
charge_automatically
send_invoice
default_payment_method string

ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source.

description string

The subscription's description, meant to be displayable to the customer. Maximum length is 500 characters.

metadata object

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

payment_behavior enum

Only applies when collection_method is charge_automatically. Controls how to handle the initial payment when creating the subscription.

Possible enum values
allow_incompleteUse default_incomplete behavior for SCA, otherwise create the subscription in incomplete status if the first payment fails.
default_incompleteCreate the subscription in incomplete status if the first payment requires action or fails. Return the latest invoice's payment intent for confirmation.
error_if_incompleteReturn an HTTP 402 error if the first payment fails. Useful for immediate feedback when the customer is present.
proration_behavior enum

Determines how to handle prorations when billing_cycle_anchor is set or when the subscription start date is backdated.

Possible enum values
create_prorationsCreate prorations when applicable. Default.
noneDisable creating prorations.
trial_end string | timestamp

Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. Can also be the string now to end the trial immediately. Mutually exclusive with trial_from_plan=true.

trial_period_days integer

Integer representing the number of trial period days before the customer is charged for the first time. Mutually exclusive with trial_end.

More attributes

Returns

Returns the newly created Subscription object, which may be in an incomplete status if the initial payment fails and payment_behavior allows incomplete subscriptions.

POST/v1/subscriptions
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscription = await zoneless.subscriptions.create({
  customer: 'cus_z_MayaChen91kL2',
  items: [{ price: 'price_z_ProMonthly25' }],
});
RESPONSE
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": null
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": null,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {},
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}

Update a subscription

Updates an existing subscription to match the specified parameters. When changing prices or quantities, prorations are created by default. For example, if a customer upgrades from a 100 USDC plan to a 200 USDC plan mid-cycle, Zoneless creates a proration for the unused time on the old price and charges for the remaining time on the new price. Use proration_behavior to control or disable this.

ENDPOINTS
POST /v1/subscriptions/:id

Parameters

items array of objects

A list of up to 20 subscription items, each with an attached price. Include an id to update an existing item, or omit it to create a new one. Set deleted to remove an item.

metadata object

Set of key-value pairs that you can attach to an object. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata.

description string

The subscription's description, meant to be displayable to the customer. Maximum length is 500 characters.

cancel_at_period_end boolean

Boolean indicating whether this subscription should cancel at the end of the current period.

default_payment_method string

ID of the default payment method for the subscription. It must belong to the customer associated with the subscription.

collection_method enum

Either charge_automatically, or send_invoice.

Possible enum values
charge_automatically
send_invoice
billing_cycle_anchor enum

Either now or unchanged. Setting the value to now resets the subscription's billing cycle anchor to the current time (in UTC).

Possible enum values
nowReset the billing cycle anchor to the current time.
unchangedKeep the existing billing cycle anchor.
proration_behavior enum

Determines how to handle prorations when the billing cycle changes or when items are updated. For example, upgrading from a 100 USDC plan to a 200 USDC plan mid-cycle creates a proration for the unused time on the old price and the remaining time on the new price.

Possible enum values
create_prorationsCreate prorations when applicable. Default.
noneDisable creating prorations.
always_invoiceCreate prorations and immediately invoice them.
proration_date timestamp

If set, the proration will be calculated as though the subscription was updated at the given time. Useful for previewing prorations.

payment_behavior enum

Use allow_incomplete to create pending updates when the latest invoice payment fails, or pending_if_incomplete to keep the update pending until payment succeeds.

Possible enum values
allow_incomplete
default_incomplete
error_if_incomplete
pending_if_incompleteKeep the update pending until the latest invoice is paid. Exclusive to subscription updates.
pause_collection object

If specified, payment collection for this subscription is paused. Pass an empty string to resume payment collection.

cancellation_details object

Details about why this subscription was cancelled.

More attributes

Returns

Returns the updated Subscription object if the update succeeds.

POST/v1/subscriptions/:id
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscription = await zoneless.subscriptions.update(
  'sub_z_1QvK9mR2eZvKYlo2CxH4pN8w',
  {
    metadata: {
      order_id: '8421',
    },
  }
);
RESPONSE
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": null
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": null,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {
    "order_id": "8421"
  },
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}

Retrieve a subscription

Retrieves the subscription with the given ID.

ENDPOINTS
GET /v1/subscriptions/:id

Parameters

No parameters.

Returns

Returns a Subscription object if a valid identifier was provided.

GET/v1/subscriptions/:id
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscription = await zoneless.subscriptions.retrieve(
  'sub_z_1QvK9mR2eZvKYlo2CxH4pN8w'
);
RESPONSE
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": null
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": null,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {},
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}

List all subscriptions

By default, returns a list of subscriptions that have not been canceled. To list canceled subscriptions, specify status=canceled.

ENDPOINTS
GET /v1/subscriptions

Parameters

customer string

The ID of the customer whose subscriptions will be retrieved.

price string

Filter for subscriptions that contain this recurring price ID.

status enum

The status of the subscriptions to retrieve. By default, returns non-canceled subscriptions. Pass canceled to list canceled subscriptions, or all to list every subscription.

Possible enum values
active
all
canceled
ended
incomplete
incomplete_expired
past_due
paused
trialing
unpaid
limit integer

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.

More attributes

Returns

Returns a list of Subscription objects.

GET/v1/subscriptions
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscriptions = await zoneless.subscriptions.list({
  limit: 3,
});
RESPONSE
{
  "object": "list",
  "url": "/v1/subscriptions",
  "has_more": false,
  "data": [
    {
      "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
      "object": "subscription",
      "application": null,
      "application_fee_percent": null,
      "automatic_tax": {
        "enabled": false,
        "disabled_reason": null,
        "liability": null
      },
      "billing_cycle_anchor": 1784745600,
      "billing_cycle_anchor_config": null,
      "billing_mode": {
        "type": "flexible",
        "flexible": {
          "proration_discounts": "included"
        },
        "updated_at": 1784745600
      },
      "billing_schedules": [],
      "billing_thresholds": null,
      "cancel_at": null,
      "cancel_at_period_end": false,
      "canceled_at": null,
      "cancellation_details": {
        "comment": null,
        "feedback": null,
        "reason": null
      },
      "collection_method": "charge_automatically",
      "created": 1784745600,
      "currency": "usdc",
      "customer": "cus_z_MayaChen91kL2",
      "customer_account": null,
      "days_until_due": null,
      "default_payment_method": "pm_z_cryptoWallet7Hx",
      "default_source": null,
      "default_tax_rates": [],
      "description": "Pro membership",
      "discounts": [],
      "ended_at": null,
      "invoice_settings": {
        "account_tax_ids": null,
        "custom_fields": null,
        "description": null,
        "footer": null,
        "issuer": {
          "type": "self",
          "account": null
        }
      },
      "items": {
        "object": "list",
        "data": [
          {
            "id": "si_z_9Km2pQxR4vL8nHw",
            "object": "subscription_item",
            "billed_until": null,
            "billing_thresholds": null,
            "created": 1784745601,
            "current_period_end": 1787424000,
            "current_period_start": 1784745600,
            "discounts": [],
            "metadata": {},
            "price": "price_z_ProMonthly25",
            "quantity": 1,
            "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
            "tax_rates": [],
            "platform_account": "acct_z_Platform123abc"
          }
        ],
        "has_more": false,
        "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
      },
      "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
      "livemode": false,
      "managed_payments": null,
      "metadata": {},
      "next_pending_invoice_item_invoice": null,
      "on_behalf_of": null,
      "pause_collection": null,
      "payment_settings": {
        "payment_method_options": {
          "crypto": {
            "setup_future_usage": "none"
          }
        },
        "payment_method_types": ["crypto"],
        "save_default_payment_method": "off"
      },
      "pending_invoice_item_interval": null,
      "pending_setup_intent": null,
      "pending_update": null,
      "presentment_details": null,
      "schedule": null,
      "start_date": 1784745600,
      "status": "active",
      "test_clock": null,
      "transfer_data": null,
      "trial_end": null,
      "trial_settings": {
        "end_behavior": {
          "missing_payment_method": "create_invoice"
        }
      },
      "trial_start": null,
      "platform_account": "acct_z_Platform123abc",
      "subscription_delegation_pda": "7xK9Nv3F...abc123",
      "billing_lock_until": null
    }
  ]
}

Cancel a subscription

Cancels a customer's subscription immediately. The customer will not be charged again for the subscription. After cancellation, any outstanding invoices remain open and must be paid separately.

ENDPOINTS
DELETE /v1/subscriptions/:id

Parameters

cancellation_details object

Details about why this subscription was cancelled.

invoice_now boolean

Generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. Defaults to false.

prorate boolean

Generate a prorated invoice for the remaining portion of the subscription period. Defaults to false.

Returns

Returns the canceled Subscription object with status set to canceled.

DELETE/v1/subscriptions/:id
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscription = await zoneless.subscriptions.cancel(
  'sub_z_1QvK9mR2eZvKYlo2CxH4pN8w'
);
RESPONSE
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": 1784832000,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": "cancellation_requested"
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": 1784832000,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {},
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "canceled",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}

Migrate a subscription

Upgrade a subscription's billing mode from classic to flexible.

ENDPOINTS
POST /v1/subscriptions/:id/migrate

Parameters

billing_mode object Required

Controls how prorations and invoices for subscriptions are calculated and orchestrated. Use this endpoint to upgrade a subscription's billing mode to flexible.

Returns

Returns the updated Subscription object with billing_mode.type set to flexible.

POST/v1/subscriptions/:id/migrate
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscription = await zoneless.subscriptions.migrate(
  'sub_z_1QvK9mR2eZvKYlo2CxH4pN8w',
  {
    billing_mode: {
      type: 'flexible',
    },
  }
);
RESPONSE
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": null
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": null,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {},
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}

Resume a subscription

Resumes a paused subscription. Only subscriptions with collection_method=charge_automatically can be resumed. The subscription must be in the paused status (typically after a trial ends without a payment method).

ENDPOINTS
POST /v1/subscriptions/:id/resume

Parameters

billing_cycle_anchor enum

Either now or unchanged. Setting the value to now resets the subscription's billing cycle anchor to the current time (in UTC). The default is now.

Possible enum values
nowReset the billing cycle anchor to the current time.
unchangedKeep the existing billing cycle anchor.
proration_behavior enum

Determines how to handle prorations when resuming the subscription.

Possible enum values
create_prorationsCreate prorations when applicable.
noneDisable creating prorations.
always_invoiceCreate prorations and immediately invoice them.
proration_date timestamp

If set, the proration will be calculated as though the subscription was resumed at the given time.

Returns

Returns the resumed Subscription object, typically with status set to active.

POST/v1/subscriptions/:id/resume
import { Zoneless } from '@zoneless/node';
const zoneless = new Zoneless('sk_live_z_YOUR_API_KEY', 'https://api.zoneless.com');

const subscription = await zoneless.subscriptions.resume(
  'sub_z_1QvK9mR2eZvKYlo2CxH4pN8w',
  {
    billing_cycle_anchor: 'now',
  }
);
RESPONSE
{
  "id": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
  "object": "subscription",
  "application": null,
  "application_fee_percent": null,
  "automatic_tax": {
    "enabled": false,
    "disabled_reason": null,
    "liability": null
  },
  "billing_cycle_anchor": 1784745600,
  "billing_cycle_anchor_config": null,
  "billing_mode": {
    "type": "flexible",
    "flexible": {
      "proration_discounts": "included"
    },
    "updated_at": 1784745600
  },
  "billing_schedules": [],
  "billing_thresholds": null,
  "cancel_at": null,
  "cancel_at_period_end": false,
  "canceled_at": null,
  "cancellation_details": {
    "comment": null,
    "feedback": null,
    "reason": null
  },
  "collection_method": "charge_automatically",
  "created": 1784745600,
  "currency": "usdc",
  "customer": "cus_z_MayaChen91kL2",
  "customer_account": null,
  "days_until_due": null,
  "default_payment_method": "pm_z_cryptoWallet7Hx",
  "default_source": null,
  "default_tax_rates": [],
  "description": "Pro membership",
  "discounts": [],
  "ended_at": null,
  "invoice_settings": {
    "account_tax_ids": null,
    "custom_fields": null,
    "description": null,
    "footer": null,
    "issuer": {
      "type": "self",
      "account": null
    }
  },
  "items": {
    "object": "list",
    "data": [
      {
        "id": "si_z_9Km2pQxR4vL8nHw",
        "object": "subscription_item",
        "billed_until": null,
        "billing_thresholds": null,
        "created": 1784745601,
        "current_period_end": 1787424000,
        "current_period_start": 1784745600,
        "discounts": [],
        "metadata": {},
        "price": "price_z_ProMonthly25",
        "quantity": 1,
        "subscription": "sub_z_1QvK9mR2eZvKYlo2CxH4pN8w",
        "tax_rates": [],
        "platform_account": "acct_z_Platform123abc"
      }
    ],
    "has_more": false,
    "url": "/v1/subscription_items?subscription=sub_z_1QvK9mR2eZvKYlo2CxH4pN8w"
  },
  "latest_invoice": "in_z_1QvK9nT3eZvKYlo2C8mR2qPx",
  "livemode": false,
  "managed_payments": null,
  "metadata": {},
  "next_pending_invoice_item_invoice": null,
  "on_behalf_of": null,
  "pause_collection": null,
  "payment_settings": {
    "payment_method_options": {
      "crypto": {
        "setup_future_usage": "none"
      }
    },
    "payment_method_types": ["crypto"],
    "save_default_payment_method": "off"
  },
  "pending_invoice_item_interval": null,
  "pending_setup_intent": null,
  "pending_update": null,
  "presentment_details": null,
  "schedule": null,
  "start_date": 1784745600,
  "status": "active",
  "test_clock": null,
  "transfer_data": null,
  "trial_end": null,
  "trial_settings": {
    "end_behavior": {
      "missing_payment_method": "create_invoice"
    }
  },
  "trial_start": null,
  "platform_account": "acct_z_Platform123abc",
  "subscription_delegation_pda": "7xK9Nv3F...abc123",
  "billing_lock_until": null
}