Skip to main content
POST

Authorizations

Authorization
string
header
required

YuvexPay API key. Include as Authorization: Bearer ypk_<env>_<kid>_<secret> where <env> is test (sandbox) or live (production). Create and manage keys in the dashboard under Settings > API Keys.

Headers

X-Idempotency-Key
string

Optional on this endpoint. When sent, a 2xx response is stored for 24 hours and replayed for a retry with the same key and body.

Maximum string length: 100

Body

application/json
code
string
required

3 to 32 characters from A-Z, 0-9, _ and -, after trimming. Stored uppercase, so black10 is saved as BLACK10. Unique among the coupons of your account in this environment that are not deleted (409 COUPON_CODE_TAKEN).

type
enum<string>
required

PERCENT requires percentBp and FIXED requires amount; sending the other field, or neither, returns 400 COUPON_VALUE_INVALID.

Available options:
PERCENT,
FIXED
percentBp
integer

PERCENT only: the discount in basis points, 1 to 10000 (10000 is 100%).

Required range: 1 <= x <= 10000
amount
number

FIXED only: the discount in BRL, at most 2 decimal places.

Required range: x <= 1000000
validFrom
string<date-time> | null

ISO 8601 date-time with an offset or Z. Inclusive.

validUntil
string<date-time> | null

ISO 8601 date-time with an offset or Z. Exclusive. Must be after validFrom (400 COUPON_WINDOW_INVALID).

maxRedemptions
integer | null

Total uses, counting payments holding the coupon and completed ones. Omitted or null: no limit.

Required range: 1 <= x <= 1000000
maxRedemptionsPerBuyer
integer | null

Uses per payer e-mail, checked when the e-mail is known. Omitted or null: no limit.

Required range: 1 <= x <= 1000000
productIds
string<uuid>[]

Products of your account in this environment that the discount covers (400 COUPON_PRODUCT_NOT_FOUND otherwise). Empty: the whole order.

Maximum array length: 100
active
boolean
default:true

Response

Coupon created.

coupon
object
required