Receive Emails: Reading
Get Messages
Read up to 50 messages by id, with their body, attachments list and headers.
https://g.sendcorex.com/v1command: get_messagesThe HTML body is returned raw, without sanitizing. Sanitize it in your client before rendering it.
Arguments
idsstring[]optionalUp to 50 message ids.
idstringoptionalA single message id. Use this or
ids.includestring[]optionalWhat to add to each message:
body,attachments,headers,full_headers. Defaults to["body","attachments"].e.g.
["body", "headers", "attachments"]
Quick start
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": []
}
}
]
}Response fields
messages[]The envelope and state fields (
folders,labels,to,cc,bcc,references,snoozed_until…) plus what you asked for ininclude.messages[].body{ html, text, external_images }. The HTML is raw and unsanitized.messages[].headerscontent_type,ip_address,is_tls,spf_success,dkim_success,dmarc_success,spam_score,list_unsubscribe…messages[].full_headersEverything in
headersplusheaders_json,received_chain,spf_result,dkim_result,dmarc_resultandspam_result.messages[].attachmentsA list with
attachment_id,file_name,mime_type,size_bytes,inline,content_idand thescan_*fields. The file itself is not included.not_foundIds that do not exist in this mailbox.
Download an attachment
The attachment list never carries the binary. Take the attachment_id and download the file with the Raw Message route.
GET /v1/raw?message_id=<message_uid>&attachment_id=<attachment_id>. The original MIME type comes back in X-Original-Content-Type.
Errors
HTTP-level errors return type, code and message. Errors marked CMD come back inside the command result, with HTTP 200.
- 401
TOKEN_EXPIREDThe access token has expired. Call Refresh Token and repeat the request.
- 401
INVALID_TOKENThe token is malformed, unknown or revoked.
- 429
RATE_LIMITEDMore than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.
- CMD
INVALID_ARGSA required argument is missing or invalid.
- CMD
INTERNALServer error. The detail is only written to the server log.