Create a discount
Creates a discount and returns it with status 201. Buy-X-get-Y and tiered-quantity discounts must include their quantity settings. The response is the bare object, without the standard {status, message, data} envelope.
How to use it
- Choose discountType: 1 fixed amount, 2 percentage, 3 buy X get Y, 4 tiered quantity.
- Send a unique name and rate; for type 3 also buyQuantity, getQuantity and getDiscountPercent, for type 4 tierMinQuantity.
- Use the returned id as discountId when you create or update items (Create an item).
BearerAuthAuthorizationBearer <JWT>application/json- body
id*integerUnique ID of the discount. Set by the server; use it as discountId on items.
int64name*stringDiscount name, up to 100 characters. Required and unique for the merchant.
discountType*integerKind of discount: 1 = fixed amount, 2 = percentage, 3 = buy X get Y, 4 = tiered quantity. Any other value is rejected.
int32rate*numberDiscount value: an amount in the merchant's currency for type 1, a percentage for type 2; for type 4 it applies once the tier quantity is reached.
modifiedTime*stringWhen the discount was last saved. Set by the server.
date-timestatus*stringStatus text, for example active (the default when omitted).
buyQuantity?|Buy X get Y only (type 3): number of units the customer must buy. Required and greater than zero for that type.
int32getQuantity?|Buy X get Y only (type 3): number of units that then get the discount. Required and greater than zero for that type.
int32getDiscountPercent?|Buy X get Y only (type 3): discount on the get units, above 0 and up to 100 (100 = free).
tierMinQuantity?|Tiered quantity only (type 4): line quantity at which rate starts to apply. Required and greater than zero for that type.
int32OK
*/*- response
id*integerUnique ID of the discount. Set by the server; use it as discountId on items.
int64name*stringDiscount name, up to 100 characters. Required and unique for the merchant.
discountType*integerKind of discount: 1 = fixed amount, 2 = percentage, 3 = buy X get Y, 4 = tiered quantity. Any other value is rejected.
int32rate*numberDiscount value: an amount in the merchant's currency for type 1, a percentage for type 2; for type 4 it applies once the tier quantity is reached.
modifiedTime*stringWhen the discount was last saved. Set by the server.
date-timestatus*stringStatus text, for example active (the default when omitted).
buyQuantity?|Buy X get Y only (type 3): number of units the customer must buy. Required and greater than zero for that type.
int32getQuantity?|Buy X get Y only (type 3): number of units that then get the discount. Required and greater than zero for that type.
int32getDiscountPercent?|Buy X get Y only (type 3): discount on the get units, above 0 and up to 100 (100 = free).
tierMinQuantity?|Tiered quantity only (type 4): line quantity at which rate starts to apply. Required and greater than zero for that type.
int32curl -X POST 'https://beta.iotoms.com/api/v1/catalog/attributes/discounts' \ -H 'Content-Type: application/json' \ -d '{ "id": 0, "name": "string", "discountType": 0, "rate": 0, "modifiedTime": "2019-08-24T14:15:22Z", "status": "string"}'{ "id": 0, "name": "string", "discountType": 0, "rate": 0, "modifiedTime": "2019-08-24T14:15:22Z", "status": "string", "buyQuantity": 0, "getQuantity": 0, "getDiscountPercent": 0, "tierMinQuantity": 0}