Coupons
Coupons allow you to offer customers customizable coupon codes/discounts that can be applied during checkout.
The Coupon object
The coupon object contains all the information about a coupon.
Properties
- Name
- id
- Type
- string
- Description
- Unique identifier for the coupon. 
 
- Name
- code
- Type
- string
- Description
- The coupon code used by the customer to apply the coupon during checkout. 
 
- Name
- product_ids
- Type
- array
- Description
- The product IDs that the coupon can be used on. Can be - all_productsif all products are applicable.
 
- Name
- discount_type
- Type
- enum
- Description
- percentage
- amount
 
 
- Name
- discount_percentage
- Type
- integer
- Description
- The discount percentage if the - discount_typeis- percentage.
 
- Name
- discount_amount
- Type
- integer
- Description
- The discount amount used if the - discount_typeis- amount.
 
- Name
- discount_currency
- Type
- integer
- Description
- The currency used for the - discount_amountif the- discount_typeis- amount.
 
- Name
- created_at
- Type
- timestamp
- Description
- Timestamp of when the coupon was created. 
 
- Name
- updated_at
- Type
- timestamp
- Description
- Timestamp of when the coupon was last updated. 
 
List all coupons
This endpoint allows you to retrieve a paginated list of all your coupons. By default, a maximum of 20 coupons are shown per page.
Optional attributes
- Name
- page
- Type
- integer
- Description
- The page number. Defaults to 1 
 
- Name
- per_page
- Type
- integer
- Description
- Records per page. Defaults to 20. 
 
Request
curl -G https://selly.io/api/v2/coupons \
  -H "Authorization: Bearer {token}" \
  -d page=1
Response
[
  {
    "id": "z1vkhnw0",
    "product_ids": [
        "all_products"
    ],
    "code": "example",
    "discount_type": "percentage",
    "discount_percentage": 10,
    "discount_amount": null,
    "discount_currency": "USD",
    "max_use": null,
    "uses": 0,
    "created_at": "2023-12-19T20:12:59.000+00:00",
    "updated_at": "2023-12-21T13:20:13.000+00:00"
  },
  {
    "id": "5w8QhZqx",
    // ...
  }
]
Retrieve a coupon
This endpoint allows you to retrieve a coupon by providing the coupon id. Refer to the list at the top of this page to see which properties are included with coupon objects.
Request
curl https://selly.io/api/v2/coupons/z1vkhnw0 \
  -H "Authorization: Bearer {token}"
Response
{
  "id": "z1vkhnw0",
  "product_ids": [
      "all_products"
  ],
  "code": "example",
  "discount_type": "percentage",
  "discount_percentage": 10,
  "discount_amount": null,
  "discount_currency": "USD",
  "max_use": null,
  "uses": 0,
  "created_at": "2023-12-19T20:12:59.000+00:00",
  "updated_at": "2023-12-21T13:20:13.000+00:00"
}
Create a coupon
This endpoint allows you to create a coupon.
Request
curl -X POST https://selly.io/api/v2/coupons \
  -H "Authorization: Bearer {token}" \
  -d discount_type="percentage" \
  -d discount_percentage="10" \
  -d product_ids[0]="all_products"
Response
{
  "id": "z1vkhnw0",
  "product_ids": [
      "all_products"
  ],
  "code": "example",
  "discount_type": "percentage",
  "discount_percentage": 10,
  "discount_amount": null,
  "discount_currency": "USD",
  "max_use": null,
  "uses": 0,
  "created_at": "2023-12-19T20:12:59.000+00:00",
  "updated_at": "2023-12-21T13:20:13.000+00:00"
}
Update a coupon
This endpoint allows you to update a coupon.
Request
curl -X PUT https://selly.io/api/v2/coupons/z1vkhnw0 \
  -H "Authorization: Bearer {token}" \
  -d discount_percentage="24"
Response
{
  "id": "z1vkhnw0",
  "product_ids": [
      "all_products"
  ],
  "code": "example",
  "discount_type": "percentage",
  "discount_percentage": 24,
  "discount_amount": null,
  "discount_currency": "USD",
  "max_use": null,
  "uses": 0,
  "created_at": "2023-12-19T20:12:59.000+00:00",
  "updated_at": "2023-12-22T13:20:13.000+00:00"
}
Delete a coupon
This endpoint allows you to delete a coupon. Note: This will permanently delete the coupon.
Request
curl -X DELETE https://selly.io/api/v2/coupons/z1vkhnw0 \
  -H "Authorization: Bearer {token}" \