Coupons

Markdown

View as Markdown

A store's discount codes. Creating and changing them needs a plan with coupons.

All paths are relative to the base URL https://api.store.link/v1. Every request needs your API key; see Overview.

Endpoints

EndpointWhat it does
GET /stores/{storeId}/couponsList coupons
POST /stores/{storeId}/couponsCreate a coupon
PATCH /stores/{storeId}/coupons/{couponId}Change a coupon
DELETE /stores/{storeId}/coupons/{couponId}Delete a coupon

Coupon types

TypeFields it uses
amount_off_orderdiscount_type, discount_amount
amount_off_productdiscount_type, discount_amount, applies_to, targets
buy_x_get_ycustomer_buys, customer_gets, max_uses_per_order

Every type also takes code, enabled, valid_from, valid_till, use_per_customer and min_order_amount. Fields a type doesn't use are null (or an empty targets) in responses.

List coupons

GET /stores/{storeId}/coupons

Every coupon in the store, with its discount, validity and how often it's been used.

Your role in the store needs to read coupons.

Path parameters

NameTypeDescription
storeIdstring
required
A store id from GET /stores.

Example request

curl 'https://api.store.link/v1/stores/665f1c2ab4e8a90012ab34cd/coupons' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response

FieldTypeDescription
dataarray of object
data[].idstring
data[].typestringamount_off_order uses discount_type and discount_amount; amount_off_product adds applies_to and targets; buy_x_get_y uses customer_buys, customer_gets and max_uses_per_order. One of: amount_off_order, amount_off_product, buy_x_get_y.
data[].codestringWhat customers type at checkout, in lowercase.
data[].enabledboolean
data[].valid_fromstring (date-time), nullable
data[].valid_tillstring (date-time), nullablenull for no end date.
data[].use_per_customerstring, nullableunlimited or once.
data[].min_order_amountnumber, nullable
data[].max_discount_amountnumber, nullableCaps a percentage discount.
data[].discount_typestring, nullableOne of: percentage, flat.
data[].discount_amountnumber, nullableA percentage, or an amount in the store currency.
data[].applies_tostring, nullableOne of: products, categories.
data[].targetsarray of object
data[].targets[].slugstringA product slug, or a category slug when applies_to is categories.
data[].targets[].namestring
data[].targets[].variantobject, nullableOne variant of the product, or null for all of them.
data[].targets[].variant.keystring
data[].targets[].variant.namestring
data[].customer_buysobject, nullable
data[].customer_buys.min_quantityinteger, nullable
data[].customer_buys.applies_tostring, nullableOne of: products, categories.
data[].customer_buys.targetsarray of objectSame fields as targets.
data[].customer_getsobject, nullableWhat the customer gets free.
data[].customer_gets.quantityinteger, nullable
data[].customer_gets.applies_tostring, nullableOne of: products, categories.
data[].customer_gets.targetsarray of objectSame fields as targets.
data[].max_uses_per_orderinteger, nullable
data[].times_usedinteger

Example response

{
  "data": [
    {
      "id": "6662b1e4d3a2c90014de67f0",
      "type": "amount_off_order",
      "code": "welcome10",
      "enabled": true,
      "valid_from": "2026-11-20T10:15:00.000Z",
      "valid_till": "2026-12-31T23:59:59.000Z",
      "use_per_customer": "once",
      "min_order_amount": 30,
      "max_discount_amount": 20,
      "discount_type": "percentage",
      "discount_amount": 10,
      "applies_to": null,
      "targets": [],
      "customer_buys": null,
      "customer_gets": null,
      "max_uses_per_order": null,
      "times_used": 12
    }
  ]
}

Errors

The common errors: 400 invalid_request, 401 unauthorized, 403 insufficient_permission, 404 store_not_found, 429 rate_limited, 500 internal_error. See Errors in the Overview.

Create a coupon

POST /stores/{storeId}/coupons

Creates a discount code. amount_off_order takes discount_type and discount_amount; amount_off_product also takes applies_to and targets; buy_x_get_y takes customer_buys, customer_gets and max_uses_per_order. A code the store already has is a conflict.

Your role in the store needs to write coupons.

Path parameters

NameTypeDescription
storeIdstring
required
A store id from GET /stores.

Request body

FieldTypeDescription
typestring
required
One of: amount_off_order, amount_off_product, buy_x_get_y.
codestring
required
What customers type at checkout. Stored in lowercase, and unique in the store.
enabledbooleanDefault true.
valid_fromstring (date-time)Default now.
valid_tillstring (date-time)Leave out for no end date.
use_per_customerstringDefault unlimited. One of: unlimited, once.
min_order_amountnumber
discount_typestringOne of: percentage, flat.
discount_amountnumberA percentage, or an amount in the store currency. Greater than 0.
max_discount_amountnumberCaps a percentage discount.
applies_tostringOne of: products, categories.
targetsarray of object
targets[].slugstring
required
A product slug, or a category slug when applies_to is categories.
targets[].namestring
targets[].variantobjectOne variant of the product, by its key; leave out for all of them.
targets[].variant.keystring
required
targets[].variant.namestring
required
customer_buysobject
customer_buys.min_quantityinteger
required
Greater than 0.
customer_buys.applies_tostring
required
One of: products, categories.
customer_buys.targetsarray of object
required
Same fields as targets.
customer_getsobjectWhat the customer gets free.
customer_gets.quantityinteger
required
Greater than 0.
customer_gets.applies_tostring
required
One of: products, categories.
customer_gets.targetsarray of object
required
Same fields as targets.
max_uses_per_orderintegerHow many times the deal can apply in one order. Greater than 0.

Example request: 10% off orders over 30

curl -X POST 'https://api.store.link/v1/stores/665f1c2ab4e8a90012ab34cd/coupons' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "amount_off_order",
  "code": "WELCOME10",
  "valid_till": "2026-12-31T23:59:59.000Z",
  "use_per_customer": "once",
  "min_order_amount": 30,
  "discount_type": "percentage",
  "discount_amount": 10,
  "max_discount_amount": 20
}'

Example request: buy 2 tees, get 1 free

curl -X POST 'https://api.store.link/v1/stores/665f1c2ab4e8a90012ab34cd/coupons' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "buy_x_get_y",
  "code": "TEES3FOR2",
  "customer_buys": {
    "min_quantity": 2,
    "applies_to": "categories",
    "targets": [{ "slug": "t-shirts" }]
  },
  "customer_gets": {
    "quantity": 1,
    "applies_to": "products",
    "targets": [{ "slug": "classic-tee" }]
  },
  "max_uses_per_order": 1
}'

Response

The coupon, with the fields listed under List coupons (each item in data) above.

Errors

  • 403 plan_upgrade_required: The store's plan doesn't include this. The message names the plan it needs.
  • 409 conflict: The write collides with what the store has, such as a code or slug in use.

Plus the common errors: 400 invalid_request, 401 unauthorized, 403 insufficient_permission, 404 store_not_found, 429 rate_limited, 500 internal_error. See Errors in the Overview.

Change a coupon

PATCH /stores/{storeId}/coupons/{couponId}

Changes only the fields you send, including enabled to pause or resume the coupon; customer_buys and customer_gets replace the whole object. An empty body changes nothing. A coupon's type can't change: delete it and create another.

Your role in the store needs to write coupons.

Path parameters

NameTypeDescription
storeIdstring
required
A store id from GET /stores.
couponIdstring
required
A coupon id from GET /stores/{storeId}/coupons. A 24-character id.

Request body

The same fields as Create a coupon, all optional. type, if sent, must be the coupon's own type.

Example request: pause a coupon

curl -X PATCH 'https://api.store.link/v1/stores/665f1c2ab4e8a90012ab34cd/coupons/6662b1e4d3a2c90014de67f0' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "enabled": false
}'

Response

The coupon, with the fields listed under List coupons (each item in data) above.

Errors

  • 403 plan_upgrade_required: The store's plan doesn't include this. The message names the plan it needs.
  • 404 not_found: Nothing with this id in this store, or something the body names, such as a product or coupon, is not there.
  • 409 conflict: The write collides with what the store has, such as a code or slug in use.

Plus the common errors: 400 invalid_request, 401 unauthorized, 403 insufficient_permission, 404 store_not_found, 429 rate_limited, 500 internal_error. See Errors in the Overview.

Delete a coupon

DELETE /stores/{storeId}/coupons/{couponId}

Deletes the coupon. To pause it instead, change it with enabled false.

Your role in the store needs to write coupons.

Path parameters

NameTypeDescription
storeIdstring
required
A store id from GET /stores.
couponIdstring
required
A coupon id from GET /stores/{storeId}/coupons. A 24-character id.

Example request

curl -X DELETE 'https://api.store.link/v1/stores/665f1c2ab4e8a90012ab34cd/coupons/6662b1e4d3a2c90014de67f0' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response

FieldTypeDescription
idstring
deletedtrue

Example response

{
  "id": "6662b1e4d3a2c90014de67f0",
  "deleted": true
}

Errors

  • 404 not_found: Nothing with this id in this store, or something the body names, such as a product or coupon, is not there.

Plus the common errors: 400 invalid_request, 401 unauthorized, 403 insufficient_permission, 404 store_not_found, 429 rate_limited, 500 internal_error. See Errors in the Overview.

Related Articles

Was this article helpful?