-
-
Getting Started
-
Industries
-
Integration API
-
Management API
-
SDKs
-
Technology Partners
-
Tutorials and Guides
A number of use cases may require creating adaptive coupons using our Management API. This guide shows you how you can programmatically create coupons with attributes to configure their behaviour.
As an example, consider a campaign that rewards individual customers with a personal coupon code. Your campaign rules will contain some sort of "coupon belongs to the current user" logic, but the coupon itself needs to carry the information about which profile it belongs to.
To establish this link, you can configure a BelongsToProfileId
attribute on coupons themselves, and then define this attribute when creating coupons.
For example, in a Ruby application you might have something like so:
# profile_id: the same ID used in the integration API to identify this customer
# campaign: a campaign object previously retrieved from the Management API
def create_coupon_for_customer_and_campaign(profile_id, campaign)
talon = TalonOne::Management::Client.new
talon.post("/v1/applications/#{campaign["applicationId"]}/campaigns/#{campaign["id"]}/coupons", {
"couponPattern" => "My-Promo-####",
"numberOfCoupons" => 1, # How many coupons codes to create
"usageLimit" => 1, # How many times each coupon can be used
"attributes" => {
"BelongsToProfileId" => profile_id
}
})
end
The above method will create a coupon with a random code that references a given
customer. By adding a campaign rule that validates Coupon.Attributes.BelongsToProfileId = Profile.Id
, only customer-specific coupons will be redeemed by the campaign.
References:
If you’d like a member of our support team to respond to you, please send a note to support@talon.one