Overview
Coupons allow you to create promotional discount codes that clients can apply during checkout. Each coupon can have usage limits, validity periods, and minimum purchase requirements.Discount Types
- percentage: Discount as a percentage of the purchase amount (e.g., 20% off)
- fixed: Fixed amount discount (e.g., €10 off)
List Coupons
Search coupons by code or description
Unique identifier for the coupon (UUID)
Unique coupon code that clients use at checkout
Internal description of the coupon purpose
Type of discount:
percentage or fixedDiscount amount (percentage value or fixed amount in currency)
Minimum purchase amount required to use the coupon
Maximum number of times this coupon can be used (null for unlimited)
Number of times the coupon has been used
Start date for coupon validity
Expiration date for the coupon
Coupon status:
activo (active) or inactivo (inactive)Timestamp when the coupon was created
Timestamp when the coupon was last updated
Create Coupon
Request Body
Unique coupon code (must be unique across all coupons)
Description of the coupon for internal reference
Discount type:
percentage or fixedDiscount value (0-100 for percentage, any positive number for fixed)
Minimum purchase amount required
Maximum uses allowed (omit for unlimited)
When the coupon becomes valid (ISO 8601 format)
When the coupon expires (ISO 8601 format)
Initial status:
activo or inactivoResponse
Returns the created coupon object with all fields including generatedcoupon_id.
Get Coupon
Retrieve a specific coupon by ID.Path Parameters
The unique identifier of the coupon
Response
Returns the complete coupon object.Error Responses
HTTP status code
400: Coupon ID is required404: Coupon not found
Error message describing the issue
Update Coupon
Update an existing coupon’s properties.Path Parameters
The unique identifier of the coupon to update
Request Body
All fields are optional. Only include the fields you want to update.Update the coupon code (must remain unique)
Update the description
Change discount type
Change discount value
Update minimum purchase requirement
Update maximum uses (set to null for unlimited)
Update validity start date
Update expiration date
Update status
Response
Returns the updated coupon object.Delete Coupon
Permanently delete a coupon.Path Parameters
The unique identifier of the coupon to delete
Response
Returns
true if the deletion was successfulValidation Rules
Code Uniqueness
Thecode field must be unique across all coupons. Attempting to create a coupon with a duplicate code will result in an error.
Discount Value Validation
- For
percentagediscount type: Value should be between 0 and 100 - For
fixeddiscount type: Value should be a positive number
Usage Tracking
current_usesis automatically incremented when a coupon is applied to a cart- When
current_usesreachesmax_uses, the coupon should no longer be accepted - This counter is read-only and managed by the system
Date Validation
valid_frommust be beforevalid_until- Coupons can only be used between these dates
- If
valid_fromis not set, the coupon is valid immediately - If
valid_untilis not set, the coupon never expires
Status Management
- Only coupons with status
activocan be used at checkout - Setting status to
inactivoimmediately disables the coupon - This allows temporary deactivation without deleting the coupon
Business Logic
Minimum Purchase Requirement
Whenmin_purchase is set, the cart subtotal must meet or exceed this amount for the coupon to be valid.
Maximum Uses
Themax_uses field limits how many times a coupon can be applied across all transactions. This is useful for limited-time promotions.
Percentage vs Fixed Discounts
- Percentage: Applied as
subtotal * (discount_value / 100) - Fixed: Applied as direct reduction up to the cart subtotal (never negative)
Cart Integration
Coupons are applied during checkout via the Cart API:applied_coupon field of the Cart model, and the discount is reflected in the cart’s discount and total fields.