Wocart
Wocart API

Coupons

Server

List coupons

GET
https://api.wocart.store
/api/coupons
X-API-Key (header)

Every coupon, newest first, with where it stands, its uses and the discount it gave.

List coupons › Responses

200

List of coupons

success
​boolean · required
​CouponSummary[] · required
count
​integer · required

Number of items returned


Create coupon

POST
https://api.wocart.store
/api/coupons
X-API-Key (header)

Create a coupon.

How it applies (at checkout, not here): after offers, to the paid lines in its scope that no offer applied to. Its discount is shared across those lines, so the order's price stays the sum of its lines. A use is an order with the coupon that is not cancelled; the usage limit and one use per customer are enforced by the database when the order is placed.

Refused with INVALID_COUPON (reason says why) or COUPON_CODE_TAKEN.

Create coupon › Request Body

code
​string · minLength: 1 · maxLength: 64 · required

What the shopper types. Stored upper case without spaces; Latin letters, digits, - and _, 3 to 32 long; Arabic-Indic digits are read as 0–9.

kind
​string · enum · required
Enum values:
percentage
fixed_amount
free_shipping
value
​integer · min: 0

Percent (1–100) for percentage, dinars for fixed_amount; none for free_shipping.

maxDiscount
​integer | null · min: 1

The most a percentage coupon takes off one order.

minSubtotal
​integer | null · min: 1

What the eligible products must cost together. Never beside minQuantity.

minQuantity
​integer | null · min: 1

How many eligible items the order must hold. Never beside minSubtotal.

scope
​string · enum
Enum values:
store
products
collections
Default: store
productIds
​string[] · maxItems: 500

The products a products coupon covers. At most 500.

collectionIds
​string[] · maxItems: 100

The collections a collections coupon covers. At most 100.

audience
​string · enum
Enum values:
everyone
selected
Default: everyone
customerIds
​string[] · maxItems: 1000

Customers a selected coupon admits. At most 1000.

groupIds
​string[] · maxItems: 50

Customer groups whose members a selected coupon admits. At most 50.

usageLimit
​integer | null · min: 1

Orders that may use it, across all customers; cancelled orders do not count.

oncePerCustomer
​boolean
startsAt
​string | null · date-time
endsAt
​string | null · date-time
status
​string · enum
Enum values:
active
inactive
Default: active

Create coupon › Responses

Coupon created

success
​boolean · required
​Coupon · required

Get coupon

GET
https://api.wocart.store
/api/coupons/{id}
X-API-Key (header)

A coupon with the products, collections, customers and groups it names.

Get coupon › path Parameters

id
​string · required

Coupon UUID

Coupon UUID

Get coupon › Responses

200

Coupon details

success
​boolean · required
​Coupon · required

Update coupon

PATCH
https://api.wocart.store
/api/coupons/{id}
X-API-Key (header)

Partially update a coupon; the coupon it leaves is judged whole. A change of kind starts its value afresh, a change of scope or audience its picks. Orders already placed keep what they were given.

Update coupon › path Parameters

id
​string · required

Coupon UUID

Coupon UUID

Update coupon › Request Body

code
​string · minLength: 1 · maxLength: 64

What the shopper types. Stored upper case without spaces; Latin letters, digits, - and _, 3 to 32 long; Arabic-Indic digits are read as 0–9.

kind
​string · enum
Enum values:
percentage
fixed_amount
free_shipping
value
​integer · min: 0

Percent (1–100) for percentage, dinars for fixed_amount; none for free_shipping.

maxDiscount
​integer | null · min: 1

The most a percentage coupon takes off one order.

minSubtotal
​integer | null · min: 1

What the eligible products must cost together. Never beside minQuantity.

minQuantity
​integer | null · min: 1

How many eligible items the order must hold. Never beside minSubtotal.

scope
​string · enum
Enum values:
store
products
collections
productIds
​string[] · maxItems: 500

The products a products coupon covers. At most 500.

collectionIds
​string[] · maxItems: 100

The collections a collections coupon covers. At most 100.

audience
​string · enum
Enum values:
everyone
selected
customerIds
​string[] · maxItems: 1000

Customers a selected coupon admits. At most 1000.

groupIds
​string[] · maxItems: 50

Customer groups whose members a selected coupon admits. At most 50.

usageLimit
​integer | null · min: 1

Orders that may use it, across all customers; cancelled orders do not count.

oncePerCustomer
​boolean
startsAt
​string | null · date-time
endsAt
​string | null · date-time
status
​string · enum
Enum values:
active
inactive

Update coupon › Responses

200

Updated coupon

success
​boolean · required
​Coupon · required

Delete coupon

DELETE
https://api.wocart.store
/api/coupons/{id}
X-API-Key (header)

Permanently delete a coupon. Orders that used it keep its code and the discount they were given.

Delete coupon › path Parameters

id
​string · required

Coupon UUID

Coupon UUID

Delete coupon › Responses

200

Coupon deleted

success
​boolean · required