Skip to main content
POST
/
api
/
v1
/
subscriptions
/
preview
JavaScript
import Stigg from '@stigg/typescript';

const client = new Stigg({
  apiKey: process.env['STIGG_API_KEY'], // This is the default and can be omitted
});

const response = await client.v1.subscriptions.preview({
  customerId: 'customerId',
  planId: 'planId',
});

console.log(response.data);
{
  "data": {
    "immediateInvoice": {
      "total": 123,
      "subTotal": 123,
      "discount": 123,
      "tax": 123,
      "currency": "<string>",
      "billingPeriodRange": {
        "start": "2023-11-07T05:31:56Z",
        "end": "2023-11-07T05:31:56Z"
      },
      "lines": [
        {
          "description": "<string>",
          "unitPrice": 123,
          "subTotal": 123,
          "currency": "<string>",
          "quantity": 123
        }
      ],
      "discounts": [
        {
          "description": "<string>",
          "amount": 123,
          "currency": "<string>"
        }
      ],
      "discountDetails": {
        "code": "<string>",
        "percentage": 123,
        "fixedAmount": 123
      }
    },
    "recurringInvoice": {
      "total": 123,
      "subTotal": 123,
      "discount": 123,
      "tax": 123,
      "currency": "<string>",
      "billingPeriodRange": {
        "start": "2023-11-07T05:31:56Z",
        "end": "2023-11-07T05:31:56Z"
      },
      "lines": [
        {
          "description": "<string>",
          "unitPrice": 123,
          "subTotal": 123,
          "currency": "<string>",
          "quantity": 123
        }
      ],
      "discounts": [
        {
          "description": "<string>",
          "amount": 123,
          "currency": "<string>"
        }
      ],
      "discountDetails": {
        "code": "<string>",
        "percentage": 123,
        "fixedAmount": 123
      }
    },
    "billingPeriodRange": {
      "start": "2023-11-07T05:31:56Z",
      "end": "2023-11-07T05:31:56Z"
    },
    "isPlanDowngrade": true,
    "hasScheduledUpdates": true,
    "freeItems": [
      {
        "addonId": "<string>",
        "quantity": 123
      }
    ]
  }
}

Authorizations

X-API-KEY
string
header
required

Server API Key

Headers

X-API-KEY
string
required

API Key

Body

application/json

Preview subscription pricing and invoice details before provisioning. Returns calculated totals, line items, taxes, and discounts based on the provided subscription configuration.

customerId
string
required

Customer ID

Maximum string length: 255
planId
string
required

Plan ID

Maximum string length: 255
payingCustomerId
string

Paying customer ID for delegated billing

resourceId
string

Resource ID for multi-instance subscriptions

billingPeriod
enum<string>

Billing period (MONTHLY or ANNUALLY)

Available options:
MONTHLY,
ANNUALLY
billingCountryCode
string

ISO 3166-1 country code for localization

unitQuantity
number

Unit quantity for per-unit pricing

Required range: x >= 1
billableFeatures
BillableFeature · object[]

Billable features with quantities

charges
Charge · object[]

One-time or recurring charges

addons
SubscriptionAddon · object[]

Addons to include

startDate
string<date-time>

Subscription start date

billingInformation
SubscriptionBillingInfo · object

Billing and tax configuration

scheduleStrategy
enum<string>

When to apply subscription changes

Available options:
END_OF_BILLING_PERIOD,
END_OF_BILLING_MONTH,
IMMEDIATE
appliedCoupon
SubscriptionCoupon · object

Coupon or discount to apply

trialOverrideConfiguration
TrialOverrideConfiguration · object

Trial period override settings

Response

SubscriptionPreview created.

Response object

data
SubscriptionPreview · object
required

Pricing preview with invoices