Skip to main content

Create discounts

You can create a discount through the API with the following endpoint:

The following example shows a discount creation request that includes only the required properties. Additional attributes are available, as documented here. The unique discount identifier in the response is required for any further API calls to manage the discount.

Example: Create a discount with required properties

curl -X post \
https://example.byappdirect.com/api/channel/v1/discounts
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"autoApply": "false",
"code": "Only required attributes",
"description": "autoApply attribute is true",
"type": "FIXED_PRICE",
"price": "5"
}

Response

{
"id": "27",
"code": "Only required attributes",
"redemptions": "0",
"type": "FIXED_PRICE",
"price": "5",
"description": "autoApply attribute is true",
"autoApply": "false",
"retainable": "false",
"redemptionRestriction": "NONE",
"vendorSharePercentage": "0",
"partnerSharePercentage": "100",
"basePartnerSharePercentage": "0",
"unit": "USER",
"minUnits": "0",
"maxUnits": "0"
}

The following example discount creation request that includes several other commonly used properties, such as the start date and expiration date.

Example: Create a discount with common properties

curl -X post \
https://example.byappdirect.com/api/channel/v1/discounts
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"code": "ILOVEAPPDIRECT",
"description": "A discount for those who love AppDirect",
"type": "PERCENTAGE",
"percentage": "50",
"autoApply": "false",
"startDate": "2015-05-06",
"expirationDate": "2015-10-11"
}

Response

{
"id": "2",
"code": "ILOVEAPPDIRECT",
"redemptions": "0",
"startDate": "2015-05-06T00:00:00-06:00",
"expirationDate": "2015-10-11T00:00:00-06:00",
"type": "PERCENTAGE",
"percentage": "50.0",
"description": "A discount for those who love AppDirect",
"autoApply": "false",
"retainable": "false",
"redemptionRestriction": "NONE",
"vendorSharePercentage": "0",
"partnerSharePercentage": "100",
"basePartnerSharePercentage": "0",
"unit": "USER",
"minUnits": "0",
"maxUnits": "0"
}

Note the following about the response:

  • Attributes that you do not specify in the request receive default values in the response.
  • The id is the unique identifier that is generated upon creation.
  • The redemptions, vendorSharePercentage, minUnits, and maxUnits properties all have default values of 0.
  • The partnerSharePercentage property has a default value of 100.
  • The retainable property has a default value of false.
  • The redemptionRestriction property has a default value of NONE.
  • The unit property has a default value of USER.
  • The maxRedemptions, startDate, expirationDate, applicationName, applicationID, paymentPlanId, and billingCycles have default values of null and are not returned in the response unless you provide them in the request.
  • You must use the price property if you set type to FIXED_PRICE, or the percentage property if you set type to PERCENTAGE.

Was this page helpful?