Marcar mensaje como leído
curl --request POST \
--url https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "5511999999999",
"messageId": "019E6F1A93FE78DCB54332F9FF0CCAE7"
}
'import requests
url = "https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message"
payload = {
"phone": "5511999999999",
"messageId": "019E6F1A93FE78DCB54332F9FF0CCAE7"
}
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({phone: '5511999999999', messageId: '019E6F1A93FE78DCB54332F9FF0CCAE7'})
};
fetch('https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message', 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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message",
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([
'phone' => '5511999999999',
'messageId' => '019E6F1A93FE78DCB54332F9FF0CCAE7'
]),
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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message"
payload := strings.NewReader("{\n \"phone\": \"5511999999999\",\n \"messageId\": \"019E6F1A93FE78DCB54332F9FF0CCAE7\"\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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"5511999999999\",\n \"messageId\": \"019E6F1A93FE78DCB54332F9FF0CCAE7\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message")
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 \"phone\": \"5511999999999\",\n \"messageId\": \"019E6F1A93FE78DCB54332F9FF0CCAE7\"\n}"
response = http.request(request)
puts response.read_body{
"value": true
}
Mensajes
Marcar mensaje como leído
Marca como leído un mensaje recibido del contacto
POST
/
read-message
Marcar mensaje como leído
curl --request POST \
--url https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "5511999999999",
"messageId": "019E6F1A93FE78DCB54332F9FF0CCAE7"
}
'import requests
url = "https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message"
payload = {
"phone": "5511999999999",
"messageId": "019E6F1A93FE78DCB54332F9FF0CCAE7"
}
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({phone: '5511999999999', messageId: '019E6F1A93FE78DCB54332F9FF0CCAE7'})
};
fetch('https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message', 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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message",
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([
'phone' => '5511999999999',
'messageId' => '019E6F1A93FE78DCB54332F9FF0CCAE7'
]),
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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message"
payload := strings.NewReader("{\n \"phone\": \"5511999999999\",\n \"messageId\": \"019E6F1A93FE78DCB54332F9FF0CCAE7\"\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://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"5511999999999\",\n \"messageId\": \"019E6F1A93FE78DCB54332F9FF0CCAE7\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://zapi.omni.z-api.io/channels/{channel_id}/token/{channel_token}/read-message")
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 \"phone\": \"5511999999999\",\n \"messageId\": \"019E6F1A93FE78DCB54332F9FF0CCAE7\"\n}"
response = http.request(request)
puts response.read_body{
"value": true
}
Conceptos
Método para marcar como leído un mensaje que el canal recibió del contacto. Funciona en canales de WhatsApp Oficial (API oficial de Meta) y en canales de WhatsApp Web, con WhatsApp Web habilitado en el workspace.Atributos
| Atributo | Uso |
|---|---|
messageId | Obligatorio. El messageId que llegó en el webhook del mensaje recibido. |
phone | Obligatorio, como en Z-API, pero no se usa: el mensaje se encuentra por el messageId. |
application/x-www-form-urlencoded o multipart/form-data).
La respuesta de éxito es 200:
{ "value": true }
Diferencias con Z-API
- El
messageIdes el id del mensaje en Omni Z-API, el mismo que llega en el webhook. En el formato por defecto del webhook, esmessage._id. No es el id del mensaje en WhatsApp. - En WhatsApp Oficial, la API de Meta (Cloud API) también marca como leídos los mensajes anteriores de la conversación.
- Un mensaje enviado por el propio canal responde
200, sin efecto.
En WhatsApp Oficial,
send-text con delayTyping también marca como leído el último mensaje recibido del contacto, porque Meta solo muestra el “escribiendo” junto con la lectura. Si usas esa opción, el mensaje aparece leído sin llamar a esta ruta.Errores
| Status | error | Cuándo |
|---|---|---|
400 | phone is required / messageId is required | phone o messageId ausente o vacío |
400 | messageId is invalid | messageId es . o .. |
400 | Varía, como invalid character 'n' looking for beginning of object key string | No se pudo leer el cuerpo, como un JSON mal formado |
404 | message not found | El mensaje no existe o es de otro canal, con el canal conectado |
422 | message cannot be marked as read: it has no id at the channel provider | El mensaje no tiene id en WhatsApp |
422 | channel is disconnected | El canal está desconectado. Vale para cualquier messageId, incluso uno que no existe: la conexión se verifica antes que el mensaje |
422 | the channel provider refused the request | El proveedor del canal rechazó la lectura |
422 | instance subscription is not active | La suscripción del canal no está activa |
422 | Z-API (WhatsApp Web) instances are not enabled for this workspace | Canal de WhatsApp Web, con WhatsApp Web no habilitado en el workspace |
422 | the Z-API instance of this channel is not provisioned | Canal de WhatsApp Web cuya instancia aún no fue aprovisionada. Se verifica antes que el mensaje |
422 | message cannot be marked as read: its chat is not supported | Canal de WhatsApp Web, con un mensaje de un chat que la ruta no atiende |
422 | message action route is not available for <tipo> channels; ... | El canal no es WhatsApp Oficial ni WhatsApp Web, como un canal de Telegram |
502 | failed to mark message as read | Falla al marcar como leído |
available only on Z-API (WhatsApp Web) instances. Ese final es el mismo para toda ruta rechazada. Esta ruta también funciona en WhatsApp Oficial.
La API no repite la llamada después de un 502. Puedes llamar de nuevo.Autorizaciones
Cuerpo
application/json