Upsert a coupon

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

SecuritySecretApiKey or JWT
Request
path Parameters
id
required
string <= 50 characters ^[@~\-\.\w]+$

ID of the resource.

Request Body schema: application/json

Coupon resource.

required
object (Discount)
amount
required
number <double> >= 0.01

Discount amount.

currency
required
string = 3 characters

Currency code in ISO 4217 format.

type
string

Discount type.

context
string (DiscountContext)
Default: "items"

Context in which the discount applies.

Enum: Description
items

items (less discounts)

shipping

shipping (less discounts)

items-and-shipping

items and shipping (less discounts)

issuedTime
required
string <date-time>

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

Array of objects (CouponRestriction)

Coupon restrictions.

Array
type
required
string

Coupon restriction type.

quantity
required
integer

Restriction quantity.

description
string

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

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

expiredTime
string <date-time>

Date and time when the coupon expires.

Responses
200

Coupon updated.

Response Schema: application/json
required
object (Discount)
amount
required
number <double> >= 0.01

Discount amount.

currency
required
string = 3 characters

Currency code in ISO 4217 format.

type
string

Discount type.

context
string (DiscountContext)
Default: "items"

Context in which the discount applies.

Enum: Description
items

items (less discounts)

shipping

shipping (less discounts)

items-and-shipping

items and shipping (less discounts)

issuedTime
required
string <date-time>

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

id
string <= 50 characters

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

Array of objects (CouponRestriction)

Coupon restrictions.

Array
type
required
string

Coupon restriction type.

quantity
required
integer

Restriction quantity.

redemptionsCount
integer >= 0

Total number of times that a coupon is redeemed.

status
string

Specifies the current status of the coupon.

Enum: "draft" "issued" "expired"
description
string

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

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

expiredTime
string <date-time>

Date and time when the coupon expires.

createdTime
string <date-time> (CreatedTime)

Date and time which is set automatically when the resource is created.

updatedTime
string <date-time> (UpdatedTime)

Date and time which updates automatically when the resource is updated.

Array of objects (SelfLink)

Related links.

Array
href
string

Link URL.

rel
string

Type of link.

Value: "self"
201

Coupon created.

Response Headers
Location
string <uri>

Location of the related resource.

Example: "https://api.rebilly.com/example"
Response Schema: application/json
required
object (Discount)
amount
required
number <double> >= 0.01

Discount amount.

currency
required
string = 3 characters

Currency code in ISO 4217 format.

type
string

Discount type.

context
string (DiscountContext)
Default: "items"

Context in which the discount applies.

Enum: Description
items

items (less discounts)

shipping

shipping (less discounts)

items-and-shipping

items and shipping (less discounts)

issuedTime
required
string <date-time>

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

id
string <= 50 characters

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

Array of objects (CouponRestriction)

Coupon restrictions.

Array
type
required
string

Coupon restriction type.

quantity
required
integer

Restriction quantity.

redemptionsCount
integer >= 0

Total number of times that a coupon is redeemed.

status
string

Specifies the current status of the coupon.

Enum: "draft" "issued" "expired"
description
string

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

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

expiredTime
string <date-time>

Date and time when the coupon expires.

createdTime
string <date-time> (CreatedTime)

Date and time which is set automatically when the resource is created.

updatedTime
string <date-time> (UpdatedTime)

Date and time which updates automatically when the resource is updated.

Array of objects (SelfLink)

Related links.

Array
href
string

Link URL.

rel
string

Type of link.

Value: "self"
401

Unauthorized access. Invalid credentials used.

404

Resource not found.

409

Conflict.

422

Invalid data sent.

put/coupons/{id}
Request samples
application/json
{
  • "discount": {
    },
  • "restrictions": [
    ],
  • "description": "string",
  • "issuedTime": "2019-08-24T14:15:22Z",
  • "expiredTime": "2019-08-24T14:15:22Z"
}
Response samples
application/json
{
  • "id": "4f6cf35x-2c4y-483z-a0a9-158621f77a21",
  • "discount": {
    },
  • "restrictions": [
    ],
  • "redemptionsCount": 0,
  • "status": "draft",
  • "description": "string",
  • "issuedTime": "2019-08-24T14:15:22Z",
  • "expiredTime": "2019-08-24T14:15:22Z",
  • "createdTime": "2019-08-24T14:15:22Z",
  • "updatedTime": "2019-08-24T14:15:22Z",
  • "_links": [
    ]
}