Sifr Wahid Developers

API reference / Coupons

Update coupon

Change a coupon (only the keys sent)

PATCH https://s.zo.sa/api/public/v1/coupons/{id}
Scope marketing.read_writeIdempotency-Key supported

product_ids, category_ids and payment_methods replace the saved list when sent: send the whole list. Every key you do not send stays.

Request

Path parameters

NameTypeRequiredDescription
idintegerrequiredAt least 1

Headers

NameTypeRequiredDescription
Idempotency-Keystring1 to 120 visible ASCII characters. A write sent again with the same key runs once; the retry gets the first answer back with the header Idempotent-Replayed: true. Use a new key for each new write. 1 to 120 characters

Request body

application/json required

A coupon to create (POST: code, type and value required) or change (PATCH: only the keys sent change). The same rules as the dashboard's coupons page.

  • codestring
    Unique in the store; saved in capitals.
    Up to 40 characters Pattern ^[A-Za-z0-9_-]+$
  • typestring
    One of percent, fixed
  • valueinteger
    A whole percent (at most 100) for percent; halalas for fixed.
    At least 1
  • min_subtotalintegernullable
    Halalas.
    At least 0
  • max_discountintegernullable
    Halalas.
    At least 1
  • free_shippingboolean
  • usage_limitintegernullable
    At least 1
  • per_customer_limitintegernullable
    At least 1
  • starts_atstring (date)nullable
    The coupon works from the start of this day in Riyadh.
  • ends_atstring (date)nullable
    Until the last second of this day in Riyadh; not before starts_at.
  • is_activeboolean
    An expired coupon is switched back on only with an ends_at still ahead.
  • applies_tostring
    products needs product_ids, categories needs category_ids.
    One of all, products, categories
  • product_idsarray of integersnullable
    Products of this store.
    Up to 500 items
  • category_idsarray of integersnullable
    Categories of this store.
    Up to 200 items
  • exclude_sale_itemsboolean
  • payment_methodsarray of stringsnullable
    Payment method codes the coupon is limited to.
  • first_order_onlyboolean
  • exclude_walletboolean
  • show_in_cartboolean
  • notestringnullable
    Up to 190 characters

cURL

curl -sS -X PATCH "https://s.zo.sa/api/public/v1/coupons/9" \
  -H "Authorization: Bearer $ZO_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: erp-coupon-9-limit" \
  -d '{
  "usage_limit": 200
}'

JavaScript

const response = await fetch('https://s.zo.sa/api/public/v1/coupons/9', {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.ZO_API_KEY}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
    'Idempotency-Key': 'erp-coupon-9-limit',
  },
  body: JSON.stringify({
    "usage_limit": 200
  }),
});
console.log(response.status, await response.json());

PHP

<?php

$ch = curl_init('https://s.zo.sa/api/public/v1/coupons/9');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('ZO_API_KEY'),
        'Accept: application/json',
        'Content-Type: application/json',
        'Idempotency-Key: erp-coupon-9-limit',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'usage_limit' => 200,
    ]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

echo $status, PHP_EOL, $body, PHP_EOL;

Python

import os

import requests

response = requests.patch(
    "https://s.zo.sa/api/public/v1/coupons/9",
    headers={
        "Authorization": f"Bearer {os.environ['ZO_API_KEY']}",
        "Accept": "application/json",
        "Idempotency-Key": "erp-coupon-9-limit",
    },
    json={
        "usage_limit": 200,
    },
    timeout=30,
)
print(response.status_code, response.json())

Caps the coupon at 200 uses; nothing else changes.

Response 200
{
  "data": {
    "id": 1,
    "code": "string",
    "type": "percent",
    "value": 10,
    "min_subtotal": null,
    "max_discount": null,
    "free_shipping": false,
    "usage_limit": null,
    "per_customer_limit": null,
    "uses": 1,
    "starts_at": null,
    "ends_at": null,
    "is_active": true,
    "status": "active",
    "created_at": "2026-11-23T06:01:53Z",
    "updated_at": "2026-11-23T06:01:53Z"
  }
}

Example generated from the schema.

Responses

200The coupon as saved.
Response schema
  • dataobjectrequired
    16 fields
    • idintegerrequired
    • codestringrequired
    • typestringrequired
      One of percent, fixed
    • valueintegerrequired
      A whole percent for type percent; halalas for type fixed.
    • min_subtotalintegerrequirednullable
      Halalas.
    • max_discountintegerrequirednullable
      Halalas.
    • free_shippingbooleanrequired
    • usage_limitintegerrequirednullable
    • per_customer_limitintegerrequirednullable
    • usesintegerrequired
      How many times the coupon was used.
    • starts_atstring (date-time)requirednullable
    • ends_atstring (date-time)requirednullable
    • is_activebooleanrequired
    • statusstringrequired
      One of active, inactive, scheduled, expired, exhausted
    • created_atstring (date-time)required
    • updated_atstring (date-time)required
401Missing, unknown, revoked or expired key.

An error object: {"error": {"code", "message", "fields"}}.

402The store's plan does not include this feature (error code feature_locked, with the feature and the plan that has it). Every operation answers it with feature public_api when the key's store is not on the Pro plan.

An error object: {"error": {"code", "message", "fields"}}.

403The key lacks the scope (code insufficient_scope, naming it in scope), the caller's address is not allowed (ip_not_allowed), or the store is suspended (store_suspended: reads stay allowed, every write answers this).

An error object: {"error": {"code", "message", "fields"}}.

404No such row in this store (code not_found).

An error object: {"error": {"code", "message", "fields"}}.

409A write with the same Idempotency-Key is still running (code duplicate_request); retry shortly.

An error object: {"error": {"code", "message", "fields"}}.

422validation_failed, or coupon_expired_end (switching an expired coupon back on needs an ends_at still ahead).

An error object: {"error": {"code", "message", "fields"}}.

429Too many requests (code rate_limited); see Retry-After.

An error object: {"error": {"code", "message", "fields"}}.