Saltar para o conteúdo principal
POST
/
public
/
api
/
v1
/
billing
/
coupons
Create coupon
curl --request POST \
  --url https://api.gennia.ai/public/api/v1/billing/coupons \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --data '
{
  "discountValue": 10,
  "applicablePlanIds": [
    "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  ],
  "code": "WELCOME10",
  "durationMonths": 3,
  "maxUses": 100,
  "name": "Welcome 10% off",
  "validFrom": "2026-06-01T00:00:00Z",
  "validUntil": "2026-12-31T23:59:59Z"
}
'
{
  "active": true,
  "applicablePlans": [
    {
      "billingIntervalMonths": 123,
      "creditsIncluded": 123,
      "currency": "<string>",
      "name": "<string>",
      "priceCents": 123,
      "publicId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
    }
  ],
  "code": "<string>",
  "createdAt": "2023-11-07T05:31:56Z",
  "currency": "<string>",
  "discountValue": 123,
  "durationMonths": 123,
  "isExhausted": true,
  "isExpired": true,
  "maxUses": 123,
  "name": "<string>",
  "publicId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "stripeCouponId": "<string>",
  "stripePromotionCodeId": "<string>",
  "timesUsed": 123,
  "updatedAt": "2023-11-07T05:31:56Z",
  "validFrom": "2023-11-07T05:31:56Z",
  "validUntil": "2023-11-07T05:31:56Z"
}

Autorizações

X-Api-Key
string
header
obrigatório

Corpo

application/json

Body for creating a new discount coupon.

discountType
enum<string>
obrigatório

Discount type (percentage or fixed amount).

Opções disponíveis:
percentage,
fixed_amount
discountValue
integer<int32>
obrigatório

Discount amount. For PERCENTAGE: 1..100. For FIXED_AMOUNT: amount in the smallest currency unit (cents).

Intervalo necessário: x >= 1
Exemplo:

10

duration
enum<string>
obrigatório

How the discount is applied across billing cycles.

Opções disponíveis:
once,
repeating,
forever
scope
enum<string>
obrigatório

Whether the coupon applies to all plans or a specific list.

Opções disponíveis:
hub,
plans
applicablePlanIds
string<uuid>[]

Required when scope = SPECIFIC. Plan public IDs the coupon applies to.

code
string

Public coupon code shared with customers. Letters, numbers and underscores only.

Required string length: 3 - 50
Pattern: ^[A-Za-z0-9_]+$
Exemplo:

"WELCOME10"

durationMonths
integer<int32>

Required when duration = REPEATING. Number of months the discount lasts (1..36).

Intervalo necessário: 1 <= x <= 36
Exemplo:

3

maxUses
integer<int32>

Maximum total redemptions of this coupon. Omit for unlimited.

Intervalo necessário: x >= 1
Exemplo:

100

name
string

Optional internal display name for the coupon.

Maximum string length: 100
Exemplo:

"Welcome 10% off"

validFrom
string<date-time>

Start of the validity window. Defaults to now when omitted.

Exemplo:

"2026-06-01T00:00:00Z"

validUntil
string<date-time>

End of the validity window. Must be in the future when provided.

Exemplo:

"2026-12-31T23:59:59Z"

Resposta

Created

active
boolean
applicablePlans
object[]
code
string
createdAt
string<date-time>
currency
string
discountType
enum<string>
Opções disponíveis:
percentage,
fixed_amount
discountValue
integer<int32>
duration
enum<string>
Opções disponíveis:
once,
repeating,
forever
durationMonths
integer<int32>
isExhausted
boolean
isExpired
boolean
maxUses
integer<int32>
name
string
publicId
string<uuid>
scope
enum<string>
Opções disponíveis:
hub,
plans
stripeCouponId
string
stripePromotionCodeId
string
timesUsed
integer<int32>
updatedAt
string<date-time>
validFrom
string<date-time>
validUntil
string<date-time>