Skip to main content
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 1
curl --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

X-API-KEY
string
header
required

Server API Key

Headers

X-ACCOUNT-ID
string

Account ID — optional when authenticating with a user JWT (Bearer token); falls back to the user's first membership. Ignored for API-key auth.

X-ENVIRONMENT-ID
string

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

application/json

Create a coupon with percentage or fixed-amount discount.

id
string
required

The unique identifier for the entity

Required string length: 1 - 255
Pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
name
string
required

Name of the coupon

Maximum string length: 40
description
string | null
required

Description of the coupon

Maximum string length: 255
percentOff
number | null
required

Percentage discount off the original price

Required range: 1 <= x <= 100
amountsOff
Money · object[] | null
required

Fixed amount discounts in different currencies

Minimum array length: 1
durationInMonths
integer | null
required

Duration of the coupon validity in months

Required range: x >= 1
metadata
object | null
required

Metadata associated with the entity

Response

The newly created coupon object.

Response object

data
Coupon · object
required

Discount instrument with percentage or fixed amount