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
idis the unique identifier that is generated upon creation. - The
redemptions,vendorSharePercentage,minUnits, andmaxUnitsproperties all have default values of0. - The
partnerSharePercentageproperty has a default value of100. - The
retainableproperty has a default value offalse. - The
redemptionRestrictionproperty has a default value ofNONE. - The unit property has a default value of
USER. - The
maxRedemptions,startDate,expirationDate,applicationName,applicationID,paymentPlanId, andbillingCycleshave default values ofnulland are not returned in the response unless you provide them in the request. - You must use the
priceproperty if you settypetoFIXED_PRICE, or thepercentageproperty if you settypetoPERCENTAGE.
Was this page helpful?
Tell us more…
Help us improve our content. Responses are anonymous.
Thanks
We appreciate your feedback!