Create a discount code
Set at most one of percentOff and amountOffMinor. Set neither and the code carries no discount at all: the buyer pays full price and you still see who it brought in. A code with no discount cannot carry a name, because the code itself is its name. Terms are fixed once created: to change them, archive this code and create another. This route needs a signed-in owner or admin: an API key is refused with 403.
Authorizations
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
What the buyer types. Letters, numbers, dashes and underscores.
^[A-Za-z0-9_-]{1,64}$Your own label for the code, shown back to you on the single-code route. Not allowed on a code that carries no discount.
120Percentage off the first invoice. A code cannot take the whole price off — set up a free trial for that.
0.01 <= x <= 99Integer 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.
x >= 1x >= 1Must be in the future.
Limit the code to these products, one-time or subscription, in any mix. Leave it out for every product you own.
100Response
Discount code created.
Fully camelCase on the wire.
As you typed it. Buyers may type it in any case.
discount changes the price. tracking changes nothing and only records who used it.
discount, tracking 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.
The products this code works on, one-time or subscription. Empty means every product you own.
The names of those products, in the same order.