Update Coupon Code API
Modify existing coupon codes including discount values, limits, and validity periods
Update Coupon Code API
Modify existing promotional coupons. Update discount values, extend validity periods, adjust usage limits, or deactivate expired promotions.
Edit Settings
Modify any coupon configuration.
Extend Validity
Extend or shorten promotion periods.
Toggle Status
Activate or deactivate coupons.
Endpoint Overview
/graphqlUpdate an existing coupon code's configuration including discount amount, usage limits, validity period, and active status.
Request Parameters
idInt!RequiredThe unique identifier of the coupon to update.
couponCouponCodeUpdate!RequiredObject containing the fields to update.
discountValueFloatUpdated discount amount.
maxUsesIntUpdated maximum usage count.
maxUsesPerUserIntUpdated per-user limit.
validUntilDateTimeExtended or shortened expiration date.
activeBooleanEnable or disable the coupon.
applicablePlans[Int]Updated list of applicable plans.
GraphQL Mutation
mutation updateCouponCode($id: Int!, $coupon: CouponCodeUpdate!) {
updateCouponCode(id: $id, coupon: $coupon) {
id
code
discountType
discountValue
maxUses
usedCount
validUntil
active
}
}Variables:
{
"id": 123,
"coupon": {
"discountValue": 30,
"validUntil": "2024-12-31T23:59:59Z",
"maxUses": 2000
}
}HTTP Request:
curl -X POST https://api.orbnet.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-d '{
"query": "mutation updateCouponCode($id: Int!, $coupon: CouponCodeUpdate!) { updateCouponCode(id: $id, coupon: $coupon) { id code discountValue active } }",
"variables": {
"id": 123,
"coupon": {
"discountValue": 30
}
}
}'Response
{
"data": {
"updateCouponCode": {
"id": "123",
"code": "SUMMER2024",
"discountType": "PERCENTAGE",
"discountValue": 30,
"maxUses": 2000,
"usedCount": 150,
"validUntil": "2024-12-31T23:59:59Z",
"active": true
}
}
}{
"errors": [
{
"message": "Coupon not found",
"path": ["updateCouponCode"],
"extensions": {
"code": "NOT_FOUND"
}
}
],
"data": null
}Common Updates
Extend Promotion
Extend validUntil date for successful campaigns.
Increase Discount
Boost discount for flash sales.
Add More Uses
Increase maxUses for popular codes.
Deactivate
Set active to false to end promotion.
Best Practices
Partial Updates
Only include fields you want to change.
Don't Change Code
Avoid changing the code string itself.
Track Changes
Keep records of coupon modifications.
Communicate
Notify marketing of any changes.
Related Endpoints
Active Promotions
Be cautious when modifying coupons during active campaigns. Changes take effect immediately.
Create New Coupons
Need a new promotion? Create fresh coupon codes with the Create Coupon API.