Discounts

Mint, read and archive discount codes, with an expiry and an owner.

Discount codes over the API. The dashboard has always had them; this lets an app or a server mint one: a loyalty reward, a referral, a make-good. A minted code can carry two things a dashboard code never needed: an expires_at, after which it is refused everywhere a code is checked, and a customer_id, after which it works for that customer’s email only and is silently ignored for anyone else. Codes are never edited; archive and mint another. An app sees and archives only the codes it created; a merchant key sees them all. Scoped keys need discounts:read / discounts:write. The hosted pay page accepts ?discount=CODE on its URL and applies it on load.

Create a discount code

Mint a code. Omit code to have one generated (unambiguous letters and digits, e.g. 7KQ2-M4XR, or PREFIX-7KQ2-M4XR with prefix). usage_limit defaults to 1: a minted code is single-use unless you say otherwise. Fixed amounts are in cents. Requires discounts:write on scoped keys.

POSThttps://paysio.com/api/v1/discounts

Authorizations

Authorizationstringheaderrequired

Secret key (sk_*) or app access token. Prepend your key with Bearer, e.g. Bearer sk_test_your_secret_key.

Body

typestring

"percentage" (default) or "fixed"

valueintegerrequired

Percent off (1-100) for percentage; amount off in cents for fixed. A code that brings the total to zero completes checkout as a free order: no card is collected, and payment.completed fires with amount 0

currencystring

For fixed amounts. Defaults to USD

codestring

Your own code, 3-40 characters of letters, digits and hyphens. Omit to mint one. 409 if it exists

prefixstring

Up to 8 letters or digits prepended to a minted code

usage_limitinteger

How many times it may be used. Default 1. null for unlimited

expires_atinteger

Unix timestamp. Refused after this, at validation and at payment

max_quantityinteger

Units the code may discount in one order. Null (default) discounts every unit; set 1 for one free or discounted item

customer_idstring

Only this customer may use it, matched by email at checkout

product_idsstring[]

Restrict the code to these products. Omit for the whole cart

List discount codes

Your codes, newest first. An app lists only the codes it minted. Filter by customer_id to find the codes issued to one buyer. Requires discounts:read on scoped keys.

GEThttps://paysio.com/api/v1/discounts

Authorizations

Authorizationstringheaderrequired

Any API key. Prepend your key with Bearer, e.g. Bearer sk_test_your_secret_key.

Query parameters

customer_idstring

Only codes issued to this customer

limitinteger

1-100, default 50

Retrieve a discount code

One code, with its usage_count. A transaction that used a code carries its discountId and discountCode, so a redemption can be matched back here.

GEThttps://paysio.com/api/v1/discounts/:id

Authorizations

Authorizationstringheaderrequired

Any API key. Prepend your key with Bearer, e.g. Bearer sk_test_your_secret_key.

Archive a discount code

The code stops working at once. The record stays, because transactions point at it. Requires discounts:write on scoped keys.

DELETEhttps://paysio.com/api/v1/discounts/:id

Authorizations

Authorizationstringheaderrequired

Secret key (sk_*) or app access token. Prepend your key with Bearer, e.g. Bearer sk_test_your_secret_key.