Discount code management requires admin permission. The
/validate endpoint requires read permission, making it safe to call from client-side checkout flows.Authentication
https://platform-api.anyspend.com/api/v1
Endpoints
List Discount Codes
List all discount codes with optional filtering and pagination.
string
Search by code string (case-insensitive partial match).
boolean
Filter by active status. Omit to return all codes.
number
Page number for pagination (default:
1).number
Results per page (default:
20, max: 100).- cURL
- SDK
Create Discount Code
Create a single discount code.
The discount code string (e.g.,
SUMMER25). Must be unique. Automatically uppercased.Discount type:
percentage or fixed.Discount value. For
percentage, a number between 1-100. For fixed, the amount in the token’s smallest unit (e.g., 5000000 for 5 USDC).Restrict this code to a specific payment link. If omitted, the code works on all payment links.
Maximum number of times this code can be redeemed. Omit for unlimited uses.
Minimum order amount required to use this code, in the token’s smallest unit.
ISO 8601 expiration timestamp. Omit for a code that never expires.
- cURL
- SDK
Update Discount Code
Update an existing discount code. All fields are optional.
- cURL
- SDK
Delete Discount Code
Permanently delete a discount code. Active sessions using this code will not be affected.
- cURL
- SDK
Validate Discount Code
Validate a discount code against a payment link and order amount. Returns the discount details if valid, or an error message explaining why the code is invalid.
The discount code to validate.
The payment link the code is being applied to.
The order amount in the token’s smallest unit, used to check
min_order_amount and calculate the discounted total.- cURL
- SDK
The validate endpoint does not consume a use. Uses are only counted when a payment is completed with the discount applied.
Batch Create Discount Codes
Bulk-create multiple discount codes at once with shared configuration. Useful for generating promotional campaigns or unique single-use codes.
Array of code strings to create. Each must be unique.
Discount type applied to all codes:
percentage or fixed.Discount value applied to all codes.
Restrict all codes to a specific payment link.
Maximum uses per code. Set to
1 for single-use codes.Minimum order amount for all codes.
ISO 8601 expiration timestamp for all codes.
- cURL
- SDK
Discount Code Object
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier (e.g., dc_abc123) |
code | string | The discount code string (uppercased) |
type | string | percentage or fixed |
value | number | Discount value (percentage 1-100, or fixed amount in smallest unit) |
payment_link_id | string | null | Restricted payment link, or null for all links |
max_uses | number | null | Maximum redemptions, or null for unlimited |
current_uses | number | Number of times redeemed so far |
min_order_amount | string | null | Minimum order amount required |
expires_at | string | null | ISO 8601 expiration, or null for no expiration |
is_active | boolean | Whether the code is currently usable |
created_at | string | ISO 8601 creation timestamp |
updated_at | string | ISO 8601 last update timestamp |
Validation Rules
A discount code is considered invalid if any of the following are true:| Condition | Error Message |
|---|---|
| Code does not exist | Invalid discount code |
Code is inactive (is_active: false) | Discount code is not active |
| Code has expired | Discount code has expired |
current_uses >= max_uses | Code has reached maximum number of uses |
| Code is restricted to a different payment link | Code is not valid for this payment link |
Order amount is below min_order_amount | Order amount is below minimum required |
HypeDuel