Save labels for the conversation
curl --request PUT \
--url https://{host}/api/{session}/labels/chats/{chatId} \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"labels": [
{
"id": "1"
}
]
}
'import requests
url = "https://{host}/api/{session}/labels/chats/{chatId}"
payload = { "labels": [{ "id": "1" }] }
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({labels: [{id: '1'}]})
};
fetch('https://{host}/api/{session}/labels/chats/{chatId}', 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://{host}/api/{session}/labels/chats/{chatId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'labels' => [
[
'id' => '1'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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://{host}/api/{session}/labels/chats/{chatId}"
payload := strings.NewReader("{\n \"labels\": [\n {\n \"id\": \"1\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("apikey", "<api-key>")
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.put("https://{host}/api/{session}/labels/chats/{chatId}")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"labels\": [\n {\n \"id\": \"1\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/labels/chats/{chatId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"labels\": [\n {\n \"id\": \"1\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"chatId": "5511999999999@s.whatsapp.net",
"labelId": "label123",
"action": "add"
}
Labels
Save Labels for the Chat
Add or remove a label from a specific chat
PUT
/
api
/
{session}
/
labels
/
chats
/
{chatId}
Save labels for the conversation
curl --request PUT \
--url https://{host}/api/{session}/labels/chats/{chatId} \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"labels": [
{
"id": "1"
}
]
}
'import requests
url = "https://{host}/api/{session}/labels/chats/{chatId}"
payload = { "labels": [{ "id": "1" }] }
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({labels: [{id: '1'}]})
};
fetch('https://{host}/api/{session}/labels/chats/{chatId}', 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://{host}/api/{session}/labels/chats/{chatId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'labels' => [
[
'id' => '1'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$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://{host}/api/{session}/labels/chats/{chatId}"
payload := strings.NewReader("{\n \"labels\": [\n {\n \"id\": \"1\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("apikey", "<api-key>")
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.put("https://{host}/api/{session}/labels/chats/{chatId}")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"labels\": [\n {\n \"id\": \"1\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/labels/chats/{chatId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"labels\": [\n {\n \"id\": \"1\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"chatId": "5511999999999@s.whatsapp.net",
"labelId": "label123",
"action": "add"
}
Description
This endpoint allows you to add or remove a label from a specific chat, allowing you to organize and categorize your chats.URL Parameters
WhatsApp unique session ID
ID of the chat (JID of the contact or group)
Request Body
ID of the label to be added or removed
Action to be executed: “add” or “remove”
Response
Indicates if the operation was executed successfully
{
"success": true,
"chatId": "5511999999999@s.whatsapp.net",
"labelId": "label123",
"action": "add"
}
Status Codes
200- Operation executed successfully400- Invalid parameters401- Unauthorized404- Chat or label not found
Usage Example
curl -X PUT https://api.wappfy.com.br/api/my-session/labels/chats/5511999999999@s.whatsapp.net \
-H "Content-Type: application/json" \
-d '{
"labelId": "label123",
"action": "add"
}'
const session = 'my-session';
const chatId = '5511999999999@s.whatsapp.net';
const response = await fetch(`https://api.wappfy.com.br/api/${session}/labels/chats/${encodeURIComponent(chatId)}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
labelId: 'label123',
action: 'add'
})
});
const data = await response.json();
console.log(data);
import requests
from urllib.parse import quote
session = 'my-session'
chat_id = '5511999999999@s.whatsapp.net'
response = requests.put(
f'https://api.wappfy.com.br/api/{session}/labels/chats/{quote(chat_id)}',
json={
'labelId': 'label123',
'action': 'add'
}
)
data = response.json()
print(data)
⌘I
