---
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/list-messages

Odbieranie e-maili: odczyt

# List Messages

Wyświetl wiadomości pojedynczo, bez grupowania w rozmowy. Możesz też wyświetlić wszystkie wiadomości z etykietą.

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

## Argumenty

- `folder` string opcjonalne
Folder do wyświetlenia. Domyślnie `INBOX`.
- `limit` number opcjonalne
Rozmiar strony, od 1 do 100. Domyślnie 25.
- `cursor` string opcjonalne
`next_cursor` z poprzedniej strony.
- `is_read` boolean opcjonalne
Filtruj po stanie przeczytania. Ten filtr skanuje folder.
- `is_starred` boolean opcjonalne
Filtruj po gwiazdce. Ten filtr skanuje folder.
- `is_important` boolean opcjonalne
Filtruj po ważności. Ten filtr skanuje folder.
- `is_spam` boolean opcjonalne
Filtruj po spamie. Ten filtr skanuje folder.
- `after` string opcjonalne
Tylko wiadomości odebrane tego dnia lub później. RFC 3339, `YYYY-MM-DD` (UTC) lub epoch w milisekundach.
- `before` string opcjonalne
Tylko wiadomości odebrane przed tą datą. Te same formaty co `after`.
- `label` string opcjonalne
Wyświetl wiadomości z tą etykietą we wszystkich folderach. `folder` i filtry logiczne są ignorowane. Bez rozróżniania wielkości liter. `after` i `before` nadal działają.
np. `"cliente-vip"`

## Szybki start

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "list_messages",
        args: {
          folder: "INBOX",
          is_read: false,
          limit: 50
        }
      }
    ]
  },
  { 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": "list_messages",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "messages": [
          {
            "message_uid": "Vj0xQUJDMTIz",
            "thread_id": "thr_9a1c4e72",
            "folder": "INBOX",
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "has_attachments": false,
            "size_bytes": 4821,
            "is_read": false,
            "is_starred": false,
            "is_important": false,
            "is_spam": false,
            "snoozed_until": null,
            "received_at": "2026-10-09T14:21:07Z"
          }
        ],
        "has_more": false,
        "next_cursor": null
      }
    }
  ]
}
```

### Pola odpowiedzi

- `messages[].message_uid`
Id wiadomości.
- `messages[].thread_id`
Rozmowa, do której należy wiadomość.
- `messages[].folder`
Folder tego wpisu.
- `messages[].subject / preview`
Temat i krótki podgląd.
- `messages[].from_name / from_email`
Nadawca.
- `messages[].has_attachments / size_bytes`
Flaga załączników i rozmiar wiadomości.
- `messages[].is_read / is_starred / is_important / is_spam`
Stan wiadomości.
- `messages[].snoozed_until`
Kiedy wraca odłożona wiadomość lub `null`.
- `messages[].received_at`
Kiedy wiadomość odebrano.
- `has_more / next_cursor`
Paginacja.

## Lista według etykiety

Z `label` polecenie czyta indeks etykiet, więc sprawdzane są tylko wiadomości z etykietą. Każda wiadomość wraca z obecnym stanem we wszystkich folderach, więc dostajesz `folders` i `labels` zamiast jednego `folder`.

Dane odpowiedzi z etykietą

```
{
  "messages": [
    {
      "message_uid": "Vj0xQUJDMTIz",
      "thread_id": "thr_9a1c4e72",
      "subject": "Invoice for September",
      "preview": "Hi, attached is the invoice for September…",
      "from_name": "Ana Costa",
      "from_email": "ana@client.com",
      "folders": [
        "INBOX"
      ],
      "labels": [
        "cliente-vip"
      ],
      "is_read": false,
      "is_starred": false,
      "is_important": false,
      "received_at": "2026-10-09T14:21:07Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## 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`INVALID_CURSOR`
Kursor jest uszkodzony lub należy do innego konta albo folderu.
- CMD`INTERNAL`
Błąd serwera. Szczegóły trafiają tylko do logu serwera.
