cURL
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" } }
Liste mensagens de uma conversa
inbound
outbound
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}`); });
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);