Update Coupon Code API

Modify existing coupon codes including discount values, limits, and validity periods

Promotions

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

MUTATION/graphql

Update an existing coupon code's configuration including discount amount, usage limits, validity period, and active status.

Authentication:Bearer Token
Required scopes:admin

Request Parameters

idInt!Required

The unique identifier of the coupon to update.

couponCouponCodeUpdate!Required

Object containing the fields to update.

discountValueFloat

Updated discount amount.

maxUsesInt

Updated maximum usage count.

maxUsesPerUserInt

Updated per-user limit.

validUntilDateTime

Extended or shortened expiration date.

activeBoolean

Enable 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

200Coupon Updated Successfully
{
  "data": {
    "updateCouponCode": {
      "id": "123",
      "code": "SUMMER2024",
      "discountType": "PERCENTAGE",
      "discountValue": 30,
      "maxUses": 2000,
      "usedCount": 150,
      "validUntil": "2024-12-31T23:59:59Z",
      "active": true
    }
  }
}
400Coupon Not Found
{
  "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.



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.

Create Coupon