License API
Consumption
Add Consumption
10 min
{ "tab" "examples", "url" "/api/v4/add consumption", "name" "/api/v4/add consumption", "method" "post", "request" { "pathparameters" \[], "queryparameters" \[], "headerparameters" \[ { "kind" "required", "name" "date", "type" "string", "children" \[], "description" "in rfc7231 format (see \\"license api authorization\\"), eg thu, 17 nov 2022 20 51 35 gmt" }, { "kind" "required", "name" "authorization", "type" "string", "children" \[], "description" "see \\"license api authorization\\" article" } ], "bodydataparameters" \[ { "kind" "required", "name" "hardware id", "type" "string", "children" \[], "description" "unique hardware id generated for the client device" }, { "kind" "required", "name" "product", "type" "string", "children" \[], "description" "product short code" }, { "kind" "optional", "name" "license key", "type" "string", "children" \[], "description" "required if product is key based (see section below)" }, { "kind" "optional", "name" "username", "type" "string", "children" \[], "description" "required if product is user based (see section below)" }, { "name" "license id", "kind" "optional", "type" "number", "description" "ensures that the action affects only the license with the specified id this is useful if e g you have multiple licenses for the same product assigned to the same user for obtaining a list of licenses assigned to a user, see \\"user licenses\\"", "children" \[] }, { "name" "consumptions", "kind" "optional", "type" "number", "description" "number of consumptions to add, defaults to 1 may be negative, unless `allow negative consumptions` is set to false", "children" \[] }, { "name" "max overages", "kind" "optional", "type" "string", "description" "maximum number of overages", "children" \[] }, { "name" "allow overages", "kind" "optional", "type" "string", "description" "allow or disallow overages", "children" \[] }, { "name" "event", "kind" "optional", "type" "array", "description" "an optional array of strings specifying which events will be recorded in the activity log for this request currently can be either `consumption add` (default) or `offline floating consumptions sync` (these 2 events are mutually exclusive)", "children" \[] } ], "formdataparameters" \[] }, "results" { "languages" \[ { "id" "es8g1cukjmbnpiivt9vof", "code" "{\n \\"id\\" 12345,\n \\"max consumptions\\" 4,\n \\"total consumptions\\" 9,\n \\"allow overages\\" true,\n \\"max overages\\" 5,\n \\"allow negative consumptions\\" true,\n \\"allow unlimited consumptions\\" false,\n \\"reset consumption\\" false,\n \\"consumpton period\\" \\"monthly\\"\n}", "language" "200", "customlabel" "" }, { "id" "7eyilksv2qgjcowesdz 2", "code" "{\n \\"unknown product\\" \\"provided product was not found\\",\n \\"license not found\\" \\"license with the provided license user not found\\",\n \\"license not enabled\\" \\"the license is not enabled\\",\n \\"device not found\\" \\"an active device matching the hardware id not found \\",\n \\"blacklisted\\" \\"this device is blacklisted\\",\n \\"license not active\\" \\"this license is not activated\\",\n \\"unsupported product feature\\" \\"one or more of requested product features do not exists or they are not enabled on the product \\",\n \\"feature not enough consumptions\\" \\"not enough consumptions left \\"", "language" "400", "customlabel" "" } ], "selectedlanguageid" "es8g1cukjmbnpiivt9vof" }, "examples" { "languages" \[ { "id" "wgu1oeamoxm6updipp9rp", "language" "curl", "code" "curl location request post '/api/v4/add consumption' \\\\\n header 'accept application/json' \\\\\n header 'date string' \\\\\n header 'authorization string' \\\\\n data raw '{\\"hardware id\\" \\"string\\",\\"product\\" \\"string\\",\\"license key\\" \\"string\\",\\"username\\" \\"string\\",\\"consumptions\\" \\"number\\",\\"max overages\\" \\"string\\",\\"allow overages\\" \\"string\\"}'", "customlabel" "" }, { "id" "6jdkevkhoj8qsopts wxs", "language" "nodejs", "code" "var request = require('request');\nvar options = {\n 'method' 'post',\n 'url' '/api/v4/add consumption',\n 'headers' {\n 'accept' 'application/json',\n 'date' 'string',\n 'authorization' 'string'\n },\n body '{\\"hardware id\\" \\"string\\",\\"product\\" \\"string\\",\\"license key\\" \\"string\\",\\"username\\" \\"string\\",\\"consumptions\\" \\"number\\",\\"max overages\\" \\"string\\",\\"allow overages\\" \\"string\\"}'\n\n};\nrequest(options, function (error, response) {\n if (error) throw new error(error);\n console log(response body);\n});\n", "customlabel" "" }, { "id" "upcywe4wofrldc4o8p3o4", "language" "javascript", "code" "var myheaders = new headers();\nmyheaders append(\\"accept\\", \\"application/json\\");\nmyheaders append(\\"date\\", \\"string\\");\nmyheaders append(\\"authorization\\", \\"string\\");\n\nvar raw = \\"{\\\\\\"hardware id\\\\\\" \\\\\\"string\\\\\\",\\\\\\"product\\\\\\" \\\\\\"string\\\\\\",\\\\\\"license key\\\\\\" \\\\\\"string\\\\\\",\\\\\\"username\\\\\\" \\\\\\"string\\\\\\",\\\\\\"consumptions\\\\\\" \\\\\\"number\\\\\\",\\\\\\"max overages\\\\\\" \\\\\\"string\\\\\\",\\\\\\"allow overages\\\\\\" \\\\\\"string\\\\\\"}\\";\n\nvar requestoptions = {\n method 'post',\n headers myheaders,\n body raw,\n redirect 'follow'\n};\n\nfetch(\\"/api/v4/add consumption\\", requestoptions)\n then(response => response text())\n then(result => console log(result))\n catch(error => console log('error', error));", "customlabel" "" }, { "id" "5hmrn8q1ygmpojbyvsgcy", "language" "python", "code" "import requests\n\nurl = \\"/api/v4/add consumption\\"\n\npayload = \\"{\\\\\\"hardware id\\\\\\" \\\\\\"string\\\\\\",\\\\\\"product\\\\\\" \\\\\\"string\\\\\\",\\\\\\"license key\\\\\\" \\\\\\"string\\\\\\",\\\\\\"username\\\\\\" \\\\\\"string\\\\\\",\\\\\\"consumptions\\\\\\" \\\\\\"number\\\\\\",\\\\\\"max overages\\\\\\" \\\\\\"string\\\\\\",\\\\\\"allow overages\\\\\\" \\\\\\"string\\\\\\"}\\"\nheaders = {\n 'accept' 'application/json',\n 'date' 'string',\n 'authorization' 'string'\n}\n\nresponse = requests request(\\"post\\", url, headers=headers, data=payload)\n\nprint(response text)\n", "customlabel" "" }, { "id" "uyshjxcmbsaczo6lipqbj", "language" "ruby", "code" "require \\"uri\\"\nrequire \\"net/http\"\n\nurl = uri(\\"/api/v4/add consumption\\")\n\nhttp = net http new(url host, url port);\nrequest = net http post new(url)\nrequest\[\\"accept\\"] = \\"application/json\\"\nrequest\[\\"date\\"] = \\"string\\"\nrequest\[\\"authorization\\"] = \\"string\\"\nrequest body = \\"{\\\\\\"hardware id\\\\\\" \\\\\\"string\\\\\\",\\\\\\"product\\\\\\" \\\\\\"string\\\\\\",\\\\\\"license key\\\\\\" \\\\\\"string\\\\\\",\\\\\\"username\\\\\\" \\\\\\"string\\\\\\",\\\\\\"consumptions\\\\\\" \\\\\\"number\\\\\\",\\\\\\"max overages\\\\\\" \\\\\\"string\\\\\\",\\\\\\"allow overages\\\\\\" \\\\\\"string\\\\\\"}\\"\n\nresponse = http request(request)\nputs response read body\n", "customlabel" "" } ], "selectedlanguageid" "5hmrn8q1ygmpojbyvsgcy" }, "description" "adds 1 or more consumptions to a license (only for consumption type licenses)\n", "currentnewparameter" { "label" "body parameter", "value" "bodydataparameters" } } schema request body type addconsumptionrequestbody = ({ // required for key based products license key string, } | { // required for user based products username string, }) & { // required parameters product string, hardware id string, // optional parameters license id? string | undefined, consumptions? number | undefined, max overages? number | undefined, allow overages? boolean | undefined, event? ('consumption add' | 'offline floating consumptions sync')\[] | undefined, } json schema { "$schema" "https //json schema org/draft/2020 12/schema", "type" "object", "allof" \[ { "oneof" \[ { "type" "object", "properties" { "license key" { "type" "string" } }, "required" \["license key"], "additionalproperties" false }, { "type" "object", "properties" { "username" { "type" "string" } }, "required" \["username"], "additionalproperties" false } ] }, { "type" "object", "properties" { "hardware id" { "type" "string" }, "product" { "type" "string" }, "license id" { "type" "number" }, "consumptions" { "type" "number" }, "max overages" { "type" "number" }, "allow overages" { "type" "number" }, "event" { "type" "array", "items" { "type" "string", "enum" \["consumption add", "offline floating consumptions sync"] }, "minitems" 1, "not" { "allof" \[ { "contains" { "const" "consumption add" } }, { "contains" { "const" "offline floating consumptions sync" } } ] } } }, "required" \["hardware id", "product"], "additionalproperties" false } ] } response body type addconsumptionresponsebody = { id number, max consumptions number, total consumptions number, allow unlimited consumptions boolean, allow negative consumptions boolean, allow overages boolean, max overages number, reset consumption boolean, consumption period 'daily' | 'weekly' | 'monthly' | 'annually' | null, } json schema { "$schema" "https //json schema org/draft/2020 12/schema", "type" "object", "properties" { "id" { "type" "number" }, "max consumptions" { "type" "number" }, "total consumptions" { "type" "number" }, "allow unlimited consumptions" { "type" "boolean" }, "allow negative consumptions" { "type" "boolean" }, "allow overages" { "type" "boolean" }, "max overages" { "type" "number" }, "reset consumption" { "type" "boolean" }, "consumption period" { "type" \[ "string", "null" ], "enum" \[ "daily", "weekly", "monthly", "annually", null ] }, }, "required" \[ "id", "max consumptions", "total consumptions", "allow unlimited consumptions", "allow negative consumptions", "allow overages", "max overages", "reset consumption", "consumption period" ], "additionalproperties" false } license authorization method there are two types of product licenses based on how the client application authorizes itself to interact with a license key based product licenses client interactions with the license have to be authorized using a license key user based product licenses the license has a corresponding "license user" instead of a license key client interactions with the license have to be authorized using a username errors if an error occurs, the response will have an http status code of 400 or higher, and the response body will contain an error description in the following format { status number, code string, message string }{ "$schema" "https //json schema org/draft/2020 12/schema", "type" "object", "properties" { "status" { "type" "number" }, "code" { "type" "string" }, "message" { "type" "string" } }, "required" \[ "status", "code", "message" ], "additionalproperties" false } list of exceptions unknown product (400) provided product was not found license not found (400) license with the provided license user not found license not active (400) the license is not active license not enabled (400) the license is not enabled license not consumption (400) the license needs to be of consumption type license not enough consumptions (400) not enough consumptions left negative consumptions not allowed (400) negative consumptions not allowed device not found (400) an active device matching the hardware id not found blacklisted (400) this device is blacklisted