Marketing API
Discounts
Update Product Discount
this api endpoint (post) (post) updates an existing discount if the request succeeds, it returns a discount object docid\ y 9znrh28cmsoyhovk7fm permissions discounts edit webhook event discount events docid\ amoqkwqv4lrhgmpdygehw note the condition of the discount cannot be updated path parameters id the id of the discount to update body parameters the body request parameters are the same as the create endpoint of the type of discount you are editing require "uri" require "json" require "net/http" url = uri("https //api tamio com/v2/discounts/product discount/update/dcb19051 c358 4d25 8363 3a345455e03b") 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 "black friday discount", active true, applies to "all products", currency "eur", percent off 0, amount off 30, shipping amount off 0, shipping percent off 0, condition "coupon", coupon "blackfriday", coupon max redemptions 100, block affiliates true } request body = data to json response = https request(request) puts response read bodycurl location request post 'https //api tamio com/v2/discounts/product discount/update/dcb19051 c358 4d25 8363 3a345455e03b' \\ \ header 'accept application/json' \\ \ header 'authorization bearer your token here' \\ \ data raw '{ "label" "black friday discount", "active" true, "applies to" "all products", "currency" "eur", "percent off" 0, "amount off" 30, "shipping amount off" 0, "shipping percent off" 0, "condition" "coupon", "coupon" "blackfriday", "coupon max redemptions" 100, "block affiliates" true }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("authorization", "bearer your token here"); var data = { label "black friday discount", active true, applies to "all products", currency "eur", percent off 0, amount off 30, shipping amount off 0, shipping percent off 0, condition "coupon", coupon "blackfriday", coupon max redemptions 100, block affiliates true }; var body = json stringify(data); var requestoptions = { method 'post', headers myheaders, body body }; fetch("https //api tamio com/v2/discounts/product discount/update/dcb19051 c358 4d25 8363 3a345455e03b", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));{ "status" 200, "discount" { "id" "f23b029d 58dd 4bab 8cf1 a89d3ebb8f6d", "label" "black friday discount", "currency" "eur", "percent off" 0, "amount off" 30, "shipping percent off" 0, "shipping amount off" 0, "active" false, "type" "product discount", "object" "discount", "payments" \[ "all" ], "created at" "2022 11 22 20 30 55 +0000", "expiry date" null, "block affiliates" true, "destinations" \[ "worldwide" ], "condition" "coupon", "applies to" "all products", "rule amount" null, "subscription discount duration" "once", "number of months" null, "domain" null, "coupon" "blackfriday", "coupon max redemptions" 100, "coupon times redeemed" 0 } }