# X + Y discount insertion

Endpoint: POST /api/xy-discounts
Version: 1.0.0
Security: shoptetAccessToken, shoptetPrivateApiToken

## Header parameters:

  - `Content-Type` (string, required)

## Request fields (application/json):

  - `data` (object, required)

  - `data.title` (string, required)
    discount title

  - `data.validFrom` (string,null)
    date of discount validity from

  - `data.validTo` (string,null)
    date of discount validity to

  - `data.customerGroupCodes` (array,null)
    customer groups connected to discount

  - `data.includeUnregisteredCustomers` (boolean)
    defines if discount is valid for unregistered customers, default value is false.

  - `data.xAmount` (string, required)
    discount amount in X axis

  - `data.yAmount` (string, required)
    amount of products get by discount

  - `data.description` (string,null)
    discount description

  - `data.termsAndConditionsUrl` (string,null)
    URL to terms and conditions

  - `data.displayFlag` (boolean)
    whether or not to display flag. If not set, default value is true.

  - `data.flagColor` (string,null)
    color of flag

  - `data.displayBanner` (boolean)
    whether or not to display banner. If not set, default value is true.

  - `data.bannerColor` (string,null)
    color of banner

  - `data.usageCount` (integer,null)
    number of how many times can be discount used.

  - `data.sortBefore` (integer)
    id of xy discount before which you want to move the xy discount from the request. Not possible to use with sortAfter.

  - `data.sortAfter` (integer)
    id of xy discount after which you want to move the  xy discount from the request. Not possible to use with sortBefore.

  - `data.xTargeting` (object, required)
    definition of products needed to get discount

  - `data.xTargeting.productGuids` (array)
    array of product guids

  - `data.xTargeting.categoryGuids` (array)
    array of page guids (categories)

  - `data.xTargeting.brandCodes` (array)
    array of brand codes

  - `data.yTargeting` (object, required)
    definition of products get by discount

## Response 201 fields (application/json):

  - `data` (object, required)

  - `data.discount` (object, required)

  - `data.discount.id` (integer, required)
    discount ID

  - `data.discount.title` (string, required)
    discount title

  - `data.discount.validFrom` (string,null, required)
    date of discount validity from

  - `data.discount.validTo` (string,null, required)
    date of discount validity to

  - `data.discount.customerGroups` (array,null, required)
    customer groups connected to discount

  - `data.discount.customerGroups.code` (string, required)
    customer group code

  - `data.discount.customerGroups.name` (string, required)
    customer group name

  - `data.discount.xAmount` (string, required)
    amount of products needed to get discount

  - `data.discount.yAmount` (string, required)
    amount of products get by discount

  - `data.discount.description` (string,null, required)
    discount description

  - `data.discount.termsAndConditionsUrl` (string,null, required)
    url address lead to terms of discount

  - `data.discount.displayFlag` (boolean, required)
    whether the flag is displayed

  - `data.discount.flagColor` (string,null, required)
    color of the flag

  - `data.discount.displayBanner` (boolean, required)
    flag whether the banner is displayed

  - `data.discount.bannerColor` (string,null, required)
    color of the banner

  - `data.discount.priority` (integer,null, required)
    priority of the discount

  - `data.discount.usageCount` (integer,null, required)
    number of how many times can be discount used

  - `data.discount.xTargeting` (object,null, required)
    definition of products needed to get discount

  - `data.discount.xTargeting.productGuids` (array,null, required)
    array of product guids

  - `data.discount.xTargeting.categoryGuids` (array,null, required)
    array of page guids (categories)

  - `data.discount.xTargeting.brandCodes` (array,null, required)
    array of brand codes

  - `data.discount.yTargeting` (object,null, required)
    definition of products get by discount

  - `data.discount.includeUnregisteredCustomers` (boolean, required)
    defines if discount is valid for unregistered customers, default value is false

  - `errors` (array,null, required)

  - `errors.errorCode` (string, required)
    Short text error identification

  - `errors.message` (string, required)
    Descriptive error message

  - `errors.instance` (string, required)
    Identification of the entity referenced

  - `metadata` (object, required)

  - `metadata.requestId` (string, required)
    Request identifier. Useful for logging/reporting purposes.


