Nesta área
Messages
Send and read messages, including SSE streaming.
List messages
get/v1/public/conversations/{id}/messages
Returns messages of a conversation in cursor-paginated form.
Parâmetros
idstringobrigatório· caminholimitnumberopcional· consulta- Maximum number of messages to return (1–100).
cursorstringopcional· consulta- Pagination cursor — pass
nextCursorfrom the previous response. orderasc | descopcional· consulta- Sort order. Default
asc(oldest first).
| Campo | Onde | Tipo | Descrição |
|---|---|---|---|
idobrigatório | caminho | string | |
limitopcional | consulta | number | Maximum number of messages to return (1–100). |
cursoropcional | consulta | string | Pagination cursor — pass nextCursor from the previous response. |
orderopcional | consulta | asc | desc | Sort order. Default asc (oldest first). |
Respostas
200
Exemplos
bash
curl -X GET "https://api.cognizy.ai/api/v1/public/conversations/<id>/messages" \
-H "Authorization: Bearer $COGNIZY_API_KEY"Send message
post/v1/public/conversations/{id}/messages
Aceita Idempotency-Key
Sends a contact message and returns the AI reply (when AI is active on the conversation). Use the /stream variant for SSE streaming.
Parâmetros
idstringobrigatório· caminho
| Campo | Onde | Tipo | Descrição |
|---|---|---|---|
idobrigatório | caminho | string |
Corpo (JSON)obrigatório
tostringobrigatório- Recipient in E.164 (digits)
instanceIdstringopcional- Send from this specific WhatsApp number (WhatsAppInstance id). Required in practice for multi-number organizations; omit it and the oldest-created connected number of the selected channel is used. Takes precedence over
channel. channelstringopcional- Which WhatsApp channel to send through when no instanceId is given. CLOUD_API is the official Meta channel (supports templates, subject to the 24h session window). EVOLUTION is the unofficial channel (free-form text/media only, no templates, subject to the instance's daily anti-ban cap). Defaults to CLOUD_API.
CLOUD_APIEVOLUTION typestringobrigatórioTEXTMEDIATEMPLATEtextstringopcional- Body for type=TEXT
mediaobjectopcionalmedia.urlstringobrigatóriomedia.typestringobrigatórioimagevideodocumentaudiomedia.captionstringopcionaltemplateobjectopcionaltemplate.namestringobrigatório- Approved Meta template name
template.languagestringopcionaltemplate.variablesstring[]opcional- Positional body variables, in order
| Campo | Tipo | Descrição |
|---|---|---|
toobrigatório | string | Recipient in E.164 (digits) |
instanceIdopcional | string | Send from this specific WhatsApp number (WhatsAppInstance id). Required in practice for multi-number organizations; omit it and the oldest-created connected number of the selected channel is used. Takes precedence over channel. |
channelopcional | string | Which WhatsApp channel to send through when no instanceId is given. CLOUD_API is the official Meta channel (supports templates, subject to the 24h session window). EVOLUTION is the unofficial channel (free-form text/media only, no templates, subject to the instance's daily anti-ban cap). Defaults to CLOUD_API.CLOUD_APIEVOLUTION |
typeobrigatório | string | TEXTMEDIATEMPLATE |
textopcional | string | Body for type=TEXT |
mediaopcional | object | |
media.urlobrigatório | string | |
media.typeobrigatório | string | imagevideodocumentaudio |
media.captionopcional | string | |
templateopcional | object | |
template.nameobrigatório | string | Approved Meta template name |
template.languageopcional | string | |
template.variablesopcional | string[] | Positional body variables, in order |
Respostas
201
Exemplos
bash
curl -X POST "https://api.cognizy.ai/api/v1/public/conversations/<id>/messages" \
-H "Authorization: Bearer $COGNIZY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"to": "5511999999999",
"instanceId": "clx7k2p9a0001qwerty",
"channel": "CLOUD_API",
"type": "TEXT",
"text": "Olá! Seu pedido saiu.",
"media": {
"url": "https://example.com/file.pdf",
"type": "image",
"caption": "texto"
},
"template": {
"name": "order_update",
"language": "pt_BR",
"variables": [
"Maria",
"#1234"
]
}
}'Send message (streaming SSE)
post/v1/public/conversations/{id}/messages/stream
Streaming (SSE)Aceita Idempotency-Key
Sends a contact message and returns the AI reply via Server-Sent Events. Event types: token, done, error. Heartbeat every 15s as : keepalive comments.
Parâmetros
idstringobrigatório· caminho- Conversation ID
| Campo | Onde | Tipo | Descrição |
|---|---|---|---|
idobrigatório | caminho | string | Conversation ID |
Corpo (JSON)obrigatório
tostringobrigatório- Recipient in E.164 (digits)
instanceIdstringopcional- Send from this specific WhatsApp number (WhatsAppInstance id). Required in practice for multi-number organizations; omit it and the oldest-created connected number of the selected channel is used. Takes precedence over
channel. channelstringopcional- Which WhatsApp channel to send through when no instanceId is given. CLOUD_API is the official Meta channel (supports templates, subject to the 24h session window). EVOLUTION is the unofficial channel (free-form text/media only, no templates, subject to the instance's daily anti-ban cap). Defaults to CLOUD_API.
CLOUD_APIEVOLUTION typestringobrigatórioTEXTMEDIATEMPLATEtextstringopcional- Body for type=TEXT
mediaobjectopcionalmedia.urlstringobrigatóriomedia.typestringobrigatórioimagevideodocumentaudiomedia.captionstringopcionaltemplateobjectopcionaltemplate.namestringobrigatório- Approved Meta template name
template.languagestringopcionaltemplate.variablesstring[]opcional- Positional body variables, in order
| Campo | Tipo | Descrição |
|---|---|---|
toobrigatório | string | Recipient in E.164 (digits) |
instanceIdopcional | string | Send from this specific WhatsApp number (WhatsAppInstance id). Required in practice for multi-number organizations; omit it and the oldest-created connected number of the selected channel is used. Takes precedence over channel. |
channelopcional | string | Which WhatsApp channel to send through when no instanceId is given. CLOUD_API is the official Meta channel (supports templates, subject to the 24h session window). EVOLUTION is the unofficial channel (free-form text/media only, no templates, subject to the instance's daily anti-ban cap). Defaults to CLOUD_API.CLOUD_APIEVOLUTION |
typeobrigatório | string | TEXTMEDIATEMPLATE |
textopcional | string | Body for type=TEXT |
mediaopcional | object | |
media.urlobrigatório | string | |
media.typeobrigatório | string | imagevideodocumentaudio |
media.captionopcional | string | |
templateopcional | object | |
template.nameobrigatório | string | Approved Meta template name |
template.languageopcional | string | |
template.variablesopcional | string[] | Positional body variables, in order |
Respostas
200SSE stream with `token`, `done`, and (on failure) `error` events400Missing or invalid `message`404Conversation not found429Concurrent stream limit (20 per API key) reached
Exemplos
bash
curl -X POST "https://api.cognizy.ai/api/v1/public/conversations/<id>/messages/stream" \
-H "Authorization: Bearer $COGNIZY_API_KEY" \
-H "Accept: text/event-stream" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"to": "5511999999999",
"instanceId": "clx7k2p9a0001qwerty",
"channel": "CLOUD_API",
"type": "TEXT",
"text": "Olá! Seu pedido saiu.",
"media": {
"url": "https://example.com/file.pdf",
"type": "image",
"caption": "texto"
},
"template": {
"name": "order_update",
"language": "pt_BR",
"variables": [
"Maria",
"#1234"
]
}
}' \
--no-buffer