Create a coupon
POST methodhttps://api.anyshop.io/v1/coupons
A code buyers type at checkout, with the dashboard's rules: a percent or an amount off, every product or the ones you name, a usage limit, one use per buyer email, a start and an end. It works at once unless starts_at is later.
Body
application/json1 required, 8 optionalcodestring requiredWhat buyers type: 3 to 32 letters and digits, kept in capitalsUp to 64 characterspercent_offnumber Percent off each product it applies to: 0.01 to 100, at most two decimals. Send this or amount_off0.01 to 100amount_offinteger Off the order once, in minor units of the store currency: 500 is $5.00. Send this or percent_offAt least 1currencystring Optional check: the store's currency, ISO 4217. Another currency is refused, since amounts off are in the store's3 charactersproductsarray of strings Product IDs: it applies to these only, up to 200. Left out, every product1 to 200 itemsusage_limitinteger Uses allowed, counted in each mode on its own1 to 10,000,000once_per_emailboolean One use per buyer emailstarts_atstring When it starts working, ISO 8601ends_atstring When it stops working, ISO 8601: after starts_at, and not in the past
Headers
Idempotency-Keystring Up to 255 characters. A retry with the same key and request gets the first answer, without running twice (24 hours).
Returns
The coupon object.
Errors
Status and error.type400invalid_requestThe request is not valid;error.paramnames the field401authenticationNo API key, or it is not valid403permissionThe key does not have the scope this needs, or the store is suspended (store_suspended)404not_foundNot found in the key's store and mode409conflictConflicts with the object's state (type conflict), or an Idempotency-Key reused for another request (type idempotency, code idempotency_key_reused)429rate_limitedToo many requests; see Retry-After