Obter mensagens na conversa
curl --request GET \
--url https://{host}/api/{session}/chats/{chatId}/messages \
--header 'apikey: <api-key>'import requests
url = "https://{host}/api/{session}/chats/{chatId}/messages"
headers = {"apikey": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {apikey: '<api-key>'}};
fetch('https://{host}/api/{session}/chats/{chatId}/messages', 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}/chats/{chatId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/{session}/chats/{chatId}/messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apikey", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{host}/api/{session}/chats/{chatId}/messages")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/chats/{chatId}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["apikey"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA",
"timestamp": 1666943582,
"from": "5511999999999@c.us",
"fromMe": true,
"source": "api",
"to": "5511999999999@c.us",
"participant": "<string>",
"body": "<string>",
"hasMedia": true,
"ack": -1,
"ackName": "<string>",
"media": {
"url": "http://localhost:3000/api/files/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga",
"mimetype": "audio/jpeg",
"filename": "example.pdf",
"s3": {
"Bucket": "my-bucket",
"Key": "default/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga"
},
"error": null
},
"author": "<string>",
"location": {
"latitude": "<string>",
"longitude": "<string>",
"description": "<string>"
},
"vCards": [
"<string>"
],
"_data": {},
"replyTo": {
"id": "AAAAAAAAAAAAAAAAAAAA",
"participant": "5511999999999@c.us",
"body": "Hello!",
"_data": {}
}
}
]Conversas
Listar Mensagens
O parâmetro deve ser o instanceName da sessão.
GET
/
api
/
{session}
/
chats
/
{chatId}
/
messages
Obter mensagens na conversa
curl --request GET \
--url https://{host}/api/{session}/chats/{chatId}/messages \
--header 'apikey: <api-key>'import requests
url = "https://{host}/api/{session}/chats/{chatId}/messages"
headers = {"apikey": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {apikey: '<api-key>'}};
fetch('https://{host}/api/{session}/chats/{chatId}/messages', 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}/chats/{chatId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://{host}/api/{session}/chats/{chatId}/messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("apikey", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{host}/api/{session}/chats/{chatId}/messages")
.header("apikey", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{host}/api/{session}/chats/{chatId}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["apikey"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA",
"timestamp": 1666943582,
"from": "5511999999999@c.us",
"fromMe": true,
"source": "api",
"to": "5511999999999@c.us",
"participant": "<string>",
"body": "<string>",
"hasMedia": true,
"ack": -1,
"ackName": "<string>",
"media": {
"url": "http://localhost:3000/api/files/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga",
"mimetype": "audio/jpeg",
"filename": "example.pdf",
"s3": {
"Bucket": "my-bucket",
"Key": "default/false_11111111111@c.us_AAAAAAAAAAAAAAAAAAAA.oga"
},
"error": null
},
"author": "<string>",
"location": {
"latitude": "<string>",
"longitude": "<string>",
"description": "<string>"
},
"vCards": [
"<string>"
],
"_data": {},
"replyTo": {
"id": "AAAAAAAAAAAAAAAAAAAA",
"participant": "5511999999999@c.us",
"body": "Hello!",
"_data": {}
}
}
]Query Parameters
Response
200 - application/json
