Skip to content

Create Coupon

POST
/api/v1/admin/coupons

Create a coupon.

The code is normalized to UPPERCASE by the request schema, so the UNIQUE constraint sees the same form every redemption path looks up.

Args: body: Validated coupon definition. user: The authenticated platform operator (injected). session: Database session.

Returns: The created coupon.

Raises: HTTPException 409: A coupon with this code already exists.

Authorizations

Request Body required

POST /api/v1/admin/coupons request body.

object
active
boolean
default: true
bonus_credits

Extra credits granted on top of the plan allowance.

integer
code
required

Coupon code. Normalized to UPPERCASE before storage.

string
>= 3 characters <= 50 characters
description
Any of:
string
<= 2000 characters
discount_type

‘percent’ (0..100) or ‘fixed_amount’ (cents off).

string
default: percent
Allowed values: percent fixed_amount
discount_value
required

0..100 when discount_type is ‘percent’, else cents.

integer
duration

Stripe-compatible discount duration.

string
default: once
Allowed values: once forever repeating
duration_months
Any of:
integer
>= 1
expires_at
Any of:
string format: date-time
max_redemptions
Any of:
integer
>= 1
plan_grant
Any of:
string
Allowed values: starter professional business

Responses

201

Successful Response

The canonical coupon JSON shape returned by every coupon endpoint.

object
active
required
boolean
bonus_credits
required
integer
code
required
string
created_at
required
string format: date-time
created_by
required
Any of:
string
description
required
Any of:
string
discount_type
required
string
discount_value
required
integer
duration
required
string
duration_months
required
Any of:
integer
expires_at
required
Any of:
string format: date-time
id
required
string format: uuid
max_redemptions
required
Any of:
integer
plan_grant
required
Any of:
string
times_redeemed
required
integer

422

Validation Error

object
detail
Array<object>
object
ctx
object
input
loc
required
Array
msg
required
string
type
required
string