Setel konfigurasi webhook perangkat
curl --request PATCH \
--url http://localhost:3000/devices/{device_id}/webhook \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"webhook_url": "https://example.com/webhook",
"webhook_secret": "super-secret-key",
"webhook_events": "message,message.ack",
"webhook_insecure_skip_verify": false
}
'import requests
url = "http://localhost:3000/devices/{device_id}/webhook"
payload = {
"webhook_url": "https://example.com/webhook",
"webhook_secret": "super-secret-key",
"webhook_events": "message,message.ack",
"webhook_insecure_skip_verify": False
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
webhook_url: 'https://example.com/webhook',
webhook_secret: 'super-secret-key',
webhook_events: 'message,message.ack',
webhook_insecure_skip_verify: false
})
};
fetch('http://localhost:3000/devices/{device_id}/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/devices/{device_id}/webhook",
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([
'webhook_url' => 'https://example.com/webhook',
'webhook_secret' => 'super-secret-key',
'webhook_events' => 'message,message.ack',
'webhook_insecure_skip_verify' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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 := "http://localhost:3000/devices/{device_id}/webhook"
payload := strings.NewReader("{\n \"webhook_url\": \"https://example.com/webhook\",\n \"webhook_secret\": \"super-secret-key\",\n \"webhook_events\": \"message,message.ack\",\n \"webhook_insecure_skip_verify\": false\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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("http://localhost:3000/devices/{device_id}/webhook")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"webhook_url\": \"https://example.com/webhook\",\n \"webhook_secret\": \"super-secret-key\",\n \"webhook_events\": \"message,message.ack\",\n \"webhook_insecure_skip_verify\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/devices/{device_id}/webhook")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"webhook_url\": \"https://example.com/webhook\",\n \"webhook_secret\": \"super-secret-key\",\n \"webhook_events\": \"message,message.ack\",\n \"webhook_insecure_skip_verify\": false\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"code": "SUCCESS",
"message": "Device webhook updated",
"results": {
"device_id": "my-device",
"webhook_url": "https://example.com/webhook",
"webhook_secret": "super-secret-key",
"webhook_events": "message,message.ack",
"webhook_insecure_skip_verify": false
}
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}{
"code": 404,
"message": "Chat not found",
"results": null
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "you are not loggin",
"results": null
}device
Setel konfigurasi webhook perangkat
Setel konfigurasi webhook kustom untuk perangkat tertentu. Jika disetel, event webhook untuk perangkat ini
akan dikirim ke URL ini sebagai pengganti URL webhook global. Pengaturan webhook_secret,
webhook_events, dan webhook_insecure_skip_verify pada tingkat perangkat menggantikan pengaturan webhook global untuk perangkat ini.
Setel ke string kosong untuk menghapusnya dan menggunakan webhook global.
PATCH
/
devices
/
{device_id}
/
webhook
Setel konfigurasi webhook perangkat
curl --request PATCH \
--url http://localhost:3000/devices/{device_id}/webhook \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"webhook_url": "https://example.com/webhook",
"webhook_secret": "super-secret-key",
"webhook_events": "message,message.ack",
"webhook_insecure_skip_verify": false
}
'import requests
url = "http://localhost:3000/devices/{device_id}/webhook"
payload = {
"webhook_url": "https://example.com/webhook",
"webhook_secret": "super-secret-key",
"webhook_events": "message,message.ack",
"webhook_insecure_skip_verify": False
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
webhook_url: 'https://example.com/webhook',
webhook_secret: 'super-secret-key',
webhook_events: 'message,message.ack',
webhook_insecure_skip_verify: false
})
};
fetch('http://localhost:3000/devices/{device_id}/webhook', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/devices/{device_id}/webhook",
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([
'webhook_url' => 'https://example.com/webhook',
'webhook_secret' => 'super-secret-key',
'webhook_events' => 'message,message.ack',
'webhook_insecure_skip_verify' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"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 := "http://localhost:3000/devices/{device_id}/webhook"
payload := strings.NewReader("{\n \"webhook_url\": \"https://example.com/webhook\",\n \"webhook_secret\": \"super-secret-key\",\n \"webhook_events\": \"message,message.ack\",\n \"webhook_insecure_skip_verify\": false\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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("http://localhost:3000/devices/{device_id}/webhook")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"webhook_url\": \"https://example.com/webhook\",\n \"webhook_secret\": \"super-secret-key\",\n \"webhook_events\": \"message,message.ack\",\n \"webhook_insecure_skip_verify\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/devices/{device_id}/webhook")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"webhook_url\": \"https://example.com/webhook\",\n \"webhook_secret\": \"super-secret-key\",\n \"webhook_events\": \"message,message.ack\",\n \"webhook_insecure_skip_verify\": false\n}"
response = http.request(request)
puts response.read_body{
"status": 200,
"code": "SUCCESS",
"message": "Device webhook updated",
"results": {
"device_id": "my-device",
"webhook_url": "https://example.com/webhook",
"webhook_secret": "super-secret-key",
"webhook_events": "message,message.ack",
"webhook_insecure_skip_verify": false
}
}{
"code": 400,
"message": "field cannot be blank",
"results": null
}{
"code": 404,
"message": "Chat not found",
"results": null
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "you are not loggin",
"results": null
}Otorisasi
Body
application/json
