---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://docs.sendcorex.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.sendcorex.com/llms.txt"
---

Source: https://docs.sendcorex.com/api-reference/receive-emails/reading/get-messages

Receive Emails: Reading

# Get Messages

Read up to 50 messages by id, with their body, attachments list and headers.

POST `https://g.sendcorex.com/v1` command: get_messages

The HTML body is returned raw, without sanitizing. Sanitize it in your client before rendering it.

## Arguments

- `ids` string[] optional
Up to 50 message ids.
- `id` string optional
A single message id. Use this or `ids`.
- `include` string[] optional
What 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 in `include`.
- `messages[].body`
`{ html, text, external_images }`. The HTML is raw and unsanitized.
- `messages[].headers`
`content_type`, `ip_address`, `is_tls`, `spf_success`, `dkim_success`, `dmarc_success`, `spam_score`, `list_unsubscribe`, `list_id`, `sender_provider` (where the email was sent from, verified on delivery), `rules_matched`…
- `messages[].agent_score / agent_reasons`
Only in `Agents` and `NotSubscribing`: the screening score and what triggered it.
- `messages[].full_headers`
Everything in `headers` plus `headers_json`, `received_chain`, `spf_result`, `dkim_result`, `dmarc_result` and `spam_result`.
- `messages[].attachments`
A list with `attachment_id`, `file_name`, `mime_type`, `size_bytes`, `inline`, `content_id` and the `scan_*` fields. The file itself is not included.
- `not_found`
Ids 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_EXPIRED`
The access token has expired. Call Refresh Token and repeat the request.
- 401`INVALID_TOKEN`
The token is malformed, unknown or revoked.
- 429`RATE_LIMITED`
More than 15 requests/s or 15 in flight for the same IP + mailbox. Wait the number of seconds in Retry-After.
- CMD`INVALID_ARGS`
A required argument is missing or invalid.
- CMD`INTERNAL`
Server error. The detail is only written to the server log.
