Marketing API
Discounts
Create Customer Discount
this api endpoint (post) (post) creates a customer discount if the request succeeds, it returns a discount object docid\ y 9znrh28cmsoyhovk7fm permissions discounts create webhook event discount events docid\ amoqkwqv4lrhgmpdygehw use customer discounts if you like to give one of your existing customers a coupon code to redeem on your store body parameters label string the label of the discount currency string appendix docid\ kfbmx4q3dxjtduqf75yx1 the currency of the discount percent off decimal the percentage discount that gets applied to the order and/or product subtotal amount off integer the fixed discount amount that gets applied to the order and/or product subtotal shipping amount off integer the fixed discount amount applied to the shipping subtotal shipping percent off decimal the percentage discount applied to the shipping subtotal applies to string the possible values are all products and selected products active boolean determines whether the discount is currently active the default value is false customer string the id of the customer object docid\ x0e6zfnwaym4bwj4a82ex that this discount belongs to coupon string the coupon code, for example, blackfriday coupon max redemptions integer the number of times the coupon can be redeemed the default value is 1 products array of strings the product ids associated with the discount required if applies to is set to selected products domain string the id of the domain that this discount can be redeemed on if not provided, the coupon can be redeemed on all your checkout flows managed by tamio expiry date appendix docid\ kfbmx4q3dxjtduqf75yx1 the expiration date of the discount require "uri" require "json" require "net/http" url = uri("https //api tamio com/v2/discounts/customer discount/create") https = net http new(url host, url port) https use ssl = true request = net http post new(url) request\["accept"] = "application/json" request\["authorization"] = "bearer your token here" data = { label "james doe 50% off", active true, applies to "all product", currency "eur", percent off 50, amount off 0, shipping amount off 0, shipping percent off 0, coupon "cpn50", customer "921f13d5 ab4a 44e6 9333 46b2e3db5c25" } request body = data to json response = https request(request) puts response read bodycurl location request post 'https //api tamio com/v2/discounts/customer discount/create' \\ \ header 'accept application/json' \\ \ header 'authorization bearer your token here' \\ \ data raw '{ "label" "james doe 50% off", "active" true, "applies to" "all products", "currency" "eur", "percent off" 50, "amount off" 0, "shipping amount off" 0, "shipping percent off" 0, "coupon" "cpn50", "customer" "921f13d5 ab4a 44e6 9333 46b2e3db5c25" }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("authorization", "bearer your token here"); var data = { label "james doe 50% off", active true, applies to "all product", currency "eur", percent off 50, amount off 0, shipping amount off 0, shipping percent off 0, coupon "cpn50", customer "921f13d5 ab4a 44e6 9333 46b2e3db5c25" }; var body = json stringify(data); var requestoptions = { method 'post', headers myheaders, body body }; fetch("https //api tamio com/v2/discounts/customer discount/create", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));{ "status" 200, "discount" { "id" "dcb19051 c358 4d25 8363 3a345455e03b", "label" "james doe 50% off", "currency" "eur", "percent off" 50, "amount off" 0, "shipping percent off" 0, "shipping amount off" 0, "active" false, "type" "customer discount", "object" "discount", "payments" \[], "created at" "2022 11 22 23 10 11 +0000", "expiry date" null, "block affiliates" false, "destinations" \[], "condition" "coupon", "applies to" "all products", "rule amount" null, "subscription discount duration" null, "number of months" null, "domain" null, "customer" "921f13d5 ab4a 44e6 9333 46b2e3db5c25", "coupon" "cpn50", "coupon max redemptions" 1, "coupon times redeemed" 0 } }