Skip to main content
POST
/
discount-codes
/
buy-x-get-y
Create Buy-X-Get-Y Discount
curl --request POST \
  --url https://api.nuwebgroup.com/v1/discount-codes/buy-x-get-y \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "code": "BXGY10",
  "amount": 10,
  "conditionSaleItemId": 1,
  "conditionSaleItemQuantity": 1,
  "targetSaleItemId": 1,
  "targetSaleItemQuantity": 1,
  "currencyId": 1,
  "maxUsesPerCustomer": 2,
  "minimumSpend": 1000,
  "maximumUses": 100,
  "validFrom": "2021-01-01",
  "validTo": "2021-02-01"
}
'
{
  "data": {
    "type": "discountCodes",
    "id": 1,
    "attributes": {
      "type": "bxgy",
      "code": "BXGY10",
      "amount": 10,
      "maximumUses": 100,
      "maxUsesPerCustomer": 2,
      "minimumSpend": 1000,
      "validFrom": "2021-11-22T11:59:00.000000Z",
      "validTo": "2021-11-25T11:59:00.000000Z",
      "boxOfficeOnly": false,
      "disabledAt": null,
      "createdAt": "2021-11-22T11:59:00.000000Z",
      "updatedAt": "2021-11-22T11:59:00.000000Z",
      "conditionSaleItemQuantity": 1,
      "targetSaleItemQuantity": 1
    },
    "relationships": {
      "conditionSaleItems": {
        "data": {
          "type": "conditionSaleItems",
          "id": 1
        }
      },
      "currencies": {
        "data": {
          "type": "currencies",
          "id": 1
        }
      },
      "targetSaleItems": {
        "data": {
          "type": "targetSaleItems",
          "id": 1
        }
      }
    },
    "links": {
      "self": "http://api.willms.com/v1/discount-codes?id=1"
    }
  },
  "included": [
    {
      "type": "currencies",
      "id": 1,
      "attributes": {
        "name": "Pounds",
        "code": "GBP",
        "symbol": "Ā£",
        "subunit": 2,
        "isCashless": false,
        "isCustom": false,
        "isPrimary": true
      }
    }
  ]
}

Authorizations

Authorization
string
header
required

The 'Bearer' token can be obtained from the token management interface or via the login endpoint using your admin user credentials.

Body

application/json

Request body for creating a buy X get Y discount code.

code
string
amount
number

The amount of the discount. For percentage discounts, this is the percentage value with up to two decimal places, e.g., 12.34 = 12.34%.

conditionSaleItemId
integer
conditionSaleItemQuantity
integer
targetSaleItemId
integer
targetSaleItemQuantity
integer
currencyId
integer
maxUsesPerCustomer
integer
minimumSpend
integer
maximumDiscount
object

An object containing maximum discounts that can be applied to an order using this code. Keyed by currency code.

maximumUses
integer
validFrom
string
validTo
string

Response

Successfully created the buy X get Y discount code.

data
object
included
object[]