create device
curl --request POST \
--url https://api.chatlevel.io/v1/devices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"webhookUrl": "<string>",
"webhookEvents": [],
"phoneNumber": "31612345678"
}
'import requests
url = "https://api.chatlevel.io/v1/devices"
payload = {
"name": "<string>",
"webhookUrl": "<string>",
"webhookEvents": [],
"phoneNumber": "31612345678"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
webhookUrl: '<string>',
webhookEvents: [],
phoneNumber: '31612345678'
})
};
fetch('https://api.chatlevel.io/v1/devices', 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.chatlevel.io/v1/devices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'webhookUrl' => '<string>',
'webhookEvents' => [
],
'phoneNumber' => '31612345678'
]),
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://api.chatlevel.io/v1/devices"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookEvents\": [],\n \"phoneNumber\": \"31612345678\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.chatlevel.io/v1/devices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookEvents\": [],\n \"phoneNumber\": \"31612345678\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatlevel.io/v1/devices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookEvents\": [],\n \"phoneNumber\": \"31612345678\"\n}"
response = http.request(request)
puts response.read_body{
"device": {
"id": 12345,
"name": "My Device",
"status": "qr",
"qr": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"webhookUrl": "https://example.com/webhook",
"webhookEvents": [
"message.received",
"message.sent"
],
"messagesSent": 0,
"subscription_status": "active",
"createdAt": "2024-01-15T10:30:00Z"
},
"status": {
"code": 200,
"message": "Device created successfully"
}
}{
"status": {
"code": 400,
"message": "Invalid JSON format"
}
}{
"status": "error",
"error": {
"code": 401,
"message": "Missing or invalid authorization header. Please provide a Bearer token."
}
}{
"status": {
"code": 403,
"message": "Device limit reached. You have 2 active device(s) and your subscription allows 2."
}
}{
"status": {
"code": 408,
"message": "Request timeout"
}
}{
"status": {
"code": 413,
"message": "Request payload too large"
}
}{
"status": {
"code": 429,
"message": "Rate limit exceeded. Maximum 100 requests per minute per user."
}
}{
"status": {
"code": 500,
"message": "Internal server error"
}
}devices
create device
Create a new device device
POST
/
devices
create device
curl --request POST \
--url https://api.chatlevel.io/v1/devices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"webhookUrl": "<string>",
"webhookEvents": [],
"phoneNumber": "31612345678"
}
'import requests
url = "https://api.chatlevel.io/v1/devices"
payload = {
"name": "<string>",
"webhookUrl": "<string>",
"webhookEvents": [],
"phoneNumber": "31612345678"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
webhookUrl: '<string>',
webhookEvents: [],
phoneNumber: '31612345678'
})
};
fetch('https://api.chatlevel.io/v1/devices', 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.chatlevel.io/v1/devices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'webhookUrl' => '<string>',
'webhookEvents' => [
],
'phoneNumber' => '31612345678'
]),
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://api.chatlevel.io/v1/devices"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookEvents\": [],\n \"phoneNumber\": \"31612345678\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.chatlevel.io/v1/devices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookEvents\": [],\n \"phoneNumber\": \"31612345678\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chatlevel.io/v1/devices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"webhookUrl\": \"<string>\",\n \"webhookEvents\": [],\n \"phoneNumber\": \"31612345678\"\n}"
response = http.request(request)
puts response.read_body{
"device": {
"id": 12345,
"name": "My Device",
"status": "qr",
"qr": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"webhookUrl": "https://example.com/webhook",
"webhookEvents": [
"message.received",
"message.sent"
],
"messagesSent": 0,
"subscription_status": "active",
"createdAt": "2024-01-15T10:30:00Z"
},
"status": {
"code": 200,
"message": "Device created successfully"
}
}{
"status": {
"code": 400,
"message": "Invalid JSON format"
}
}{
"status": "error",
"error": {
"code": 401,
"message": "Missing or invalid authorization header. Please provide a Bearer token."
}
}{
"status": {
"code": 403,
"message": "Device limit reached. You have 2 active device(s) and your subscription allows 2."
}
}{
"status": {
"code": 408,
"message": "Request timeout"
}
}{
"status": {
"code": 413,
"message": "Request payload too large"
}
}{
"status": {
"code": 429,
"message": "Rate limit exceeded. Maximum 100 requests per minute per user."
}
}{
"status": {
"code": 500,
"message": "Internal server error"
}
}Authorizations
API key authentication. Provide your API key as: Authorization: Bearer <api_key>
Body
application/json
User-friendly device name
Webhook URL for receiving events
Events to send to webhook (defaults to all). See webhook documentation for event payloads.
Available options:
connection.open, connection.closed, connection.auth, connection.timeout, connection.logout, message.received, message.sent, message.updated, message.deleted, call Phone number for pairing code authentication (alternative to QR code). Must be digits only, include country code, no + or spaces.
Example:
"31612345678"
⌘I
