curl --request PATCH \
--url https://app.variable.global/api/v1/switch/{uuid} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"syncId": "sync123",
"name": "Switch Name",
"unit": "kg"
}
'import requests
url = "https://app.variable.global/api/v1/switch/{uuid}"
payload = {
"syncId": "sync123",
"name": "Switch Name",
"unit": "kg"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({syncId: 'sync123', name: 'Switch Name', unit: 'kg'})
};
fetch('https://app.variable.global/api/v1/switch/{uuid}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.variable.global/api/v1/switch/{uuid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'syncId' => 'sync123',
'name' => 'Switch Name',
'unit' => 'kg'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.variable.global/api/v1/switch/{uuid}"
payload := strings.NewReader("{\n \"syncId\": \"sync123\",\n \"name\": \"Switch Name\",\n \"unit\": \"kg\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.variable.global/api/v1/switch/{uuid}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"syncId\": \"sync123\",\n \"name\": \"Switch Name\",\n \"unit\": \"kg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.variable.global/api/v1/switch/{uuid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"syncId\": \"sync123\",\n \"name\": \"Switch Name\",\n \"unit\": \"kg\"\n}"
response = http.request(request)
puts response.read_body{
"uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"syncId": "sync123",
"name": "Switch Name",
"unit": "kg",
"image": "https://app.variable.global/uploads/image.jpg",
"sources": [
{
"uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Name"
}
],
"footprint": {
"CO2e": {
"productCarbonFootprint": "1234.5678",
"A1_A3": "1234.5678"
}
},
"impacts": {
"GWP-fossil": {
"unit": "kgCO2e",
"method": "Mixed",
"totalCarbonFootprint": "10",
"A1_A3": "10"
},
"ODP": {
"unit": "kgCFC11e",
"method": "EN15804+A2 - Core impact categories and indicators",
"A1_A3": "0.0000012"
},
"AP": {
"unit": "molH+e",
"method": "EN15804+A2 - Core impact categories and indicators",
"A1_A3": "2"
}
},
"created": "2021-01-01T00:00:00.000Z",
"updated": "2021-01-31T23:59:59.000Z"
}{
"message": "token expired"
}Edit Switch
Edit a switch
curl --request PATCH \
--url https://app.variable.global/api/v1/switch/{uuid} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"syncId": "sync123",
"name": "Switch Name",
"unit": "kg"
}
'import requests
url = "https://app.variable.global/api/v1/switch/{uuid}"
payload = {
"syncId": "sync123",
"name": "Switch Name",
"unit": "kg"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({syncId: 'sync123', name: 'Switch Name', unit: 'kg'})
};
fetch('https://app.variable.global/api/v1/switch/{uuid}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.variable.global/api/v1/switch/{uuid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'syncId' => 'sync123',
'name' => 'Switch Name',
'unit' => 'kg'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.variable.global/api/v1/switch/{uuid}"
payload := strings.NewReader("{\n \"syncId\": \"sync123\",\n \"name\": \"Switch Name\",\n \"unit\": \"kg\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.variable.global/api/v1/switch/{uuid}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"syncId\": \"sync123\",\n \"name\": \"Switch Name\",\n \"unit\": \"kg\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.variable.global/api/v1/switch/{uuid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"syncId\": \"sync123\",\n \"name\": \"Switch Name\",\n \"unit\": \"kg\"\n}"
response = http.request(request)
puts response.read_body{
"uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"syncId": "sync123",
"name": "Switch Name",
"unit": "kg",
"image": "https://app.variable.global/uploads/image.jpg",
"sources": [
{
"uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Name"
}
],
"footprint": {
"CO2e": {
"productCarbonFootprint": "1234.5678",
"A1_A3": "1234.5678"
}
},
"impacts": {
"GWP-fossil": {
"unit": "kgCO2e",
"method": "Mixed",
"totalCarbonFootprint": "10",
"A1_A3": "10"
},
"ODP": {
"unit": "kgCFC11e",
"method": "EN15804+A2 - Core impact categories and indicators",
"A1_A3": "0.0000012"
},
"AP": {
"unit": "molH+e",
"method": "EN15804+A2 - Core impact categories and indicators",
"A1_A3": "2"
}
},
"created": "2021-01-01T00:00:00.000Z",
"updated": "2021-01-31T23:59:59.000Z"
}{
"message": "token expired"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
"Switch Name"
The unit code (e.g. kg, lbs, etc.). All unit codes can be found in the List Units endpoint.
"kg"
Response
A Switch
"Switch Name"
The unit code (e.g. kg, lbs, etc.). All unit codes can be found in the List Units endpoint.
"kg"
"https://app.variable.global/uploads/image.jpg"
Show child attributes
Show child attributes
Deprecated — use impacts["GWP-fossil"]. Kept for backwards compatibility.
Show child attributes
Show child attributes
Environmental impact indicators keyed by canonical code (e.g. GWP-fossil, ODP, AP). Which indicators appear is controlled by the impacts query parameter — by default only GWP-fossil is returned.
Show child attributes
Show child attributes
{
"GWP-fossil": {
"unit": "kgCO2e",
"method": "Mixed",
"totalCarbonFootprint": "10",
"A1_A3": "10"
},
"ODP": {
"unit": "kgCFC11e",
"method": "EN15804+A2 - Core impact categories and indicators",
"A1_A3": "0.0000012"
},
"AP": {
"unit": "molH+e",
"method": "EN15804+A2 - Core impact categories and indicators",
"A1_A3": "2"
}
}
ISO 8601 date
"2021-01-01T00:00:00.000Z"
ISO 8601 date
"2021-01-31T23:59:59.000Z"