Create Order Discount

Beta
POST/v1/sales/order-discounts

Idempotent with Idempotency-Key header. Learn more

Creates an order discount that buyers can then redeem on a sales order by its code.

The code must be unique within your account; reusing a code that another discount already holds returns a conflict error. Creating the discount does not apply it to anything — a discount only affects an order once that order references it.

Permissions requiredValues:discounts:create
The role behind your API key or agent must grant every one of these permissions.
namestring

Display name of the discount.

codestring

The code a buyer enters to apply this discount to an order.

Codes are unique within your account and are compared without regard to letter case, so SAVE10 collides with save10.

percentageoptional string (decimal)

The fraction of the order total to take off, as a decimal string.

This is a multiplier, not a whole percent: send 0.1 to take 10% off. Only read when discount_type is percentage. Leaving it out stores 0, which produces a discount that takes nothing off.

amountoptional string (decimal)

The flat amount to take off the order total, as a decimal string.

Only read when discount_type is amount. Leaving it out stores 0, which produces a discount that takes nothing off.

discount_typestringenumValues:percentageamount

How the discount is calculated.

  • percentage: the order total is reduced by the fraction in percentage.
  • amount: the order total is reduced by the flat amount in amount.
idstring

Order discount ID.

objectstringenumValues:order_discount

Resource type identifier.

namestring

Display name of the discount.

codestring

The code a buyer enters to apply this discount to an order.

Codes are unique within your account and are matched without regard to letter case.

percentagestring (decimal)

The fraction of the order total taken off, as a decimal string.

This is a multiplier, not a whole percent: 0.1 takes 10% off. Only read when discount_type is percentage.

amountstring (decimal)

The flat amount taken off the order total, as a decimal string.

Only read when discount_type is amount.

discount_typestringenumValues:percentageamount

How the discount is calculated.

  • percentage: the order total is reduced by the fraction in percentage.
  • amount: the order total is reduced by the flat amount in amount.
order_countinteger

How many sales orders this discount has been applied to, across all buyers.

created_atstring (date-time)

Creation timestamp.

updated_atstring (date-time)

Last updated timestamp.

Responses

201

Successful response for Create Order Discount