ShopEazydevelopers
API referenceMerchant API BetaDiscounts

Create a discount code

Beta
Credentials
  • OAuth access token
Scopes
marketing:write
Subscription
Needs an active plan. Otherwise 403 subscription_locked.
Idempotency
Send an Idempotency-Key header. A retry with the same key does the work once.
POST
/v1/merchant/stores/{storeId}/discounts

Access: OAuth scope marketing:write; write-gated by the subscription.

Authorization

merchantOAuth marketing:write
headerAuthorizationBearer <token>

OAuth 2.1 (authorization code + PKCE S256, public clients, dynamic registration) for connected AI apps. Effective power is scopes granted AND the person's role today AND the plan. orders:refund, billing:write and team:write are opt-in on the consent screen. Write implies read for marketing:read and messages:read, so a grant holding marketing:write passes a marketing:read check, and messages:send passes messages:read.

Scope: marketing:write

Path Parameters

storeId*string

A store the person can reach. Any other id answers 404, never 403.

Header Parameters

Idempotency-Key*string

Required on every write. Minted on the device when the person taps, reused on every retry. A write without one, or with one that does not match the pattern, is refused with 422 validation_error. Scoped to the token's subject, remembered 24 hours. A replay returns the first 2xx response with Idempotent-Replay: true; a request still running answers 409 in_flight; the same key with a different method, path or body answers 409 idempotency_key_reused; non-2xx results are not remembered. If the key store cannot be read nothing is processed and the answer is 503 idempotency_unavailable: retry with the same key.

Match^[A-Za-z0-9_-]{8,128}$

Request Body

application/json
  1. body

A new code (parseNewDiscount). percent for a percent code, amountOff (ZAR) for a fixed one.

code*string
Match^[A-Za-z0-9_-]{2,24}$
kind*DiscountKind
Value in"percent""fixed""freeShipping"
percent?integer
Range0 <= value
amountOff?

A price as the server parses it: amount is a whole, non-negative number of minor units (a numeric string is coerced). currency defaults to ZAR.

status?string
Value in"active""paused""archived"
startsAt?integer|null
endsAt?integer|null
minSpend?|null
usageLimit?integer|null
perCustomerLimit?integer|null

Response Body

Created

application/json
  1. response
data*
Example Request
curl -X POST 'https://api.shopeazy.co/v1/merchant/stores/<storeId>/discounts' \  -H 'Authorization: Bearer <access_token>' \  -H 'Idempotency-Key: <unique_key>' \  -H 'Content-Type: application/json' \  -d '{  "code": "SPRING10",  "kind": "percent",  "percent": 10,  "status": "active",  "startsAt": 1792920792825,  "endsAt": 1797762792825,  "minSpend": {    "amount": 30000,    "currency": "ZAR"  },  "usageLimit": 200,  "perCustomerLimit": 1}'
Example Response
{  "data": {    "id": "SPRING10",    "code": "SPRING10",    "kind": "percent",    "kindLabel": "Percentage off",    "status": "active",    "state": "live",    "note": null,    "offer": "10% off",    "used": 0,    "usageLimit": 200,    "usageLabel": "Used 0 / 200",    "updatedAt": 1792924393230,    "percent": 10,    "amountOff": null,    "startsAt": 1792920792825,    "endsAt": 1797762792825,    "minSpend": {      "amount": 30000,      "currency": "ZAR"    },    "minSpendLabel": "Baskets over R300,00",    "perCustomerLimit": 1,    "createdAt": 1792924393230  }}