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 coupon = await client.v1.coupons.create({
id: 'id',
amountsOff: [{ amount: 0, currency: 'usd' }],
description: 'description',
durationInMonths: 1,
metadata: { foo: 'string' },
name: 'name',
percentOff: 1,
});
console.log(coupon.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
)
coupon = client.v1.coupons.create(
id="id",
amounts_off=[{
"amount": 0,
"currency": "usd",
}],
description="description",
duration_in_months=1,
metadata={
"foo": "string"
},
name="name",
percent_off=1,
)
print(coupon.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"),
)
coupon, err := client.V1.Coupons.New(context.TODO(), stigg.V1CouponNewParams{
ID: "id",
AmountsOff: []stigg.V1CouponNewParamsAmountsOff{{
Amount: 0,
Currency: "usd",
}},
Description: stigg.String("description"),
DurationInMonths: stigg.Int(1),
Metadata: map[string]string{
"foo": "string",
},
Name: "name",
PercentOff: stigg.Float(1),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", coupon.Data)
}
package io.stigg.example;
import io.stigg.client.StiggClient;
import io.stigg.client.okhttp.StiggOkHttpClient;
import io.stigg.core.JsonValue;
import io.stigg.models.v1.coupons.Coupon;
import io.stigg.models.v1.coupons.CouponCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
CouponCreateParams params = CouponCreateParams.builder()
.id("id")
.addAmountsOff(CouponCreateParams.AmountsOff.builder()
.amount(0.0)
.currency(CouponCreateParams.AmountsOff.Currency.USD)
.build())
.description("description")
.durationInMonths(1L)
.metadata(CouponCreateParams.Metadata.builder()
.putAdditionalProperty("foo", JsonValue.from("string"))
.build())
.name("name")
.percentOff(1.0)
.build();
Coupon coupon = client.v1().coupons().create(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
coupon = stigg.v1.coupons.create(
id: "id",
amounts_off: [{amount: 0, currency: :usd}],
description: "description",
duration_in_months: 1,
metadata: {foo: "string"},
name: "name",
percent_off: 1
)
puts(coupon)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V1.Coupons;
StiggClient client = new();
CouponCreateParams parameters = new()
{
ID = "id",
AmountsOff =
[
new()
{
Amount = 0,
Currency = Currency.Usd,
},
],
Description = "description",
DurationInMonths = 1,
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
Name = "name",
PercentOff = 1,
};
var coupon = await client.V1.Coupons.Create(parameters);
Console.WriteLine(coupon);stigg v1:coupons create \
--api-key 'My API Key' \
--id id \
--amounts-off '{amount: 0, currency: usd}' \
--description description \
--duration-in-months 1 \
--metadata '{foo: string}' \
--name name \
--percent-off 1curl --request POST \
--url https://api.stigg.io/api/v1/coupons \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"percentOff": 50.5,
"amountsOff": [
{
"amount": 123
}
],
"durationInMonths": 2,
"metadata": {}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/coupons",
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([
'id' => '<string>',
'name' => '<string>',
'description' => '<string>',
'percentOff' => 50.5,
'amountsOff' => [
[
'amount' => 123
]
],
'durationInMonths' => 2,
'metadata' => [
]
]),
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>",
"name": "<string>",
"description": "<string>",
"type": "FIXED",
"status": "ACTIVE",
"source": "STIGG",
"percentOff": 50,
"amountsOff": [
{
"amount": 123,
"currency": "usd"
}
],
"billingId": "<string>",
"billingLinkUrl": "<string>",
"durationInMonths": 2,
"metadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"code": "BadUserInput",
"reason": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>",
"code": "IdentityForbidden"
}{
"message": "<string>",
"code": "DuplicatedEntityNotAllowed"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Coupons
Create coupon
Creates a new discount coupon with percentage or fixed amount off, applicable to customer subscriptions.
POST
/
api
/
v1
/
coupons
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 coupon = await client.v1.coupons.create({
id: 'id',
amountsOff: [{ amount: 0, currency: 'usd' }],
description: 'description',
durationInMonths: 1,
metadata: { foo: 'string' },
name: 'name',
percentOff: 1,
});
console.log(coupon.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
)
coupon = client.v1.coupons.create(
id="id",
amounts_off=[{
"amount": 0,
"currency": "usd",
}],
description="description",
duration_in_months=1,
metadata={
"foo": "string"
},
name="name",
percent_off=1,
)
print(coupon.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"),
)
coupon, err := client.V1.Coupons.New(context.TODO(), stigg.V1CouponNewParams{
ID: "id",
AmountsOff: []stigg.V1CouponNewParamsAmountsOff{{
Amount: 0,
Currency: "usd",
}},
Description: stigg.String("description"),
DurationInMonths: stigg.Int(1),
Metadata: map[string]string{
"foo": "string",
},
Name: "name",
PercentOff: stigg.Float(1),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", coupon.Data)
}
package io.stigg.example;
import io.stigg.client.StiggClient;
import io.stigg.client.okhttp.StiggOkHttpClient;
import io.stigg.core.JsonValue;
import io.stigg.models.v1.coupons.Coupon;
import io.stigg.models.v1.coupons.CouponCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
StiggClient client = StiggOkHttpClient.fromEnv();
CouponCreateParams params = CouponCreateParams.builder()
.id("id")
.addAmountsOff(CouponCreateParams.AmountsOff.builder()
.amount(0.0)
.currency(CouponCreateParams.AmountsOff.Currency.USD)
.build())
.description("description")
.durationInMonths(1L)
.metadata(CouponCreateParams.Metadata.builder()
.putAdditionalProperty("foo", JsonValue.from("string"))
.build())
.name("name")
.percentOff(1.0)
.build();
Coupon coupon = client.v1().coupons().create(params);
}
}require "stigg"
stigg = Stigg::Client.new(api_key: "My API Key")
coupon = stigg.v1.coupons.create(
id: "id",
amounts_off: [{amount: 0, currency: :usd}],
description: "description",
duration_in_months: 1,
metadata: {foo: "string"},
name: "name",
percent_off: 1
)
puts(coupon)using System;
using System.Collections.Generic;
using Stigg.Client;
using Stigg.Client.Models.V1.Coupons;
StiggClient client = new();
CouponCreateParams parameters = new()
{
ID = "id",
AmountsOff =
[
new()
{
Amount = 0,
Currency = Currency.Usd,
},
],
Description = "description",
DurationInMonths = 1,
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
Name = "name",
PercentOff = 1,
};
var coupon = await client.V1.Coupons.Create(parameters);
Console.WriteLine(coupon);stigg v1:coupons create \
--api-key 'My API Key' \
--id id \
--amounts-off '{amount: 0, currency: usd}' \
--description description \
--duration-in-months 1 \
--metadata '{foo: string}' \
--name name \
--percent-off 1curl --request POST \
--url https://api.stigg.io/api/v1/coupons \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"percentOff": 50.5,
"amountsOff": [
{
"amount": 123
}
],
"durationInMonths": 2,
"metadata": {}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.stigg.io/api/v1/coupons",
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([
'id' => '<string>',
'name' => '<string>',
'description' => '<string>',
'percentOff' => 50.5,
'amountsOff' => [
[
'amount' => 123
]
],
'durationInMonths' => 2,
'metadata' => [
]
]),
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>",
"name": "<string>",
"description": "<string>",
"type": "FIXED",
"status": "ACTIVE",
"source": "STIGG",
"percentOff": 50,
"amountsOff": [
{
"amount": 123,
"currency": "usd"
}
],
"billingId": "<string>",
"billingLinkUrl": "<string>",
"durationInMonths": 2,
"metadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"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
Create a coupon with a percentage or fixed-amount discount. Set percentOff for a percentage coupon or amountsOff for a fixed-amount coupon — which one is required depends on type. Leave durationInMonths unset for a coupon that applies for the lifetime of the subscription; set it for a coupon that expires N calendar months after it is applied.