SeloraXDEVELOPERS

Discounts

Discounts API

Manage discount codes and coupons for the authenticated store. Supports both percentage-based and fixed-amount discounts with optional expiry dates, usage limits, and minimum order values.

List Discounts

Retrieve a paginated list of discount codes.

GET /api/apps/v1/discounts

Scope

read:discounts

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger50Items per page (max 250)
is_activeinteger--Filter by status: 1 for active, 0 for inactive
searchstring--Search by discount code

Example Request

curl -X GET "https://api.selorax.io/api/apps/v1/discounts?is_active=1&limit=20" \
  -H "Authorization: Bearer <token>"

Response

{
  "data": [
    {
      "discount_id": 5,
      "store_id": 22,
      "code": "SUMMER20",
      "is_amount": 0,
      "amount": 0,
      "percentage": 20,
      "free_shipping_on": 0,
      "minimum_order_value": 500,
      "maximum_discount_amount": 200,
      "is_active": 1,
      "total_use": 100,
      "use_per_user": 1,
      "starts_at": "2025-06-01T00:00:00.000Z",
      "ends_at": "2025-08-31T23:59:59.000Z",
      "created_at": "2025-05-28T10:00:00.000Z",
      "updated_at": "2025-05-28T10:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 1
  },
  "status": 200
}

Response Fields

FieldTypeDescription
discount_idintegerUnique discount identifier
codestringDiscount code (uppercase)
is_amountinteger0 = percentage discount, 1 = fixed amount
amountnumberFixed discount amount (when is_amount = 1)
percentagenumberPercentage off (when is_amount = 0)
free_shipping_oninteger1 if free shipping is included
minimum_order_valuenumber or nullMinimum cart total to apply
maximum_discount_amountnumber or nullCap on percentage discount
is_activeinteger1 = active, 0 = inactive
total_useinteger or nullMaximum total uses (null = unlimited)
use_per_userinteger or nullMaximum uses per customer
starts_atstring or nullStart date (ISO 8601)
ends_atstring or nullExpiry date (ISO 8601)

Get Discount

Retrieve a single discount by ID.

GET /api/apps/v1/discounts/:discount_id

Scope

read:discounts


Create Discount

Create a new discount code.

POST /api/apps/v1/discounts

Scope

write:discounts

Request Body

FieldTypeRequiredDescription
codestringYesDiscount code (auto-uppercased, unique per store)
is_amountintegerNo0 = percentage (default), 1 = fixed amount
amountnumberConditionalRequired when is_amount = 1
percentagenumberConditionalRequired when is_amount = 0
free_shipping_onintegerNo1 to include free shipping
minimum_order_valuenumberNoMinimum order value to apply
maximum_discount_amountnumberNoMaximum discount cap
is_activeintegerNo1 = active (default), 0 = inactive
total_useintegerNoMax total uses
use_per_userintegerNoMax uses per customer
starts_atstringNoStart date (ISO 8601)
ends_atstringNoExpiry date (ISO 8601)

Example — Percentage Discount

curl -X POST "https://api.selorax.io/api/apps/v1/discounts" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "SUMMER20",
    "is_amount": 0,
    "percentage": 20,
    "minimum_order_value": 500,
    "maximum_discount_amount": 200,
    "total_use": 100,
    "use_per_user": 1,
    "starts_at": "2025-06-01T00:00:00Z",
    "ends_at": "2025-08-31T23:59:59Z"
  }'

Example — Fixed Amount Discount

curl -X POST "https://api.selorax.io/api/apps/v1/discounts" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "FLAT100",
    "is_amount": 1,
    "amount": 100,
    "minimum_order_value": 1000,
    "is_active": 1
  }'

Response (201)

Returns the full discount object.

Error Responses

StatusMeaning
400Missing required fields
409Discount code already exists

Update Discount

Update a discount's fields. Only provided fields are updated.

PUT /api/apps/v1/discounts/:discount_id

Scope

write:discounts

Request Body

Same fields as Create Discount, all optional.

Example Request

curl -X PUT "https://api.selorax.io/api/apps/v1/discounts/5" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "percentage": 25,
    "ends_at": "2025-09-30T23:59:59Z"
  }'

Delete Discount

Permanently delete a discount code.

DELETE /api/apps/v1/discounts/:discount_id

Scope

write:discounts


Validate Discount Code

Check if a discount code is valid (active, within date range).

GET /api/apps/v1/discounts/validate/:code

Scope

read:discounts

Example Request

curl -X GET "https://api.selorax.io/api/apps/v1/discounts/validate/SUMMER20" \
  -H "Authorization: Bearer <token>"

Response

{
  "data": {
    "discount_id": 5,
    "code": "SUMMER20",
    "is_amount": 0,
    "percentage": 20,
    "minimum_order_value": 500,
    "maximum_discount_amount": 200,
    "is_active": 1,
    "starts_at": "2025-06-01T00:00:00.000Z",
    "ends_at": "2025-08-31T23:59:59.000Z"
  },
  "valid": true,
  "issues": [],
  "status": 200
}

If the code is invalid:

{
  "data": { ... },
  "valid": false,
  "issues": ["Discount has expired."],
  "status": 200
}

Possible issues:

  • "Discount is inactive."
  • "Discount has not started yet."
  • "Discount has expired."