SellGate API

Coupons API

Create and manage discount coupons for your store

Coupons API

Create promotional coupons, set discounts, and manage coupon usage.

Endpoints Overview

MethodEndpointDescription
GET/v1/couponsList all coupons
POST/v1/couponsCreate a new coupon
GET/v1/coupons/:idGet coupon details
PATCH/v1/coupons/:idUpdate a coupon
DELETE/v1/coupons/:idDelete a coupon
POST/v1/coupons/validateValidate a coupon code

List Coupons

GET /v1/coupons

Response

{
  "data": [
    {
      "id": "cpn_abc123",
      "code": "SAVE20",
      "discount_type": "percentage",
      "discount_value": 20,
      "min_order_amount": 10.00,
      "max_uses": 100,
      "used_count": 45,
      "expires_at": "2025-12-31T23:59:59Z",
      "is_active": true,
      "is_global": true,
      "product_ids": [],
      "group_ids": [],
      "created_at": "2025-01-01T00:00:00Z",
      "updated_at": "2025-01-01T00:00:00Z"
    }
  ],
  "meta": {
    "total": 10,
    "limit": 25,
    "offset": 0
  }
}

Create Coupon

POST /v1/coupons

Request Body

FieldTypeRequiredDescription
codestringNoCoupon code (auto-generated if not provided)
discount_typestringNopercentage or fixed (default: percentage)
discount_valuenumberYesDiscount amount (must be > 0)
min_order_amountnumberNoMinimum order amount (default: 0)
max_usesintegerNoMaximum number of uses (null = unlimited)
expires_atstringNoExpiration date (ISO 8601)
is_globalbooleanNoApply to all products (default: true)
product_idsarrayNoLimit to specific product IDs
group_idsarrayNoLimit to specific group IDs

Example Request

curl -X POST "https://api.sellgate.cc/v1/coupons" \
  -H "Authorization: Bearer sg_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "SUMMER25",
    "discount_type": "percentage",
    "discount_value": 25,
    "max_uses": 500,
    "expires_at": "2025-08-31T23:59:59Z"
  }'

Response (201 Created)

{
  "data": {
    "id": "cpn_new123",
    "code": "SUMMER25",
    "discount_type": "percentage",
    "discount_value": 25,
    "min_order_amount": 0,
    "max_uses": 500,
    "expires_at": "2025-08-31T23:59:59Z",
    "is_global": true,
    "created_at": "2025-01-20T10:00:00Z"
  }
}

Update Coupon

PATCH /v1/coupons/:id

All fields are optional.

Example Request

curl -X PATCH "https://api.sellgate.cc/v1/coupons/cpn_abc123" \
  -H "Authorization: Bearer sg_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "is_active": false
  }'

Delete Coupon

DELETE /v1/coupons/:id

Validate Coupon

Check if a coupon code is valid and calculate the discount amount.

POST /v1/coupons/validate

Request Body

FieldTypeRequiredDescription
codestringYesCoupon code to validate
product_idstringNoProduct ID to check coupon eligibility
order_amountnumberNoOrder amount to calculate discount

Example Request

curl -X POST "https://api.sellgate.cc/v1/coupons/validate" \
  -H "Authorization: Bearer sg_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "SAVE20",
    "order_amount": 50.00
  }'

Response (Valid Coupon)

{
  "valid": true,
  "coupon": {
    "id": "cpn_abc123",
    "code": "SAVE20",
    "discount_type": "percentage",
    "discount_value": 20,
    "min_order_amount": 10.00,
    "discount_amount": 10.00
  }
}

Response (Invalid Coupon)

{
  "valid": false,
  "error": "Coupon has expired"
}

Discount Types

TypeDescription
percentagePercentage discount (e.g., 20 = 20% off)
fixedFixed amount discount (e.g., 5 = $5 off)

Coupon Targeting

Coupons can be scoped to specific products or groups:

  • Global (is_global: true): Applies to all products
  • Product-specific: Set product_ids array
  • Group-specific: Set group_ids array

If both product_ids and group_ids are set, the coupon applies to products in either list.

On this page