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>",
"percentOff": 50,
"amountsOff": [
{
"amount": 123
}
],
"billingId": "<string>",
"billingLinkUrl": "<string>",
"durationInMonths": 2,
"metadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Create coupon
Creates a new discount coupon with percentage or fixed amount off, applicable to customer subscriptions.
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>",
"percentOff": 50,
"amountsOff": [
{
"amount": 123
}
],
"billingId": "<string>",
"billingLinkUrl": "<string>",
"durationInMonths": 2,
"metadata": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>"
}{
"message": "<string>",
"code": "Unauthenticated"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "RateLimitExceeded"
}Authorizations
Server API Key
Headers
Account ID — optional when authenticating with a user JWT (Bearer token); falls back to the user's first membership. Ignored for API-key auth.
Environment ID — required when authenticating with a user JWT (Bearer token) on environment-scoped endpoints. Ignored for API-key auth (env is intrinsic to the key).
Body
Create a coupon with percentage or fixed-amount discount.
The unique identifier for the entity
1 - 255^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$Name of the coupon
40Description of the coupon
255Percentage discount off the original price
1 <= x <= 100Fixed amount discounts in different currencies
1Show child attributes
Show child attributes
Duration of the coupon validity in months
x >= 1Metadata associated with the entity
Show child attributes
Show child attributes
Response
The newly created coupon object.
Response object
Discount instrument with percentage or fixed amount
Show child attributes
Show child attributes
