Skip to main content
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/coupons

List 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/coupons

Create a coupon

Create a new discount coupon. The coupon code must be unique within your store.

Request body

FieldTypeRequiredDescription
codestringYesUnique coupon code (e.g., “LAUNCH20”)
typestringYes“percentage” or “fixed”
valuenumberYesDiscount value (e.g., 20 for 20% or $20)
max_usesintegerNoMaximum number of times this coupon can be used. Null for unlimited.
product_idsstring[]NoRestrict to specific product IDs. Null applies to all.
min_order_amountnumberNoMinimum order total required to use this coupon.
expires_atISO 8601NoExpiration 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/:id

Delete 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
Was this page helpful?