If you are replacing an exising coupon or voucher system with Talon.One, you may need to transfer coupon codes from the old system to ensure that these codes continue to work. This guide shows how you can use the coupon import endpoint from our Management API to create coupons programmatically.
Before creating coupons in Talon.One, you need to create one or more campaigns that define coupon validation conditions and coupon effects. As a general rule, you will use one campaign for each kind of validation you need to support. E.g. if one set of coupons is only valid for orders with a total value greater than $50, and another set is valid for customers in a certain geographic region, these should belong to 2 different campaigns.
Once the campaign has been created, make a note of its ID for later use in our API calls.
#Generate a CSV file that has the correct structure (1 file per Talon.One campaign)
Once you've collected the raw coupon data from your legacy system and you know the ID of the campaign you want to import the codes into, you will have to transform your raw data into a csv file with all the necessary data.
The structure of a coupon import CSV file is very similar to our own exportCoupons CSV files (using ISO8601 for dates). Below is an example showing a csv file with all available columns provided:
The first step when using the Management API is to create a new session token. See our Authentication reference for more details on how to obtain a session token.
#Perform a importCoupon API call with the csv file as the payload
Now you have all the pieces you need to import your coupons into Talon.One. The generalized process is to perform the importCoupons operation, with your generated csv file as the payload. Assuming you have your csv file saved in the same folder, you could import the coupons by executing a simple curl command such as the following one:
This article has outlined the general process for importing existing coupon codes into Talon.One, and demonstrated the simplest case with a curl command. More complex scenarios may need to use multiple campaigns or even varying attributes on individual coupons. To see more of what's possible with coupon attributes check out our tutorial on creating custom coupons with the API.