Skip to main content
POST
/
api
/
v1
/
subscriptions
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.provision({
  customerId: 'customerId',
  planId: 'planId',
});

console.log(response.data);
{
  "data": {
    "id": "<string>",
    "status": "SUCCESS",
    "entitlements": [
      {
        "isGranted": true,
        "accessDeniedReason": "<string>",
        "feature": {
          "refId": "<string>"
        },
        "usageLimit": 1,
        "hasUnlimitedUsage": true,
        "resetPeriod": "YEAR",
        "currentUsage": 1,
        "usagePeriodAnchor": "2023-11-07T05:31:56Z",
        "usagePeriodStart": "2023-11-07T05:31:56Z",
        "usagePeriodEnd": "2023-11-07T05:31:56Z",
        "entitlementUpdatedAt": "2023-11-07T05:31:56Z"
      }
    ],
    "checkoutBillingId": "<string>",
    "checkoutUrl": "<string>",
    "subscription": {
      "id": "<string>",
      "customerId": "<string>",
      "billingId": "<string>",
      "createdAt": "2023-11-07T05:31:56Z",
      "startDate": "2023-11-07T05:31:56Z",
      "status": "PAYMENT_PENDING",
      "pricingType": "FREE",
      "paymentCollection": "NOT_REQUIRED",
      "planId": "<string>",
      "payingCustomerId": "<string>",
      "resourceId": "<string>",
      "endDate": "2023-11-07T05:31:56Z",
      "effectiveEndDate": "2023-11-07T05:31:56Z",
      "cancellationDate": "2023-11-07T05:31:56Z",
      "trialEndDate": "2023-11-07T05:31:56Z",
      "cancelReason": "UPGRADE_OR_DOWNGRADE",
      "metadata": {},
      "currentBillingPeriodStart": "2023-11-07T05:31:56Z",
      "currentBillingPeriodEnd": "2023-11-07T05:31:56Z",
      "paymentCollectionMethod": "CHARGE",
      "prices": [
        {
          "featureId": "<string>",
          "addonId": "<string>",
          "baseCharge": true,
          "price": {
            "amount": 123,
            "currency": "usd",
            "billingCountryCode": "<string>"
          },
          "blockSize": 123,
          "tiers": [
            {
              "upTo": 123,
              "unitPrice": {
                "amount": 123,
                "currency": "usd",
                "billingCountryCode": "<string>"
              },
              "flatPrice": {
                "amount": 123,
                "currency": "usd",
                "billingCountryCode": "<string>"
              }
            }
          ]
        }
      ]
    },
    "isScheduled": true
  }
}

Authorizations

X-API-KEY
string
header
required

Server API Key

Headers

X-API-KEY
string
required

API Key

Body

application/json

Provision a subscription. Returns subscription or checkout URL.

customerId
string
required

Customer ID to provision the subscription for

Maximum string length: 255
planId
string
required

Plan ID to provision

Maximum string length: 255
id
string

Unique identifier for the subscription

Maximum string length: 255
payingCustomerId
string | null

Optional paying customer ID for split billing scenarios

Maximum string length: 255
resourceId
string | null

Optional resource ID for multi-instance subscriptions

Maximum string length: 255
billingPeriod
enum<string>

Billing period (MONTHLY or ANNUALLY)

Available options:
MONTHLY,
ANNUALLY
addons
object[]
charges
Charge · object[]
startDate
string<date-time>

Subscription start date

billingInformation
object
billingId
string | null

External billing system identifier

Maximum string length: 255
billingCountryCode
string | null

The ISO 3166-1 alpha-2 country code for billing

Maximum string length: 255
subscriptionEntitlements
object[]
trialOverrideConfiguration
object

Trial period override settings

scheduleStrategy
enum<string>

Strategy for scheduling subscription changes

Available options:
END_OF_BILLING_PERIOD,
END_OF_BILLING_MONTH,
IMMEDIATE
checkoutOptions
object

Checkout page configuration for payment collection

metadata
object

Additional metadata for the subscription

salesforceId
string | null

Salesforce ID

Maximum string length: 255
budget
object
minimumSpend
object
priceOverrides
object[]
paymentCollectionMethod
enum<string>
default:CHARGE

How payments should be collected for this subscription

Available options:
CHARGE,
INVOICE,
NONE
appliedCoupon
SubscriptionCoupon · object

Coupon configuration

awaitPaymentConfirmation
boolean
default:true

Whether to wait for payment confirmation before returning the subscription

unitQuantity
number
Required range: x >= 1

Response

Subscription created.

Response object

data
ProvisionSubscriptionResult · object
required

Provisioning result with status and subscription or checkout URL.