E-mails ontvangen: lezen
Get Messages
Lees tot 50 berichten op id, met body, bijlagenlijst en headers.
https://g.sendcorex.com/v1command: get_messagesDe HTML-body komt ruw terug, zonder sanitizing. Sanitize hem in je client voordat je hem toont.
Argumenten
idsstring[]optioneelTot 50 bericht-id's.
idstringoptioneelEén bericht-id. Gebruik dit of
ids.includestring[]optioneelWat aan elk bericht wordt toegevoegd:
body,attachments,headers,full_headers. Standaard["body","attachments"].bijv.
["body", "headers", "attachments"]
Snel starten
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);Response
{
"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": []
}
}
]
}Responsevelden
messages[]De envelop- en statusvelden (
folders,labels,to,cc,bcc,references,snoozed_until…) plus wat je inincludevroeg.messages[].body{ html, text, external_images }. De HTML is ruw en niet gesanitized.messages[].headerscontent_type,ip_address,is_tls,spf_success,dkim_success,dmarc_success,spam_score,list_unsubscribe,list_id,sender_provider(vanwaar de e-mail is verstuurd, gecontroleerd bij aflevering),rules_matched…messages[].agent_score / agent_reasonsAlleen in
AgentsenNotSubscribing: de screeningscore en wat die veroorzaakte.messages[].full_headersAlles uit
headersplusheaders_json,received_chain,spf_result,dkim_result,dmarc_resultenspam_result.messages[].attachmentsEen lijst met
attachment_id,file_name,mime_type,size_bytes,inline,content_iden descan_*-velden. Het bestand zelf zit er niet bij.not_foundId's die niet in deze mailbox bestaan.
Een bijlage downloaden
De bijlagenlijst bevat nooit het binaire bestand. Neem de attachment_id en download het bestand met de route Raw Message.
GET /v1/raw?message_id=<message_uid>&attachment_id=<attachment_id>. Het oorspronkelijke MIME-type komt terug in X-Original-Content-Type.
Fouten
Fouten op HTTP-niveau geven type, code en message terug. Fouten met CMD komen terug in het resultaat van de opdracht, met HTTP 200.
- 401
TOKEN_EXPIREDDe access token is verlopen. Roep Refresh Token aan en herhaal het request.
- 401
INVALID_TOKENDe token is ongeldig, onbekend of ingetrokken.
- 429
RATE_LIMITEDMeer dan 15 requests/s of 15 tegelijk voor hetzelfde IP + mailbox. Wacht het aantal seconden uit Retry-After.
- CMD
INVALID_ARGSEen verplicht argument ontbreekt of is ongeldig.
- CMD
INTERNALServerfout. Het detail wordt alleen in het serverlog geschreven.