Core API
...
Discounts
Create a Discount
code examples curl location 'https //app sparklayer io/api/v1/discounts' \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ header 'site id string' \\ \ data '{ "internal name" "", "internal slug" "", "calculation group" "", "priority" "", "times applicable per order" "", "max rewards" 1, "groups" \[], "requirement selection type" "", "reward selection type" "", "currency code" "gbp", "start date" "", "end date" "", "active" "", "requirements" \[ { "items" \[ { "restrictions" \[ { "type" "", "ref" "" } ], "points type" "", "points" 1, "quantity" 0, "selection type" "" } ], "max rewards" 0, "min spend" "", "max spend" "", "spend tax type" "", "selection type" "", "min points" 0 } ], "rewards" \[ { "type" "", "amount type" "", "item id" "", "amount" "" } ], "other requirements" \[ {} ] }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); myheaders append("site id", "string"); var raw = json stringify({ "internal name" "", "internal slug" "", "calculation group" "", "priority" "", "times applicable per order" "", "max rewards" 1, "groups" \[], "requirement selection type" "", "reward selection type" "", "currency code" "gbp", "start date" "", "end date" "", "active" "", "requirements" \[ { "items" \[ { "restrictions" \[ { "type" "", "ref" "" } ], "points type" "", "points" 1, "quantity" 0, "selection type" "" } ], "max rewards" 0, "min spend" "", "max spend" "", "spend tax type" "", "selection type" "", "min points" 0 } ], "rewards" \[ { "type" "", "amount type" "", "item id" "", "amount" "" } ], "other requirements" \[ {} ] }); var requestoptions = { method 'post', headers myheaders, body raw, redirect 'follow' }; fetch("https //app sparklayer io/api/v1/discounts", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("https //app sparklayer io/api/v1/discounts") https = net http new(url host, url port) https use ssl = true request = net http post new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request\["site id"] = "string" request body = json dump({ "internal name" "", "internal slug" "", "calculation group" "", "priority" "", "times applicable per order" "", "max rewards" 1, "groups" \[], "requirement selection type" "", "reward selection type" "", "currency code" "gbp", "start date" "", "end date" "", "active" "", "requirements" \[ { "items" \[ { "restrictions" \[ { "type" "", "ref" "" } ], "points type" "", "points" 1, "quantity" 0, "selection type" "" } ], "max rewards" 0, "min spend" "", "max spend" "", "spend tax type" "", "selection type" "", "min points" 0 } ], "rewards" \[ { "type" "", "amount type" "", "item id" "", "amount" "" } ], "other requirements" \[ {} ] }) response = https request(request) puts response read body import requests import json url = "https //app sparklayer io/api/v1/discounts" payload = json dumps({ "internal name" "", "internal slug" "", "calculation group" "", "priority" "", "times applicable per order" "", "max rewards" 1, "groups" \[], "requirement selection type" "", "reward selection type" "", "currency code" "gbp", "start date" "", "end date" "", "active" "", "requirements" \[ { "items" \[ { "restrictions" \[ { "type" "", "ref" "" } ], "points type" "", "points" 1, "quantity" 0, "selection type" "" } ], "max rewards" 0, "min spend" "", "max spend" "", "spend tax type" "", "selection type" "", "min points" 0 } ], "rewards" \[ { "type" "", "amount type" "", "item id" "", "amount" "" } ], "other requirements" \[ {} ] }) headers = { 'accept' 'application/json', 'content type' 'application/json', 'site id' 'string' } response = requests request("post", url, headers=headers, data=payload) print(response text) responses // successful response { "id" "942651af f950 4716 9916 16170fe0645f", "created at" "", "deleted at" "", "updated at" "", "name" "", "internal name" "", "internal slug" "", "template" "", "calculation group" 0, "priority" 0, "times applicable per order" 0, "max rewards" 0, "groups" \[ "default" ], "simultaneity" \[ "default" ], "requirement selection type" "", "reward selection type" "", "currency code" "gbp", "start date" "", "end date" "", "active" false, "requirements" \[ { "items" \[ { "restrictions" \[ { "type" "", "ref" "", "metadata namespace" "erp", "metadata key" "vendor" } ], "points type" "", "points" 0, "quantity" 0, "selection type" "" } ], "max rewards" 0, "min spend" 0, "max spend" 0, "spend tax type" "", "selection type" "", "min points" 0 } ], "rewards" \[ { "type" "", "amount type" "", "restriction type" "", "item id" "", "metadata namespace" "erp", "metadata key" "vendor", "amount" 0 } ], "other requirements" \[ { "requirement type" "", "number" 0 } ] }// error response