Skip to main content

Discount Codes

Discount codes reduce the price of a product at checkout, either by a percentage or by a fixed amount.

The discount code object​

AttributeTypeDescription
idintegerDiscount code ID. Used in the URL.
codestringThe code customers enter.
descriptionstringDescription.
typestringpercentage or numeric (a fixed amount).
valueintegerThe percentage, or the fixed amount, to take off.
usesinteger or nullRemaining uses. null or -1 means unlimited.
activebooleanWhether the code can be used.
expires_atstring or nullISO 8601 expiry date (time is always midnight), or null for no expiry.
created_at, updated_atstringISO 8601 timestamps.

List discount codes​

GET /api/application/billing/discount-codes

Admin permission: billing.discount-codes

Returns a paginated list of discount codes. Unless another sort is given, newest codes come first (created_at descending). When you pass sort, created_at descending is applied after it as a tie-breaker.

curl "https://panel.example.com/api/application/billing/discount-codes" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json"

Query parameters​

ParameterTypeRequiredDescription
per_pageintegerNoResults per page, 1 to 100. Default 20. See pagination.
pageintegerNoPage number.
filter[id], filter[code], filter[type], filter[expires_at]stringNoPartial match on the field. See filtering and sorting.
sortstringNoOne of id, code, value, type, uses, expires_at, created_at, optionally prefixed with -.

Response​

200 OK

{
"object": "list",
"data": [
{
"object": "discount_codes",
"attributes": {
"id": 1,
"code": "WINTER25",
"description": "25% off for winter",
"type": "percentage",
"value": 25,
"uses": 100,
"active": true,
"expires_at": "2027-01-31T00:00:00+00:00",
"created_at": "2026-11-26T14:20:00+00:00",
"updated_at": "2026-11-26T14:20:00+00:00"
}
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 20,
"current_page": 1,
"total_pages": 1,
"links": {}
}
}
}

Create a discount code​

POST /api/application/billing/discount-codes

Admin permission: billing.discount-codes

Creates a discount code.

Request body​

JSON body.

FieldTypeRequiredDescription
codestringYes4 to 16 characters. Codes are not required to be unique.
descriptionstringYesAt least 3 characters.
typestringYespercentage or numeric.
valueintegerYes0 or more.
usesintegerNo-1 or more. null or -1 means unlimited.
activebooleanYesWhether the code can be used.
expires_atstringNoA date the Panel can parse, for example 2027-01-31. Only the date is stored. Defaults to null (no expiry).

Response​

200 OK

{
"object": "discount_codes",
"attributes": {
"id": 2,
"code": "FIVEOFF",
"description": "5 off any plan",
"type": "numeric",
"value": 5,
"uses": null,
"active": true,
"expires_at": null,
"created_at": "2026-11-26T14:25:00+00:00",
"updated_at": "2026-11-26T14:25:00+00:00"
}
}

Logs the activity event admin:billing:discount-codes:create.

Update a discount code​

PATCH /api/application/billing/discount-codes/{discount_code}

Admin permission: billing.discount-codes

Updates a discount code. {discount_code} is the code's numeric id.

Request body​

The same fields and rules as Create a discount code. Although the method is PATCH, code, description, type, value and active are required on every request. If expires_at is left out, the expiry is cleared (set to null). If uses is left out, it is not changed.

Response​

200 OK. The updated discount code object, as in Create a discount code.

Logs the activity event admin:billing:discount-codes:update, with the request body as the new_data property.

Errors​

StatusWhen
404No discount code has this ID.

Delete a discount code​

DELETE /api/application/billing/discount-codes/{discount_code}

Admin permission: billing.discount-codes

Deletes a discount code. {discount_code} is the code's numeric id.

Response​

204 No Content

Logs the activity event admin:billing:discount-codes:delete.

Errors​

StatusWhen
404No discount code has this ID.