Skip to content
PharmaFlow Knowledgebase
Esc
↑↓navigate↵open⌘Jpreview

Create a coupon

Admin or branch manager only. Registers a coupon the register can apply at checkout. Codes are uppercased; duplicates 409, and a percentage over 100 or non-positive value 400.

POST/api/v1/coupons
Authorization
AuthorizationBearer token (JWT) · headerrequired

JWT from POST /api/v1/auth/login sent as Authorization Bearer.

Request body
requiredapplication/json
codestringrequired
min length 1
typestring
default: "promotional"
discount_typestringrequired
discount_valuenumberrequired
descriptionstring
default: ""
valid_fromstring | null
valid_untilstring | null
max_usesinteger | null
Show properties
Any of:
integer
integer
null
null
Responses
201

Coupon registered

idstringrequired
codestringrequired
typestringrequired
discount_typestringrequired
discount_valuenumberrequired
is_activebooleanrequired
usage_countintegerrequired
min -9007199254740991 · max 9007199254740991
400

The code is empty, discount_type is neither percentage nor fixed, the value is not positive, or a percentage is above 100

detailstringrequired
401

Not authenticated

detailstringrequired
403

Caller is not an admin or branch manager

detailstringrequired
409

A coupon with that code already exists

detailstringrequired
Try it
Server
Authorization
Bodyapplication/json
Request
curl -X POST 'http://localhost:8000/api/v1/coupons' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "code": "string",
  "type": "promotional",
  "discount_type": "string",
  "discount_value": 0,
  "description": "",
  "valid_from": "string",
  "valid_until": "string",
  "max_uses": -9007199254740991
}'
Response
{
  "id": "string",
  "code": "string",
  "type": "string",
  "discount_type": "string",
  "discount_value": 0,
  "is_active": true,
  "usage_count": -9007199254740991
}