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);import os
from stigg import Stigg
client = Stigg(
api_key=os.environ.get("STIGG_API_KEY"), # This is the default and can be omitted
)
response = client.v1.subscriptions.preview(
customer_id="customerId",
plan_id="planId",
)
print(response.data)package main
import (
"context"
"fmt"
"github.com/stiggio/stigg-go"
"github.com/stiggio/stigg-go/option"
)
func main() {
client := stigg.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.V1.Subscriptions.Preview(context.TODO(), stigg.V1SubscriptionPreviewParams{
CustomerID: "customerId",
PlanID: "planId",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package io.stigg.example;
import io.stigg.client.StiggClient;
import io.stigg.client.okhttp.StiggOkHttpClient;
import io.stigg.models.v1.subscriptions.SubscriptionPreviewParams;
import io.stigg.models.v1.subscriptions.SubscriptionPreviewResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
SubscriptionPreviewParams params = SubscriptionPreviewParams.builder()
.customerId("customerId")
.planId("planId")
.build();
SubscriptionPreviewResponse response = client.v1().subscriptions().preview(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.subscriptions.preview(customer_id: "customerId", plan_id: "planId")
puts(response)using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Subscriptions;
StiggClient client = new();
SubscriptionPreviewParams parameters = new()
{
CustomerID = "customerId",
PlanID = "planId",
};
var response = await client.V1.Subscriptions.Preview(parameters);
Console.WriteLine(response);stigg v1:subscriptions preview \
--api-key 'My API Key' \
--customer-id customerId \
--plan-id planIdcurl --request POST \
--url https://api.stigg.io/api/v1/subscriptions/preview \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"customerId": "<string>",
"planId": "<string>",
"payingCustomerId": "<string>",
"resourceId": "<string>",
"billingCountryCode": "<string>",
"unitQuantity": 1,
"billableFeatures": [
{
"featureId": "<string>",
"quantity": 1
}
],
"charges": [
{
"id": "<string>",
"quantity": 1
}
],
"addons": [
{
"id": "<string>",
"quantity": 1
}
],
"startDate": "2023-11-07T05:31:56Z",
"billingInformation": {
"taxRateIds": [
"<string>"
],
"taxPercentage": 50,
"billingAddress": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postalCode": "<string>",
"state": "<string>"
},
"metadata": {},
"chargeOnBehalfOfAccount": "<string>",
"isBackdated": false,
"isInvoicePaid": false,
"invoiceDaysUntilDue": 123,
"integrationId": "<string>",
"taxIds": [
{
"type": "<string>",
"value": "<string>"
}
]
},
"appliedCoupon": {
"couponId": "<string>",
"billingCouponId": "<string>",
"promotionCode": "<string>",
"discount": {
"name": "<string>",
"description": "<string>",
"durationInMonths": 2,
"percentOff": 50.5,
"amountsOff": [
{
"amount": 123
}
]
},
"configuration": {
"startDate": "2023-11-07T05:31:56Z"
}
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/subscriptions/preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<string>',
'planId' => '<string>',
'payingCustomerId' => '<string>',
'resourceId' => '<string>',
'billingCountryCode' => '<string>',
'unitQuantity' => 1,
'billableFeatures' => [
[
'featureId' => '<string>',
'quantity' => 1
]
],
'charges' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'addons' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'startDate' => '2023-11-07T05:31:56Z',
'billingInformation' => [
'taxRateIds' => [
'<string>'
],
'taxPercentage' => 50,
'billingAddress' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'postalCode' => '<string>',
'state' => '<string>'
],
'metadata' => [
],
'chargeOnBehalfOfAccount' => '<string>',
'isBackdated' => false,
'isInvoicePaid' => false,
'invoiceDaysUntilDue' => 123,
'integrationId' => '<string>',
'taxIds' => [
[
'type' => '<string>',
'value' => '<string>'
]
]
],
'appliedCoupon' => [
'couponId' => '<string>',
'billingCouponId' => '<string>',
'promotionCode' => '<string>',
'discount' => [
'name' => '<string>',
'description' => '<string>',
'durationInMonths' => 2,
'percentOff' => 50.5,
'amountsOff' => [
[
'amount' => 123
]
]
],
'configuration' => [
'startDate' => '2023-11-07T05:31:56Z'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"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": [
{
"id": "<string>",
"quantity": 1
}
]
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "DuplicatedEntityNotAllowed"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Preview Subscription
Previews the pricing impact of creating or updating a subscription without making changes. Returns estimated costs, taxes, and proration details.
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);import os
from stigg import Stigg
client = Stigg(
api_key=os.environ.get("STIGG_API_KEY"), # This is the default and can be omitted
)
response = client.v1.subscriptions.preview(
customer_id="customerId",
plan_id="planId",
)
print(response.data)package main
import (
"context"
"fmt"
"github.com/stiggio/stigg-go"
"github.com/stiggio/stigg-go/option"
)
func main() {
client := stigg.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.V1.Subscriptions.Preview(context.TODO(), stigg.V1SubscriptionPreviewParams{
CustomerID: "customerId",
PlanID: "planId",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package io.stigg.example;
import io.stigg.client.StiggClient;
import io.stigg.client.okhttp.StiggOkHttpClient;
import io.stigg.models.v1.subscriptions.SubscriptionPreviewParams;
import io.stigg.models.v1.subscriptions.SubscriptionPreviewResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
SubscriptionPreviewParams params = SubscriptionPreviewParams.builder()
.customerId("customerId")
.planId("planId")
.build();
SubscriptionPreviewResponse response = client.v1().subscriptions().preview(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.subscriptions.preview(customer_id: "customerId", plan_id: "planId")
puts(response)using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Subscriptions;
StiggClient client = new();
SubscriptionPreviewParams parameters = new()
{
CustomerID = "customerId",
PlanID = "planId",
};
var response = await client.V1.Subscriptions.Preview(parameters);
Console.WriteLine(response);stigg v1:subscriptions preview \
--api-key 'My API Key' \
--customer-id customerId \
--plan-id planIdcurl --request POST \
--url https://api.stigg.io/api/v1/subscriptions/preview \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"customerId": "<string>",
"planId": "<string>",
"payingCustomerId": "<string>",
"resourceId": "<string>",
"billingCountryCode": "<string>",
"unitQuantity": 1,
"billableFeatures": [
{
"featureId": "<string>",
"quantity": 1
}
],
"charges": [
{
"id": "<string>",
"quantity": 1
}
],
"addons": [
{
"id": "<string>",
"quantity": 1
}
],
"startDate": "2023-11-07T05:31:56Z",
"billingInformation": {
"taxRateIds": [
"<string>"
],
"taxPercentage": 50,
"billingAddress": {
"city": "<string>",
"country": "<string>",
"line1": "<string>",
"line2": "<string>",
"postalCode": "<string>",
"state": "<string>"
},
"metadata": {},
"chargeOnBehalfOfAccount": "<string>",
"isBackdated": false,
"isInvoicePaid": false,
"invoiceDaysUntilDue": 123,
"integrationId": "<string>",
"taxIds": [
{
"type": "<string>",
"value": "<string>"
}
]
},
"appliedCoupon": {
"couponId": "<string>",
"billingCouponId": "<string>",
"promotionCode": "<string>",
"discount": {
"name": "<string>",
"description": "<string>",
"durationInMonths": 2,
"percentOff": 50.5,
"amountsOff": [
{
"amount": 123
}
]
},
"configuration": {
"startDate": "2023-11-07T05:31:56Z"
}
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/subscriptions/preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => '<string>',
'planId' => '<string>',
'payingCustomerId' => '<string>',
'resourceId' => '<string>',
'billingCountryCode' => '<string>',
'unitQuantity' => 1,
'billableFeatures' => [
[
'featureId' => '<string>',
'quantity' => 1
]
],
'charges' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'addons' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'startDate' => '2023-11-07T05:31:56Z',
'billingInformation' => [
'taxRateIds' => [
'<string>'
],
'taxPercentage' => 50,
'billingAddress' => [
'city' => '<string>',
'country' => '<string>',
'line1' => '<string>',
'line2' => '<string>',
'postalCode' => '<string>',
'state' => '<string>'
],
'metadata' => [
],
'chargeOnBehalfOfAccount' => '<string>',
'isBackdated' => false,
'isInvoicePaid' => false,
'invoiceDaysUntilDue' => 123,
'integrationId' => '<string>',
'taxIds' => [
[
'type' => '<string>',
'value' => '<string>'
]
]
],
'appliedCoupon' => [
'couponId' => '<string>',
'billingCouponId' => '<string>',
'promotionCode' => '<string>',
'discount' => [
'name' => '<string>',
'description' => '<string>',
'durationInMonths' => 2,
'percentOff' => 50.5,
'amountsOff' => [
[
'amount' => 123
]
]
],
'configuration' => [
'startDate' => '2023-11-07T05:31:56Z'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"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": [
{
"id": "<string>",
"quantity": 1
}
]
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "DuplicatedEntityNotAllowed"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Headers
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.