Discount coupons can be either import-based (codes are manually uploaded) or API-based (codes are generated on-demand).
To generate discount coupons from your website via API, your website needs to provide a webhook URL that:
- Receives multiple GET parameters;
- Generates unique (single-use) codes on your website based on the provided parameters.
The mandatory GET parameters that can be specified are:
- type – INT – The type of discount generated by the coupon, which can be 0 (fixed value), 1 (percentage), or 2 (free shipping).
- value – INT | FLOAT – Appears for percentage or fixed value types. If
type
is 1 (percentage), it contains the discount percentage; otherwise, it contains the fixed value.
Optionally, the following parameters can also be specified:
- batch_size – INT – The number of codes that should be generated by the webhook URL (optional but recommended). Codes can be generated in batches to reduce the number of requests. A single code can still be returned even if this parameter is specified.
- prefix – STRING – The prefix that should be added at the beginning of the codes.
- expire_date – STRING – The expiration date in the format YYYY-MM-DD HH:MM for the codes.
- min_amount – FLOAT – The minimum cart value required to apply the coupon (if specified, it should be based on the amount without VAT).
- currency – STRING – Can be RON or EUR (used when specifying a fixed discount value or minimum order amount).
The returned response can be a string (containing the generated code if a single code was created) or an array (list of codes) in JSON format, containing the following keys:
- status – 0 (for error) or 1 (for success).
- codes – An array containing the generated codes (in case of success).
- msg – The error message (in case of error).