PlandalfDocsSign inStart free trial

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

FieldTypeWhat it is
codestring
namestring
discount_type"percent" | "fixed"
percent_off optionalnumber | null
amount_off_cents optionalinteger | null
currency optionalstring | null
frequency"once" | "recurring" | "forever"
frequency_duration optionalinteger | null
expires_at optionalstring | null
usage_limit optionalinteger | null
reusable optionalboolean | null
min_amount_cents optionalinteger | null
limited_product_ids optionalarray | null
limited_price_ids optionalarray | null
external_ref optionalstring | 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

StatusWhen
401The API key or OAuth token is missing or invalid.
422The 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

NameInTypeWhat it is
codepathstring
curl -X DELETE https://admin.plandalf.dev/api/v1/discounts/:code \
  -H "Authorization: Bearer $PLANDALF_API_KEY"

Response

{
  "ok": true
}

Errors

StatusWhen
401The API key or OAuth token is missing or invalid.
404Nothing with that id or code exists in this organization.