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);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.provision(
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.Provision(context.TODO(), stigg.V1SubscriptionProvisionParams{
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.SubscriptionProvisionParams;
import io.stigg.models.v1.subscriptions.SubscriptionProvisionResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
SubscriptionProvisionParams params = SubscriptionProvisionParams.builder()
.customerId("customerId")
.planId("planId")
.build();
SubscriptionProvisionResponse response = client.v1().subscriptions().provision(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.subscriptions.provision(customer_id: "customerId", plan_id: "planId")
puts(response)using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Subscriptions;
StiggClient client = new();
SubscriptionProvisionParams parameters = new()
{
CustomerID = "customerId",
PlanID = "planId",
};
var response = await client.V1.Subscriptions.Provision(parameters);
Console.WriteLine(response);stigg v1:subscriptions provision \
--api-key 'My API Key' \
--customer-id customerId \
--plan-id planIdcurl --request POST \
--url https://api.stigg.io/api/v1/subscriptions \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"customerId": "<string>",
"planId": "<string>",
"id": "<string>",
"payingCustomerId": "<string>",
"resourceId": "<string>",
"addons": [
{
"id": "<string>",
"quantity": 1
}
],
"charges": [
{
"id": "<string>",
"quantity": 1
}
],
"startDate": "2023-11-07T05:31:56Z",
"cancellationDate": "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>"
}
]
},
"billingId": "<string>",
"billingCountryCode": "<string>",
"entitlements": [
{
"type": "FEATURE",
"id": "<string>",
"usageLimit": 1,
"hasUnlimitedUsage": true,
"hasSoftLimit": true,
"yearlyResetPeriodConfiguration": {
"accordingTo": "SubscriptionStart"
},
"monthlyResetPeriodConfiguration": {},
"weeklyResetPeriodConfiguration": {}
}
],
"metadata": {},
"salesforceId": "<string>",
"budget": {
"limit": 123,
"hasSoftLimit": true
},
"minimumSpend": {
"amount": 123
},
"priceOverrides": [
{
"amount": 123,
"featureId": "<string>",
"addonId": "<string>",
"baseCharge": true,
"billingCountryCode": "<string>",
"blockSize": 123,
"tiers": [
{
"upTo": 123
}
]
}
],
"paymentCollectionMethod": "CHARGE",
"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"
}
},
"awaitPaymentConfirmation": true,
"unitQuantity": 1
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/subscriptions",
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>',
'id' => '<string>',
'payingCustomerId' => '<string>',
'resourceId' => '<string>',
'addons' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'charges' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'startDate' => '2023-11-07T05:31:56Z',
'cancellationDate' => '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>'
]
]
],
'billingId' => '<string>',
'billingCountryCode' => '<string>',
'entitlements' => [
[
'type' => 'FEATURE',
'id' => '<string>',
'usageLimit' => 1,
'hasUnlimitedUsage' => true,
'hasSoftLimit' => true,
'yearlyResetPeriodConfiguration' => [
'accordingTo' => 'SubscriptionStart'
],
'monthlyResetPeriodConfiguration' => [
],
'weeklyResetPeriodConfiguration' => [
]
]
],
'metadata' => [
],
'salesforceId' => '<string>',
'budget' => [
'limit' => 123,
'hasSoftLimit' => true
],
'minimumSpend' => [
'amount' => 123
],
'priceOverrides' => [
[
'amount' => 123,
'featureId' => '<string>',
'addonId' => '<string>',
'baseCharge' => true,
'billingCountryCode' => '<string>',
'blockSize' => 123,
'tiers' => [
[
'upTo' => 123
]
]
]
],
'paymentCollectionMethod' => 'CHARGE',
'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'
]
],
'awaitPaymentConfirmation' => true,
'unitQuantity' => 1
]),
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": {
"id": "<string>",
"status": "SUCCESS",
"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>",
"contractId": "<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",
"billingCycleAnchor": "2023-11-07T05:31:56Z",
"prices": [],
"addons": [],
"coupons": [],
"futureUpdates": [],
"budget": {
"limit": 123,
"hasSoftLimit": true
},
"minimumSpend": {
"amount": 123,
"currency": "usd"
},
"subscriptionEntitlements": [],
"latestInvoice": {
"billingId": "<string>",
"status": "OPEN",
"createdAt": "2023-11-07T05:31:56Z",
"requiresAction": true,
"total": 123,
"amountDue": 123,
"currency": "<string>",
"pdfUrl": "<string>",
"billingReason": "BILLING_CYCLE"
},
"trial": {
"trialEndBehavior": "CONVERT_TO_PAID"
}
},
"entitlements": [
{
"isGranted": true,
"type": "FEATURE",
"accessDeniedReason": "FeatureNotFound",
"feature": {
"id": "<string>",
"displayName": "<string>",
"featureType": "BOOLEAN",
"featureStatus": "NEW"
},
"usageLimit": 1,
"hasUnlimitedUsage": true,
"resetPeriod": "YEAR",
"currentUsage": 123,
"usagePeriodAnchor": "2023-11-07T05:31:56Z",
"usagePeriodStart": "2023-11-07T05:31:56Z",
"usagePeriodEnd": "2023-11-07T05:31:56Z",
"entitlementUpdatedAt": "2023-11-07T05:31:56Z",
"validUntil": "2023-11-07T05:31:56Z"
}
],
"checkoutBillingId": "<string>",
"checkoutUrl": "<string>",
"isScheduled": true
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "DuplicatedEntityNotAllowed"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Create Subscription
Creates a new subscription for an existing customer. When payment is required and no payment method exists, returns a checkout URL.
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);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.provision(
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.Provision(context.TODO(), stigg.V1SubscriptionProvisionParams{
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.SubscriptionProvisionParams;
import io.stigg.models.v1.subscriptions.SubscriptionProvisionResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
SubscriptionProvisionParams params = SubscriptionProvisionParams.builder()
.customerId("customerId")
.planId("planId")
.build();
SubscriptionProvisionResponse response = client.v1().subscriptions().provision(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.subscriptions.provision(customer_id: "customerId", plan_id: "planId")
puts(response)using System;
using Stigg.Client;
using Stigg.Client.Models.V1.Subscriptions;
StiggClient client = new();
SubscriptionProvisionParams parameters = new()
{
CustomerID = "customerId",
PlanID = "planId",
};
var response = await client.V1.Subscriptions.Provision(parameters);
Console.WriteLine(response);stigg v1:subscriptions provision \
--api-key 'My API Key' \
--customer-id customerId \
--plan-id planIdcurl --request POST \
--url https://api.stigg.io/api/v1/subscriptions \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"customerId": "<string>",
"planId": "<string>",
"id": "<string>",
"payingCustomerId": "<string>",
"resourceId": "<string>",
"addons": [
{
"id": "<string>",
"quantity": 1
}
],
"charges": [
{
"id": "<string>",
"quantity": 1
}
],
"startDate": "2023-11-07T05:31:56Z",
"cancellationDate": "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>"
}
]
},
"billingId": "<string>",
"billingCountryCode": "<string>",
"entitlements": [
{
"type": "FEATURE",
"id": "<string>",
"usageLimit": 1,
"hasUnlimitedUsage": true,
"hasSoftLimit": true,
"yearlyResetPeriodConfiguration": {
"accordingTo": "SubscriptionStart"
},
"monthlyResetPeriodConfiguration": {},
"weeklyResetPeriodConfiguration": {}
}
],
"metadata": {},
"salesforceId": "<string>",
"budget": {
"limit": 123,
"hasSoftLimit": true
},
"minimumSpend": {
"amount": 123
},
"priceOverrides": [
{
"amount": 123,
"featureId": "<string>",
"addonId": "<string>",
"baseCharge": true,
"billingCountryCode": "<string>",
"blockSize": 123,
"tiers": [
{
"upTo": 123
}
]
}
],
"paymentCollectionMethod": "CHARGE",
"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"
}
},
"awaitPaymentConfirmation": true,
"unitQuantity": 1
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/subscriptions",
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>',
'id' => '<string>',
'payingCustomerId' => '<string>',
'resourceId' => '<string>',
'addons' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'charges' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'startDate' => '2023-11-07T05:31:56Z',
'cancellationDate' => '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>'
]
]
],
'billingId' => '<string>',
'billingCountryCode' => '<string>',
'entitlements' => [
[
'type' => 'FEATURE',
'id' => '<string>',
'usageLimit' => 1,
'hasUnlimitedUsage' => true,
'hasSoftLimit' => true,
'yearlyResetPeriodConfiguration' => [
'accordingTo' => 'SubscriptionStart'
],
'monthlyResetPeriodConfiguration' => [
],
'weeklyResetPeriodConfiguration' => [
]
]
],
'metadata' => [
],
'salesforceId' => '<string>',
'budget' => [
'limit' => 123,
'hasSoftLimit' => true
],
'minimumSpend' => [
'amount' => 123
],
'priceOverrides' => [
[
'amount' => 123,
'featureId' => '<string>',
'addonId' => '<string>',
'baseCharge' => true,
'billingCountryCode' => '<string>',
'blockSize' => 123,
'tiers' => [
[
'upTo' => 123
]
]
]
],
'paymentCollectionMethod' => 'CHARGE',
'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'
]
],
'awaitPaymentConfirmation' => true,
'unitQuantity' => 1
]),
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": {
"id": "<string>",
"status": "SUCCESS",
"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>",
"contractId": "<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",
"billingCycleAnchor": "2023-11-07T05:31:56Z",
"prices": [],
"addons": [],
"coupons": [],
"futureUpdates": [],
"budget": {
"limit": 123,
"hasSoftLimit": true
},
"minimumSpend": {
"amount": 123,
"currency": "usd"
},
"subscriptionEntitlements": [],
"latestInvoice": {
"billingId": "<string>",
"status": "OPEN",
"createdAt": "2023-11-07T05:31:56Z",
"requiresAction": true,
"total": 123,
"amountDue": 123,
"currency": "<string>",
"pdfUrl": "<string>",
"billingReason": "BILLING_CYCLE"
},
"trial": {
"trialEndBehavior": "CONVERT_TO_PAID"
}
},
"entitlements": [
{
"isGranted": true,
"type": "FEATURE",
"accessDeniedReason": "FeatureNotFound",
"feature": {
"id": "<string>",
"displayName": "<string>",
"featureType": "BOOLEAN",
"featureStatus": "NEW"
},
"usageLimit": 1,
"hasUnlimitedUsage": true,
"resetPeriod": "YEAR",
"currentUsage": 123,
"usagePeriodAnchor": "2023-11-07T05:31:56Z",
"usagePeriodStart": "2023-11-07T05:31:56Z",
"usagePeriodEnd": "2023-11-07T05:31:56Z",
"entitlementUpdatedAt": "2023-11-07T05:31:56Z",
"validUntil": "2023-11-07T05:31:56Z"
}
],
"checkoutBillingId": "<string>",
"checkoutUrl": "<string>",
"isScheduled": true
}
}{
"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
Provision a subscription. Returns subscription or checkout URL.