You can use this API to create coupons for incentives.

When you generate coupons using the API, if any duplicate coupon code is generated, the job fails and you need to execute the job again.

APISignature
createCouponsForIncentiveswebService static Apttus_CPQApi.CPQ.CreateCouponsForIncentiveResponseDO createCouponsForIncentives(Apttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDO request)



Request Parameter
NameTypeDescription
requestApttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDOThe request data object.



Request Data Object - Apttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDO
NameTypeDescription
IncentiveIdsListThe IDs of the incentives for which you want to generate coupons.
NumCouponsList

The number of coupons you want to generate.

For example, if you enter 10000, CPQ will generate 10000 coupons for the specified incentive.




Reponse Parameter Data Object - Apttus_CPQApi.CPQ.CreateCouponsForIncentiveResponseDO
NameTypeDescription
CouponsListThe list of generated coupon codes.
IsAsyncBoolean

Indicates whether coupons were created in aysnc mode or not.

  • If there are <10k coupons, CPQ returns Async as False.
  • If there are >10k coupons, CPQ returns Async as True.
  • If there are multiple incentives, CPQ returns Async as True.
JobIdIdThe ID of the job created to generate coupons.


Code Sample

The sample code below demonstrates the coupons created in sync mode and async mode.

//Sync Test

Apttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDO request = new Apttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDO(); 
request.IncentiveIds.add(incentiveSO.Id);
// add corresponding number of coupons parameter
request.NumCoupons.add(5);

Apttus_CPQApi.CPQ.CreateCouponsForIncentiveResponseDO result = Apttus_CPQApi.CPQWebService.createCouponsForIncentives(request);

//Async Test

Apttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDO request2 = new Apttus_CPQApi.CPQ.CreateCouponsForIncentiveRequestDO();
request2.IncentiveIds.add(incentiveSO.Id);
request2.IncentiveIds.add(incentiveSO2.Id);

// add corresponding number of coupons parameter
request2.NumCoupons.add(5);
request2.NumCoupons.add(5);

Apttus_CPQApi.CPQ.CreateCouponsForIncentiveResponseDO result2 = Apttus_CPQApi.CPQWebService.createCouponsForIncentives(request2);
CODE