API and webhooks
Discounts
Manage discount codes from your own system. Codes are matched by code, so sending the same code again updates it. The dashboard's version of this is Coupons.
Example
20% off the first three months, for the first 100 buyers, until the end of the year:
curl -X POST https://admin.plandalf.dev/api/v1/discounts \
-H "Authorization: Bearer $PLANDALF_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "WELCOME20",
"name": "Welcome 20%",
"discount_type": "percent",
"percent_off": 20,
"frequency": "recurring",
"frequency_duration": 3,
"usage_limit": 100,
"expires_at": "2026-12-31T23:59:59Z"
}'
A fixed discount takes amount_off_cents and currency instead of percent_off. Turning a code off with DELETE keeps its record and past redemptions.
Endpoints
Create or update a discount code
POST /api/v1/discounts
Upserts by code. percent discounts need percent_off; fixed discounts need
amount_off_cents and usually currency. recurring discounts need frequency_duration
(the number of billing periods). expires_at makes the code stop working after that time.
A missing cross-field value returns 422 with {"error": "…"}.
Body
| Field | Type | What it is |
|---|---|---|
code | string | |
name | string | |
discount_type | "percent" | "fixed" | |
percent_off optional | number | null | |
amount_off_cents optional | integer | null | |
currency optional | string | null | |
frequency | "once" | "recurring" | "forever" | |
frequency_duration optional | integer | null | |
expires_at optional | string | null | |
usage_limit optional | integer | null | |
reusable optional | boolean | null | |
min_amount_cents optional | integer | null | |
limited_product_ids optional | array | null | |
limited_price_ids optional | array | null | |
external_ref optional | string | null |
curl -X POST https://admin.plandalf.dev/api/v1/discounts \
-H "Authorization: Bearer $PLANDALF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"code":"string","name":"string","discount_type":"percent","percent_off":0,"amount_off_cents":0,"currency":"string","frequency":"once","frequency_duration":0,"expires_at":"string","usage_limit":0,"reusable":true,"min_amount_cents":0,"limited_product_ids":null,"limited_price_ids":null,"external_ref":"string"}'
Response
{
"id": "string",
"uuid": "string",
"code": "string",
"name": "string",
"discount_type": "string",
"percent_off": "string",
"amount_off_cents": "string",
"frequency": "string",
"frequency_duration": "string",
"status": "string",
"created_at": "string"
}
Errors
| Status | When |
|---|---|
401 | The API key or OAuth token is missing or invalid. |
422 | The request failed validation; errors lists the problems by field. |
Deactivate a discount code
DELETE /api/v1/discounts/{code}
Marks the code terminated so it can no longer be redeemed. The record is kept.
Returns 404 with {"error": "Discount not found"} for an unknown code.
Parameters
| Name | In | Type | What it is |
|---|---|---|---|
code | path | string |
curl -X DELETE https://admin.plandalf.dev/api/v1/discounts/:code \
-H "Authorization: Bearer $PLANDALF_API_KEY"
Response
{
"ok": true
}
Errors
| Status | When |
|---|---|
401 | The API key or OAuth token is missing or invalid. |
404 | Nothing with that id or code exists in this organization. |