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.import({
subscriptions: [
{
id: 'id',
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.import_(
subscriptions=[{
"id": "id",
"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.Import(context.TODO(), stigg.V1SubscriptionImportParams{
Subscriptions: []stigg.V1SubscriptionImportParamsSubscription{{
ID: "id",
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.SubscriptionImportParams;
import io.stigg.models.v1.subscriptions.SubscriptionImportResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
SubscriptionImportParams params = SubscriptionImportParams.builder()
.addSubscription(SubscriptionImportParams.Subscription.builder()
.id("id")
.customerId("customerId")
.planId("planId")
.build())
.build();
SubscriptionImportResponse response = client.v1().subscriptions().import_(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.subscriptions.import(subscriptions: [{id: "id", customerId: "customerId", planId: "planId"}])
puts(response)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V1.Subscriptions;
StiggClient client = new();
SubscriptionImportParams parameters = new()
{
Subscriptions =
[
new()
{
ID = "id",
CustomerID = "customerId",
PlanID = "planId",
Addons =
[
new()
{
ID = "id",
Quantity = 0,
},
],
BillingID = "billingId",
BillingPeriod = SubscriptionBillingPeriod.Monthly,
Charges =
[
new()
{
ID = "id",
Quantity = 0,
Type = SubscriptionChargeType.Feature,
},
],
EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
ResourceID = "resourceId",
StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
},
],
};
var response = await client.V1.Subscriptions.Import(parameters);
Console.WriteLine(response);stigg v1:subscriptions import \
--api-key 'My API Key' \
--subscription '{id: id, customerId: customerId, planId: planId}'curl --request POST \
--url https://api.stigg.io/api/v1/subscriptions/import \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"subscriptions": [
{
"customerId": "<string>",
"planId": "<string>",
"id": "<string>",
"resourceId": "<string>",
"endDate": "2023-11-07T05:31:56Z",
"metadata": {},
"billingId": "<string>",
"startDate": "2023-11-07T05:31:56Z",
"addons": [
{
"id": "<string>",
"quantity": 1
}
],
"charges": [
{
"id": "<string>",
"quantity": 1
}
]
}
],
"integrationId": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/subscriptions/import",
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([
'subscriptions' => [
[
'customerId' => '<string>',
'planId' => '<string>',
'id' => '<string>',
'resourceId' => '<string>',
'endDate' => '2023-11-07T05:31:56Z',
'metadata' => [
],
'billingId' => '<string>',
'startDate' => '2023-11-07T05:31:56Z',
'addons' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'charges' => [
[
'id' => '<string>',
'quantity' => 1
]
]
]
],
'integrationId' => '<string>'
]),
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": {
"taskId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "CustomerNotFound"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Bulk Import
Bulk import subscriptions
Imports multiple subscriptions in bulk. Used for migrating subscription data from external systems.
POST
/
api
/
v1
/
subscriptions
/
import
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.import({
subscriptions: [
{
id: 'id',
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.import_(
subscriptions=[{
"id": "id",
"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.Import(context.TODO(), stigg.V1SubscriptionImportParams{
Subscriptions: []stigg.V1SubscriptionImportParamsSubscription{{
ID: "id",
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.SubscriptionImportParams;
import io.stigg.models.v1.subscriptions.SubscriptionImportResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
SubscriptionImportParams params = SubscriptionImportParams.builder()
.addSubscription(SubscriptionImportParams.Subscription.builder()
.id("id")
.customerId("customerId")
.planId("planId")
.build())
.build();
SubscriptionImportResponse response = client.v1().subscriptions().import_(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
response = stigg.v1.subscriptions.import(subscriptions: [{id: "id", customerId: "customerId", planId: "planId"}])
puts(response)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V1.Subscriptions;
StiggClient client = new();
SubscriptionImportParams parameters = new()
{
Subscriptions =
[
new()
{
ID = "id",
CustomerID = "customerId",
PlanID = "planId",
Addons =
[
new()
{
ID = "id",
Quantity = 0,
},
],
BillingID = "billingId",
BillingPeriod = SubscriptionBillingPeriod.Monthly,
Charges =
[
new()
{
ID = "id",
Quantity = 0,
Type = SubscriptionChargeType.Feature,
},
],
EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
ResourceID = "resourceId",
StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
},
],
};
var response = await client.V1.Subscriptions.Import(parameters);
Console.WriteLine(response);stigg v1:subscriptions import \
--api-key 'My API Key' \
--subscription '{id: id, customerId: customerId, planId: planId}'curl --request POST \
--url https://api.stigg.io/api/v1/subscriptions/import \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"subscriptions": [
{
"customerId": "<string>",
"planId": "<string>",
"id": "<string>",
"resourceId": "<string>",
"endDate": "2023-11-07T05:31:56Z",
"metadata": {},
"billingId": "<string>",
"startDate": "2023-11-07T05:31:56Z",
"addons": [
{
"id": "<string>",
"quantity": 1
}
],
"charges": [
{
"id": "<string>",
"quantity": 1
}
]
}
],
"integrationId": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/subscriptions/import",
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([
'subscriptions' => [
[
'customerId' => '<string>',
'planId' => '<string>',
'id' => '<string>',
'resourceId' => '<string>',
'endDate' => '2023-11-07T05:31:56Z',
'metadata' => [
],
'billingId' => '<string>',
'startDate' => '2023-11-07T05:31:56Z',
'addons' => [
[
'id' => '<string>',
'quantity' => 1
]
],
'charges' => [
[
'id' => '<string>',
'quantity' => 1
]
]
]
],
'integrationId' => '<string>'
]),
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": {
"taskId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "CustomerNotFound"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Headers
Body
application/json
Bulk import up to 1000 subscriptions. Creates an async import task that processes subscriptions in the background. Existing subscriptions are updated, new ones are created.