Happy Business Starts Here

Savvy Scholar

How to create promo code using REST API

Hi All,

I want to create promo codes using API. I found documentation POST /api/v1/tools/promos/ (https://promotion-codes.apps.zuora.com/api-docs/index.html) but it's rather limited. For example, sample request is missing.
Can any of you provide few working request samples, preferably with custom fields. 

 

Thanks,
Ed

3 REPLIES 3
Support SME

Re: How to create promo code using REST API

All Zuora REST API can be found https://www.zuora.com/developer/api-reference/#

There is discount related api call such as subscribe call: https://www.zuora.com/developer/api-reference/#operation/Action_POSTsubscribe

Create subscription: 

https://www.zuora.com/developer/api-reference/#operation/POST_Subscription

We can confirm promo code api is not in our developer center. 

Support SME

Re: How to create promo code using REST API

We confirmed with our connect engineering team and that is the documentation for the connect promo codes app. It is public facing to anyone working with that app.

Savvy Scholar

Re: How to create promo code using REST API

With a little help from Zuora engineers there's working promo code request. Most of the parameters are self-explanatory but you need to make sure that fields ratePlan.productRatePlanId and ratePlanGroups.productRatePlanId are pointing to valid rate plan ids.

 

POST https://promotion-codes.apps.zuora.com/api/v1/tools/promos

 

Request: 
{
"code": "TEST-PROMO",
"campaign": "Testing Creation",
"availableQuantity": 999999999,
"effectiveFrom": "2018-05-30T16:00:00.000-06:00",
"effectiveTo": "2019-06-02T06:00:00.000-06:00",
"initialQuantity": 999999999,
"effectiveFrom": "2018-06-14T05:00:00.000-06:00",
"effectiveTo": "2019-06-15T05:00:00.000-06:00",
"discount": {
"type": "percent",
"ratePlan": {
"productRatePlanId": <RATE_PLAN_ID>
}
},
"customFields": {
"test1": {
"type": "string",
"value": "",
"required": false,
"validateRequirement": false
},
"test2": {
"type": "string",
"value": "",
"required": false,
"validateRequirement": false
},
"test3": {
"type": "string",
"value": "",
"required": false,
"validateRequirement": false
}
},
"ratePlanGroups": [
[
{
"productRatePlanId": "<PRODUCT_RATE_PLAN_ID>"
}
]
]
}