iotoms Docs

Create a discount

POST
/api/v1/catalog/attributes/discounts

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

  1. Choose discountType: 1 fixed amount, 2 percentage, 3 buy X get Y, 4 tiered quantity.
  2. Send a unique name and rate; for type 3 also buyQuantity, getQuantity and getDiscountPercent, for type 4 tierMinQuantity.
  3. Use the returned id as discountId when you create or update items (Create an item).

Authorization

BearerAuth
headerAuthorizationBearer <JWT>

Request Body

application/json
  1. body
id*integer

Unique ID of the discount. Set by the server; use it as discountId on items.

Formatint64
name*string

Discount name, up to 100 characters. Required and unique for the merchant.

discountType*integer

Kind of discount: 1 = fixed amount, 2 = percentage, 3 = buy X get Y, 4 = tiered quantity. Any other value is rejected.

Formatint32
rate*number

Discount 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*string

When the discount was last saved. Set by the server.

Formatdate-time
status*string

Status 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.

Formatint32
getQuantity?|

Buy X get Y only (type 3): number of units that then get the discount. Required and greater than zero for that type.

Formatint32
getDiscountPercent?|

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.

Formatint32

Response Body

OK

*/*
  1. response
id*integer

Unique ID of the discount. Set by the server; use it as discountId on items.

Formatint64
name*string

Discount name, up to 100 characters. Required and unique for the merchant.

discountType*integer

Kind of discount: 1 = fixed amount, 2 = percentage, 3 = buy X get Y, 4 = tiered quantity. Any other value is rejected.

Formatint32
rate*number

Discount 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*string

When the discount was last saved. Set by the server.

Formatdate-time
status*string

Status 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.

Formatint32
getQuantity?|

Buy X get Y only (type 3): number of units that then get the discount. Required and greater than zero for that type.

Formatint32
getDiscountPercent?|

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.

Formatint32
Example Request
curl -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"}'
Example Response
{  "id": 0,  "name": "string",  "discountType": 0,  "rate": 0,  "modifiedTime": "2019-08-24T14:15:22Z",  "status": "string",  "buyQuantity": 0,  "getQuantity": 0,  "getDiscountPercent": 0,  "tierMinQuantity": 0}