curl --request POST \
--url https://api.dashboard.knotapi.com/oauth/device/code \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c \
--data 'scope=webhooks:read webhooks:write'import requests
url = "https://api.dashboard.knotapi.com/oauth/device/code"
payload = {
"client_id": "9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c",
"scope": "webhooks:read webhooks:write"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
client_id: '9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c',
scope: 'webhooks:read webhooks:write'
})
};
fetch('https://api.dashboard.knotapi.com/oauth/device/code', 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://api.dashboard.knotapi.com/oauth/device/code",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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://api.dashboard.knotapi.com/oauth/device/code"
payload := strings.NewReader("client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dashboard.knotapi.com/oauth/device/code")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dashboard.knotapi.com/oauth/device/code")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite"
response = http.request(request)
puts response.read_bodyRequest Device Code
Request a device code to start the device authorization flow.
curl --request POST \
--url https://api.dashboard.knotapi.com/oauth/device/code \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c \
--data 'scope=webhooks:read webhooks:write'import requests
url = "https://api.dashboard.knotapi.com/oauth/device/code"
payload = {
"client_id": "9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c",
"scope": "webhooks:read webhooks:write"
}
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
client_id: '9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c',
scope: 'webhooks:read webhooks:write'
})
};
fetch('https://api.dashboard.knotapi.com/oauth/device/code', 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://api.dashboard.knotapi.com/oauth/device/code",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite",
CURLOPT_HTTPHEADER => [
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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://api.dashboard.knotapi.com/oauth/device/code"
payload := strings.NewReader("client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.dashboard.knotapi.com/oauth/device/code")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dashboard.knotapi.com/oauth/device/code")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "client_id=9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c&scope=webhooks%3Aread%20webhooks%3Awrite"
response = http.request(request)
puts response.read_bodyBody
The input parameters required for requesting a device code.
Your client ID for the environment you want to manage, found in the Knot Dashboard. Never send your secret.
"9f3c2a1e-6b7d-4e8f-a2c4-5d6e7f8a9b0c"
Response
Successful request.
Code to exchange for an access token. Do not show it to the user.
"def50200a1b2c3d4e5f6"
Code for the user to enter in the Knot Dashboard. Eight letters; a hyphen is optional.
"WDJBMJHT"
URL where the user approves the request.
"https://api.dashboard.knotapi.com/oauth/device"
The verification_uri with the user_code. The approval page still asks the user to enter the code.
"https://api.dashboard.knotapi.com/oauth/device?user_code=WDJBMJHT"
Seconds until the device_code and user_code expire.
600
Minimum seconds to wait between polling requests.
5
Was this page helpful?