API Reference/Coupons
Coupons API
Create and manage discount coupons for your store. Supports percentage and fixed-amount discounts with optional usage limits, product restrictions, and expiration dates.
GET
/v1/couponsList coupons
Returns all coupons for your store.
const res = await fetch("https://api.sellvy.io/v1/coupons", {
headers: { "Authorization": "Bearer sk_live_..." }
});
const { data } = await res.json();Response
json
{
"data": [
{
"id": "cpn_abc123",
"code": "LAUNCH20",
"type": "percentage",
"value": 20,
"max_uses": 100,
"times_used": 34,
"product_ids": null,
"min_order_amount": 10.00,
"expires_at": "2025-06-01T00:00:00Z",
"created_at": "2025-01-01T00:00:00Z"
}
]
}POST
/v1/couponsCreate a coupon
Create a new discount coupon. The coupon code must be unique within your store.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| code | string | Yes | Unique coupon code (e.g., “LAUNCH20”) |
| type | string | Yes | “percentage” or “fixed” |
| value | number | Yes | Discount value (e.g., 20 for 20% or $20) |
| max_uses | integer | No | Maximum number of times this coupon can be used. Null for unlimited. |
| product_ids | string[] | No | Restrict to specific product IDs. Null applies to all. |
| min_order_amount | number | No | Minimum order total required to use this coupon. |
| expires_at | ISO 8601 | No | Expiration date. Null for no expiration. |
const res = await fetch("https://api.sellvy.io/v1/coupons", {
method: "POST",
headers: {
"Authorization": "Bearer sk_live_...",
"Content-Type": "application/json"
},
body: JSON.stringify({
code: "SUMMER25",
type: "percentage",
value: 25,
max_uses: 500,
min_order_amount: 5.00,
expires_at: "2025-09-01T00:00:00Z"
})
});
const coupon = await res.json();
console.log(coupon.id); // "cpn_xyz789"DELETE
/v1/coupons/:idDelete a coupon
Permanently delete a coupon. Existing orders that used this coupon are not affected.
const res = await fetch("https://api.sellvy.io/v1/coupons/cpn_abc123", {
method: "DELETE",
headers: { "Authorization": "Bearer sk_live_..." }
});
// Returns 204 No Content on success