Ricevi email: lettura
Get Messages
Leggi fino a 50 messaggi per id, con corpo, elenco degli allegati e header.
https://g.sendcorex.com/v1command: get_messagesIl corpo HTML viene restituito grezzo, senza sanificazione. Sanificalo nel tuo client prima di visualizzarlo.
Argomenti
idsstring[]facoltativoFino a 50 id di messaggi.
idstringfacoltativoUn singolo id di messaggio. Usa questo o
ids.includestring[]facoltativoCosa aggiungere a ogni messaggio:
body,attachments,headers,full_headers. Predefinito["body","attachments"].es.
["body", "headers", "attachments"]
Avvio rapido
import axios from 'axios';
const response = await axios.post(
'https://g.sendcorex.com/v1',
{
commands: [
{
command: "get_messages",
args: {
ids: [
"Vj0xQUJDMTIz"
],
include: [
"body",
"headers",
"attachments"
]
}
}
]
},
{ headers: { Authorization: process.env.SENDCOREX_TOKEN } },
);
const [result] = response.data.results;
if (result.type !== 'SUCCESS') throw new Error(`${result.code}: ${result.message}`);
console.log(result.data);Risposta
{
"type": "SUCCESS",
"results": [
{
"command": "get_messages",
"id": "0",
"type": "SUCCESS",
"data": {
"messages": [
{
"message_uid": "Vj0xQUJDMTIz",
"thread_id": "thr_9a1c4e72",
"message_id": "<3f2a1b4c@SCOREX123MB45.prd.sendcorex.com>",
"folders": [
"INBOX"
],
"labels": [
"cliente-vip"
],
"from_name": "Ana Costa",
"from_email": "ana@client.com",
"to": [
{
"email": "you@yourdomain.com"
}
],
"cc": [],
"bcc": [],
"subject": "Invoice for September",
"is_read": false,
"is_starred": false,
"is_important": false,
"snoozed_until": null,
"received_at": "2026-10-09T14:21:07Z",
"body": {
"html": "<p>Hi, attached is the invoice.</p>",
"text": "Hi, attached is the invoice.",
"external_images": false
},
"headers": {
"content_type": "multipart/mixed",
"ip_address": "203.0.113.10",
"is_tls": true,
"spf_success": true,
"dkim_success": true,
"dmarc_success": true,
"spam_score": 0.4,
"list_unsubscribe": null
},
"attachments": [
{
"attachment_id": "Vj0xQVRUMDE",
"file_name": "invoice.pdf",
"mime_type": "application/pdf",
"size_bytes": 48213,
"inline": false,
"content_id": null
}
]
}
],
"not_found": []
}
}
]
}Campi della risposta
messages[]I campi di busta e stato (
folders,labels,to,cc,bcc,references,snoozed_until…) più ciò che hai chiesto ininclude.messages[].body{ html, text, external_images }. L'HTML è grezzo e non sanificato.messages[].headerscontent_type,ip_address,is_tls,spf_success,dkim_success,dmarc_success,spam_score,list_unsubscribe,list_id,sender_provider(da dove è stata inviata l'email, verificato alla consegna),rules_matched…messages[].agent_score / agent_reasonsSolo in
AgentseNotSubscribing: il punteggio del filtro e cosa l'ha attivato.messages[].full_headersTutto ciò che è in
headerspiùheaders_json,received_chain,spf_result,dkim_result,dmarc_resultespam_result.messages[].attachmentsUna lista con
attachment_id,file_name,mime_type,size_bytes,inline,content_ide i campiscan_*. Il file non è incluso.not_foundId che non esistono in questa casella.
Scarica un allegato
L'elenco degli allegati non contiene mai il binario. Prendi l'attachment_id e scarica il file con la rotta Raw Message.
GET /v1/raw?message_id=<message_uid>&attachment_id=<attachment_id>. Il tipo MIME originale torna in X-Original-Content-Type.
Errori
Gli errori a livello HTTP restituiscono type, code e message. Gli errori marcati CMD tornano dentro il risultato del comando, con HTTP 200.
- 401
TOKEN_EXPIREDL'access token è scaduto. Chiama Refresh Token e ripeti la richiesta.
- 401
INVALID_TOKENIl token è malformato, sconosciuto o revocato.
- 429
RATE_LIMITEDPiù di 15 richieste/s o 15 in corso per la stessa IP + casella. Attendi i secondi indicati in Retry-After.
- CMD
INVALID_ARGSUn argomento obbligatorio manca o non è valido.
- CMD
INTERNALErrore del server. Il dettaglio viene scritto solo nel log del server.