---
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-thread

Odbieranie e-maili: odczyt

# Get Thread

Otwórz całą rozmowę: podsumowanie i każdą wiadomość chronologicznie, opcjonalnie z treścią.

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

## Argumenty

- `thread_id` string opcjonalne
Id rozmowy.
- `id` string opcjonalne
Id dowolnej wiadomości w rozmowie. Użyj tego lub `thread_id`.
- `include_body` boolean opcjonalne
`true` dodaje `body` (`html` i `text`) do każdej wiadomości.

## Szybki start

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "get_thread",
        args: {
          id: "Vj0xQUJDMTIz",
          include_body: true
        }
      }
    ]
  },
  { 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_thread",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "thread": {
          "thread_id": "thr_9a1c4e72",
          "subject": "Invoice for September",
          "participants": [
            "ana@client.com",
            "you@yourdomain.com"
          ],
          "last_senders": [
            "ana@client.com"
          ],
          "message_count": 2,
          "unread_count": 1,
          "folders": [
            "INBOX",
            "Sent"
          ]
        },
        "messages": [
          {
            "message_uid": "Vj0xQUJDMDA5",
            "message_id": "<4c1d…@mail.client.com>",
            "in_reply_to": null,
            "parent_uid": null,
            "depth": 0,
            "folders": [
              "INBOX"
            ],
            "from_name": "Ana Costa",
            "from_email": "ana@client.com",
            "direction": "inbound",
            "to": [
              {
                "email": "you@yourdomain.com"
              }
            ],
            "reply_to": [],
            "subject": "Invoice for September",
            "preview": "Hi, attached is the invoice for September…",
            "is_read": true,
            "is_starred": false,
            "is_important": false,
            "has_attachments": false,
            "received_at": "2026-10-09T09:02:41Z",
            "body": {
              "html": "<p>Hi, attached is the invoice for September.</p>",
              "text": "Hi, attached is the invoice for September."
            }
          }
        ]
      }
    }
  ]
}
```

### Pola odpowiedzi

- `thread`
Podsumowanie rozmowy: `thread_id`, `subject`, `participants`, `last_senders`, `message_count`, `unread_count` i `folders`.
- `messages[]`
Wiadomości w porządku chronologicznym.
- `messages[].message_uid / message_id`
Id w skrzynce i Message-ID SMTP.
- `messages[].in_reply_to / parent_uid / depth`
Miejsce wiadomości w drzewie odpowiedzi.
- `messages[].direction`
`inbound` lub `outbound`.
- `messages[].from_name / from_email / to / reply_to`
Dane koperty.
- `messages[].subject / preview`
Temat i podgląd.
- `messages[].is_read / is_starred / is_important / has_attachments`
Stan wiadomości.
- `messages[].received_at`
Kiedy wiadomość odebrano lub wysłano.
- `messages[].body`
Tylko z `include_body: true`: `{ html, text }`.

## 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`NOT_FOUND`
Wiadomość, wątek lub folder nie istnieje dla tego tokena.
- CMD`INTERNAL`
Błąd serwera. Szczegóły trafiają tylko do logu serwera.
