---
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/pl/api-reference/receive-emails/reading/get-messages

Odbieranie e-maili: odczyt

# Get Messages

Odczytaj do 50 wiadomości po id, z treścią, listą załączników i nagłówkami.

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

Treść HTML jest zwracana surowa, bez sanityzacji. Zsanityzuj ją w kliencie przed wyświetleniem.

## Argumenty

- `ids` string[] opcjonalne
Do 50 id wiadomości.
- `id` string opcjonalne
Pojedyncze id wiadomości. Użyj tego lub `ids`.
- `include` string[] opcjonalne
Co dodać do każdej wiadomości: `body`, `attachments`, `headers`, `full_headers`. Domyślnie `["body","attachments"]`.
np. `["body", "headers", "attachments"]`

## Szybki 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);
```

## Odpowiedź

```
{
  "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": []
      }
    }
  ]
}
```

### Pola odpowiedzi

- `messages[]`
Pola koperty i stanu (`folders`, `labels`, `to`, `cc`, `bcc`, `references`, `snoozed_until`…) plus to, o co poprosiłeś w `include`.
- `messages[].body`
`{ html, text, external_images }`. HTML jest surowy i niesanityzowany.
- `messages[].headers`
`content_type`, `ip_address`, `is_tls`, `spf_success`, `dkim_success`, `dmarc_success`, `spam_score`, `list_unsubscribe`, `list_id`, `sender_provider` (skąd wysłano e-mail, weryfikowane przy doręczeniu), `rules_matched`…
- `messages[].agent_score / agent_reasons`
Tylko w `Agents` i `NotSubscribing`: wynik filtrowania i co go wywołało.
- `messages[].full_headers`
Wszystko z `headers` plus `headers_json`, `received_chain`, `spf_result`, `dkim_result`, `dmarc_result` i `spam_result`.
- `messages[].attachments`
Lista z `attachment_id`, `file_name`, `mime_type`, `size_bytes`, `inline`, `content_id` i polami `scan_*`. Sam plik nie jest dołączany.
- `not_found`
Id, które nie istnieją w tej skrzynce.

## Pobierz załącznik

Lista załączników nigdy nie zawiera danych binarnych. Weź `attachment_id` i pobierz plik przez trasę Raw Message.

GET `/v1/raw?message_id=<message_uid>&attachment_id=<attachment_id>`. Oryginalny typ MIME wraca w `X-Original-Content-Type`.

## Błędy

Błędy na poziomie HTTP zwracają `type`, `code` i `message`. Błędy oznaczone CMD wracają w wyniku polecenia, z HTTP 200.

- 401`TOKEN_EXPIRED`
Access token wygasł. Wywołaj Refresh Token i powtórz zapytanie.
- 401`INVALID_TOKEN`
Token jest uszkodzony, nieznany lub unieważniony.
- 429`RATE_LIMITED`
Ponad 15 zapytań/s lub 15 jednocześnie dla tego samego IP + skrzynki. Odczekaj liczbę sekund z Retry-After.
- CMD`INVALID_ARGS`
Brakuje wymaganego argumentu lub jest nieprawidłowy.
- CMD`INTERNAL`
Błąd serwera. Szczegóły trafiają tylko do logu serwera.
