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_products if all products are applicable.

  • Name
    discount_type
    Type
    enum
    Description
    • percentage
    • amount
  • Name
    discount_percentage
    Type
    integer
    Description

    The discount percentage if the discount_type is percentage.

  • Name
    discount_amount
    Type
    integer
    Description

    The discount amount used if the discount_type is amount.

  • Name
    discount_currency
    Type
    integer
    Description

    The currency used for the discount_amount if the discount_type is 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.


GET/v2/coupons

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

GET
/api/v2/coupons
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",
    // ...
  }
]

GET/v2/coupons/:id

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

GET
/api/v2/coupons/:id
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"
}

POST/v2/coupons

Create a coupon

This endpoint allows you to create a coupon.

Request

POST
/api/v2/coupons
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"
}

PUT/v2/coupons/:id

Update a coupon

This endpoint allows you to update a coupon.

Request

PUT
/api/v2/coupons/:id
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/v2/coupons/:id

Delete a coupon

This endpoint allows you to delete a coupon. Note: This will permanently delete the coupon.

Request

DELETE
/api/v2/coupons/:id
curl -X DELETE https://selly.io/api/v2/coupons/z1vkhnw0 \
  -H "Authorization: Bearer {token}" \