Skip to main content
POST
Create a discount code
Needs a signed-in owner or admin. An API key is refused with 403: create and stop codes in the dashboard, under Discounts.
Webhook: none. A discount code moves no money until a buyer uses it at checkout. See Which action fires which event.

Authorizations

x-api-key
string
header
required

Your secret key, from app.agentaos.ai -> Settings -> Developers -> API Keys. The key's prefix is both its identity and its environment: sk_test_... (sandbox, free, no verification) or sk_live_... (real money, requires business verification). A missing or invalid key returns 401.

Body

application/json
code
string
required

What the buyer types. Letters, numbers, dashes and underscores.

Pattern: ^[A-Za-z0-9_-]{1,64}$
name
string

Your own label for the code, shown back to you on the single-code route. Not allowed on a code that carries no discount.

Maximum string length: 120
percentOff
number

Percentage off the first invoice. A code cannot take the whole price off — set up a free trial for that.

Required range: 0.01 <= x <= 99
amountOffMinor
integer

Integer minor units. The currency is the one the products in productIds share (they must all use one), or your settlement currency when the code works on every product. It comes off the total the buyer pays, VAT included.

Required range: x >= 1
maxRedemptions
integer
Required range: x >= 1
expiresAt
string<date-time>

Must be in the future.

productIds
string<uuid>[]

Limit the code to these products, one-time or subscription, in any mix. Leave it out for every product you own.

Maximum array length: 100

Response

Discount code created.

Fully camelCase on the wire.

id
string<uuid>
required
code
string
required

As you typed it. Buyers may type it in any case.

kind
enum<string>
required

discount changes the price. tracking changes nothing and only records who used it.

Available options:
discount,
tracking
archivedAt
string<date-time> | null
required
createdAt
string<date-time>
required
active
boolean
required

Usable as far as this list can tell: not archived, and fully created. Whether the code has since been used up is answered by the single-code route.

productIds
string<uuid>[]
required

The products this code works on, one-time or subscription. Empty means every product you own.

productNames
string[]
required

The names of those products, in the same order.