Skip to content

Update Promotion Code

Description

This API allows store owners to update an existing promotion by its unique ID.

Endpoint

  • URL: /v1/promotions/{promotionId}
  • Method: PATCH

Required Headers

json
{
  "Authorization": "Bearer JWT_TOKEN",
  "X-MerchantApiKey": "MERCHANT_API_KEY",
  "Content-Type": "application/json"
}

📥 Request Body

ParameterTypeRequiredDescriptionSinceExample
namestringtrueThe name of the promotion-
codestringtrueThe code for the promotion
Validation[Size(max=50, min=3, message=Promotion code must be between 3 and 50 characters)]
-
descriptionstringfalseA description of the promotion-
startDatestringtrueThe start date of the promotion-yyyy-MM-dd HH:mm:ss
endDatestringtrueThe end date of the promotion-yyyy-MM-dd HH:mm:ss
discountnumbertrueThe discount percentage for the promotion
Validation[Min(value=0, message=Discount must be at least 0); Max(value=100, message=Discount cannot exceed 100)]
-0
discountTypeenumfalseThe type of discount.
Defaults to PERCENTAGE if not provided, for backward compatibility.
[Enum: PERCENTAGE, FLAT_AMOUNT, FREE_SHIPPING, BUY_X_GET_Y]
-PERCENTAGE
discountValuenumberfalseThe discount value.
- PERCENTAGE → 0–100
- FLAT_AMOUNT → positive monetary amount
- FREE_SHIPPING / BUY_X_GET_Y → omit or send null
Validation[DecimalMin(value= 0.0, message=Discount value must be at least 0)]
-0
maximumDiscountCapnumberfalseFor PERCENTAGE only — caps the maximum monetary discount applied.
Send null to remove an existing cap.
Validation[DecimalMin(value=0.0, inclusive=false, message=Maximum discount cap must be greater than 0)]
-0
minimumOrderValuenumberfalseMinimum order subtotal required to qualify.
Send null to remove an existing minimum.
Validation[DecimalMin(value=0.0, message=Minimum order value must be at least 0)]
-0
requiredQuantityint32falseFor BUY_X_GET_Y only — number of items customer must buy.
Validation[Min(value=1, message=Required quantity must be at least 1)]
-0
freeQuantityint32falseFor BUY_X_GET_Y only — number of free items customer receives.
Validation[Min(value=1, message=Free quantity must be at least 1)]
-0
usageLimitint32falseMaximum number of times this promotion can be redeemed across all customers.
Send null to make unlimited.
Validation[Min(value=1, message=Usage limit must be at least 1)]
-0
perCustomerUsageLimitint32falseMaximum number of times a single customer can redeem this promotion.
Send null to make unlimited per customer.
Validation[Min(value=1, message=Per customer usage limit must be at least 1)]
-0
statusstringfalseLifecycle status of the promotion.
The status of the promotion (e.g., active, expired, upcoming)
Restricted transitions: DEPLETED cannot be manually set — it is system-managed.
-

Example API Call (Using Fetch)

javascript
fetch("https://api.shopsynch.com/v1/promotions/679f8f5a3b5f2173201c2582", {
  method: "PATCH",
  headers: {
    "Authorization": "Bearer JWT_TOKEN",
    "X-MerchantApiKey": "MERCHANT_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "name": "Spring Sale",
    "code": "SPRING20",
    "description": "Hurrray",
    "startDate": "yyyy-MM-dd HH:mm:ss",
    "endDate": "yyyy-MM-dd HH:mm:ss",
    "discount": 4.0,
    "status": "active"
  })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));

Response-fields:

FieldTypeDescriptionSinceExample
statusbooleanNo comments found.-true
messagestringNo comments found.-
dataobjectNo comments found.-
└─createdAtstringNo comments found.-yyyy-MM-dd HH:mm:ss
└─updatedAtstringNo comments found.-yyyy-MM-dd HH:mm:ss
└─idstringNo comments found.-
└─namestringName of promotion-
└─codestringThe code that customers will use to redeem the promotion-
└─descriptionstringA description of the promotion-
└─startDatestringThe start date and time of the promotion-yyyy-MM-dd HH:mm:ss
└─endDatestringThe end date and time of the promotion-yyyy-MM-dd HH:mm:ss
└─discountTypeenumThe type of discount this promotion applies.
Defaults to PERCENTAGE for backward compatibility with existing promotions
that were created before discount types were introduced.
[Enum: PERCENTAGE, FLAT_AMOUNT, FREE_SHIPPING, BUY_X_GET_Y]
-PERCENTAGE
└─discountValuenumberThe discount value — interpretation depends on discountType:
PERCENTAGE → value is a percentage. e.g. 10 means 10% off
FLAT_AMOUNT → value is a fixed amount in the tenant's currency. e.g. 500 means ₦500 off
FREE_SHIPPING → value is ignored, set to ZERO by convention
BUY_X_GET_Y → value is ignored, use requiredQuantity + freeQuantity instead
-0
└─maximumDiscountCapnumberFor PERCENTAGE promotions — caps the maximum monetary discount that can be applied.
e.g. "20% off but no more than ₦2,000"
Null means no cap.
Only meaningful when discountType = PERCENTAGE.
-0
└─minimumOrderValuenumberMinimum order subtotal required to qualify for this promotion.
Null or ZERO means no minimum.
-0
└─requiredQuantityint32For BUY_X_GET_Y promotions — the number of items the customer must purchase.
Only meaningful when discountType = BUY_X_GET_Y.
-0
└─freeQuantityint32For BUY_X_GET_Y promotions — the number of free items the customer receives.
Only meaningful when discountType = BUY_X_GET_Y.
-0
└─usageLimitint32Maximum number of times this promotion can be redeemed across all customers.
Null means unlimited.
-0
└─usageCountint32How many times this promotion has been redeemed so far.-0
└─perCustomerUsageLimitint32Maximum number of times a single customer can redeem this promotion.
Null means unlimited per customer.
-0
└─discountnumberThe discount amount for the promotion-0
└─statusstringThe status of the promotion (e.g., active, expired, upcoming)-
└─tenantIdstringNo comments found.-

Response-example:

json
{
  "status": true,
  "message": "",
  "data": {
    "createdAt": "yyyy-MM-dd HH:mm:ss",
    "updatedAt": "yyyy-MM-dd HH:mm:ss",
    "id": "",
    "name": "",
    "code": "",
    "description": "",
    "startDate": "yyyy-MM-dd HH:mm:ss",
    "endDate": "yyyy-MM-dd HH:mm:ss",
    "discountType": "PERCENTAGE",
    "discountValue": 0,
    "maximumDiscountCap": 0,
    "minimumOrderValue": 0,
    "requiredQuantity": 0,
    "freeQuantity": 0,
    "usageLimit": 0,
    "usageCount": 0,
    "perCustomerUsageLimit": 0,
    "discount": 0,
    "status": "",
    "tenantId": ""
  }
}

Next Steps

Build with joy