Salvar etiquetas para a conversa
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"
}
Etiquetas
Salvar Rótulos para o Chat
Adicionar ou remover um rótulo de um chat específico
PUT
/
api
/
{session}
/
labels
/
chats
/
{chatId}
Salvar etiquetas para a conversa
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"
}
Descrição
Este endpoint permite adicionar ou remover um rótulo de um chat específico, permitindo organizar e categorizar suas conversas.Parâmetros de URL
ID único da sessão WhatsApp
ID do chat (JID do contato ou grupo)
Corpo da Requisição
ID do rótulo a ser adicionado ou removido
Ação a ser executada: “add” (adicionar) ou “remove” (remover)
Resposta
Indica se a operação foi executada com sucesso
{
"success": true,
"chatId": "5511999999999@s.whatsapp.net",
"labelId": "label123",
"action": "add"
}
Códigos de Status
200- Operação executada com sucesso400- Parâmetros inválidos401- Não autorizado404- Chat ou rótulo não encontrado
Exemplo de Uso
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
