Upsert a coupon

Request

Creates or updates (upserts) a coupon with a specified coupon ID.

Security
SecretApiKey or JWT or ApplicationJWT
Path
idstring, <= 50 characters^[@~\-\.\w]+$required

ID of the resource.

Bodyapplication/jsonrequired

Coupon resource.

discountobject(Discount)required
restrictionsArray of objects(CouponRestriction)

Coupon restrictions. All type values in this array must be unique.

descriptionstring

Description of the coupon. Use this field to provide a description for the invoice discount item.

If this field is empty, the invoice discount item description uses the related coupon ID, in the following format: Coupon "COUPON-ID".

issuedTimestring, (date-time)required

Date and time when the coupon is issued. This value may also be described as start time of the coupon.

expiredTimestring or null, (date-time)

Date and time when the coupon expires.

curl -i -X PUT \
  'https://www.rebilly.com/_mock/catalog/all/coupons/{id}' \
  -H 'Content-Type: application/json' \
  -H 'REB-APIKEY: YOUR_API_KEY_HERE' \
  -d '{
    "discount": {
      "amount": 0.01,
      "currency": "USD",
      "type": "fixed",
      "context": "items"
    },
    "restrictions": [
      {
        "type": "discounts-per-redemption",
        "quantity": 0
      }
    ],
    "description": "string",
    "issuedTime": "2019-08-24T14:15:22Z",
    "expiredTime": "2019-08-24T14:15:22Z"
  }'

Responses

Coupon updated.

Headers
X-RateLimit-Limitinteger

Total number of rate limit tokens for this request within a rate limit period. For more information, see Rate limits.

Example:3600
X-RateLimit-Remaininginteger

Remaining number of rate limit tokens for this request within the rate limit period. For example, in the sandbox environment, rate limits for non-GET endpoints are set at 3000 requests per 10 minutes.

Example:3600
Bodyapplication/json
idstring, <= 50 charactersread-only

ID of the coupon. This value is also known as the coupon redemption code.

Example:"cpn_0YVCNKF81GD778N4YNVGDJK558"
discountobject(Discount)required
restrictionsArray of objects(CouponRestriction)

Coupon restrictions. All type values in this array must be unique.

redemptionsCountinteger, >= 0read-only

Total number of times that a coupon is redeemed.

statusstringread-only

Specifies the current status of the coupon.

Enum:"draft""issued""expired"
descriptionstring

Description of the coupon. Use this field to provide a description for the invoice discount item.

If this field is empty, the invoice discount item description uses the related coupon ID, in the following format: Coupon "COUPON-ID".

issuedTimestring, (date-time)required

Date and time when the coupon is issued. This value may also be described as start time of the coupon.

expiredTimestring or null, (date-time)

Date and time when the coupon expires.

revisionintegerread-only

Number of times the coupon data has been modified.

Use the revision number when analyzing webhook data to determine if a change should take precedence over the current representation.

createdTimestring, (date-time)(CreatedTime)read-only

Date and time when the resource is created. This value is set automatically when the resource is created.

updatedTimestring, (date-time)(UpdatedTime)read-only

Date and time when the resource is updated. This value is set automatically when the resource is updated.

Response
{ "id": "cpn_0YVCNKF81GD778N4YNVGDJK558", "discount": { "amount": 0.01, "currency": "USD", "type": "fixed", "context": "items" }, "restrictions": [ {} ], "redemptionsCount": 0, "status": "draft", "description": "string", "issuedTime": "2019-08-24T14:15:22Z", "expiredTime": "2019-08-24T14:15:22Z", "revision": 0, "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "_links": [ {} ] }