anyshop docs homeStatusOpen the dashboard

API reference Coupons Update a coupon

API referenceCoupons

Update a coupon

PATCH methodhttps://api.anyshop.io/v1/coupons/{id}

Changes the fields you send and nothing else, by the same rules as creating one. An archived coupon cannot be changed. Needs a live key.

  • Scope coupons:write
  • Live keys only
  • Idempotent with Idempotency-Key
  • 403 store_suspended while suspended

Path parameters

  • idstring required

Body

application/json0 required, 9 optional
  • codestring What buyers type: 3 to 32 letters and digits, kept in capitalsUp to 64 characters
  • percent_offnumber Makes it a percent off: 0.01 to 100, at most two decimals0.01 to 100
  • amount_offinteger Makes it an amount off the order, in minor units of the store currencyAt least 1
  • currencystring Optional check: the store's currency, ISO 4217. Another currency is refused, since amounts off are in the store's3 characters
  • productsarray of strings or null Product IDs it applies to, up to 200; null for every product1 to 200 items
  • usage_limitinteger or null Uses allowed, counted in each mode on its own1 to 10,000,000
  • once_per_emailboolean One use per buyer email
  • starts_atstring or null When it starts working, ISO 8601
  • ends_atstring or null 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.type
  • 400invalid_requestThe request is not valid; error.param names the field
  • 401authenticationNo API key, or it is not valid
  • 403permissionThe key does not have the scope this needs, or the store is suspended (store_suspended)
  • 404not_foundNot found in the key's store and mode
  • 409conflictConflicts 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