Skip to main content
GET
https://api.enviaai.app
/
v1
/
messages
Histórico de Mensagens
curl --request GET \
  --url https://api.enviaai.app/v1/messages \
  --header 'Authorization: Bearer <token>'
{
  "success": true,
  "data": [
    {
      "messageId": "msg_001",
      "direction": "inbound",
      "type": "text",
      "content": "Olá, preciso de ajuda",
      "from": "5511999999999",
      "timestamp": "2026-02-03T12:00:00.000Z",
      "status": "read"
    },
    {
      "messageId": "msg_002",
      "direction": "outbound",
      "type": "text",
      "content": "Olá! Como posso ajudar?",
      "to": "5511999999999",
      "timestamp": "2026-02-03T12:00:30.000Z",
      "status": "delivered"
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "msg_000"
  }
}

Query Parameters

instanceId
string
required
ID da instância
chatId
string
ID do chat (opcional, filtra por conversa)
phone
string
Número do contato (alternativa ao chatId)
limit
number
default:"50"
Máximo de mensagens (1-100)
before
string
Cursor para paginação (messageId)
after
string
Buscar mensagens após este ID

Response

data
array
Lista de mensagens
data[].messageId
string
ID da mensagem
data[].direction
string
inbound ou outbound
data[].type
string
Tipo: text, image, video, audio, document
data[].content
string
Conteúdo da mensagem
data[].timestamp
string
Data/hora da mensagem
pagination
object
Info de paginação

Exemplo

const messages = await client.messages.list({
  instanceId: 'inst_abc123',
  phone: '5511999999999',
  limit: 50
});

messages.data.forEach(msg => {
  const arrow = msg.direction === 'inbound' ? '←' : '→';
  console.log(`${arrow} ${msg.content}`);
});
{
  "success": true,
  "data": [
    {
      "messageId": "msg_001",
      "direction": "inbound",
      "type": "text",
      "content": "Olá, preciso de ajuda",
      "from": "5511999999999",
      "timestamp": "2026-02-03T12:00:00.000Z",
      "status": "read"
    },
    {
      "messageId": "msg_002",
      "direction": "outbound",
      "type": "text",
      "content": "Olá! Como posso ajudar?",
      "to": "5511999999999",
      "timestamp": "2026-02-03T12:00:30.000Z",
      "status": "delivered"
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "msg_000"
  }
}

Paginação

Para buscar mais mensagens, use o cursor:
let cursor = null;
let allMessages = [];

do {
  const response = await client.messages.list({
    instanceId: 'inst_abc123',
    phone: '5511999999999',
    before: cursor
  });

  allMessages.push(...response.data);
  cursor = response.pagination.nextCursor;
} while (response.pagination.hasMore);