---
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/it/api-reference/receive-emails/reading/search

Ricevi email: lettura

# Search

Cerca nella casella per mittente, dominio, oggetto, corpo o etichetta, con gli stessi operatori della ricerca della webmail.

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

Senza `field`, la ricerca è automatica: un indirizzo email completo cerca per mittente esatto, `domain.com` cerca per dominio, e tutto il resto cerca in oggetto, corpo e nome del mittente.

Con gli operatori (`from:`, `is:unread`…) i risultati sono raggruppati per conversazione: una riga per thread, il messaggio più recente che corrisponde. Senza `in:`, Spam e Cestino sono esclusi.

## Argomenti

- `query` string obbligatorio
Cosa cercare, fino a 256 caratteri. Con più parole, la prima viene dall'indice e le altre filtrano per oggetto e anteprima.
- `field` string facoltativo
Limita una ricerca semplice a `from`, `to`, `subject`, `body`, `sender` o `label`. Ignorato quando la query ha operatori.
- `limit` number facoltativo
Dimensione della pagina, da 1 a 100. Predefinito 25.
- `cursor` string facoltativo
Il `next_cursor` della pagina precedente.

## Avvio rapido

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1',
  {
    commands: [
      {
        command: "search",
        args: {
          query: "ana@client.com",
          field: "from",
          limit: 5
        }
      }
    ]
  },
  { 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);
```

## Risposta

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "search",
      "id": "0",
      "type": "SUCCESS",
      "data": {
        "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"
            ],
            "is_read": false,
            "is_starred": false,
            "is_important": false,
            "received_at": "2026-10-09T14:21:07Z"
          }
        ],
        "has_more": false,
        "next_cursor": null
      }
    }
  ]
}
```

### Campi della risposta

- `messages[]`
Messaggi corrispondenti, dal più recente. Ognuno ha `message_uid`, `thread_id`, `subject`, `preview`, `from_name`, `from_email`, `folders`, i flag letto/stella/importante e `received_at`.
- `has_more / next_cursor`
Paginazione.

## Operatori

Combinali con parole semplici. Un valore con spazi va tra virgolette: `subject:"new proposal"`. Metti `-` davanti per escludere: `-from:noreply`, `-newsletter`.

Body della richiesta

```
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "from:ana@client.com has:attachment newer_than:30d invoice"
      }
    }
  ]
}
```

- `from: / to:`
Mittente / destinatario (to o cc), parte del nome o dell'indirizzo.
- `subject: / label:`
Testo dell'oggetto / un'etichetta.
- `in:`
`inbox`, `sent`, `archive`, `trash`, `spam`, `drafts`, `promotions`, `snoozed`, `scheduled`, `agents`, `not-subscribing` o l'id di una cartella personalizzata.
- `has:attachment`
Solo messaggi con allegati.
- `is:unread / is:read / is:starred / is:important`
Stato del messaggio.
- `after: / before:`
Una data `YYYY/MM/DD` (o `YYYY-MM-DD`), UTC.
- `newer_than: / older_than:`
`7d`, `2w`, `3m` (30 giorni) o `1y`.

Solo filtri, senza parole da cercare (`is:unread in:archive`), restituiscono `threads` (l'elenco conversazioni di quella cartella) invece di `messages`.

## Esempi di ricerca

Body delle richieste

```
// subject + body + sender name
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "invoice september"
      }
    }
  ]
}

// exact sender
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "ana@client.com",
        "field": "from"
      }
    }
  ]
}

// everyone from a domain
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "client.com"
      }
    }
  ]
}

// messages with a label
{
  "commands": [
    {
      "command": "search",
      "args": {
        "query": "cliente-vip",
        "field": "label"
      }
    }
  ]
}
```

## Errori

Gli errori a livello HTTP restituiscono `type`, `code` e `message`. Gli errori marcati CMD tornano dentro il risultato del comando, con HTTP 200.

- 401`TOKEN_EXPIRED`
L'access token è scaduto. Chiama Refresh Token e ripeti la richiesta.
- 401`INVALID_TOKEN`
Il token è malformato, sconosciuto o revocato.
- 429`RATE_LIMITED`
Più di 15 richieste/s o 15 in corso per la stessa IP + casella. Attendi i secondi indicati in Retry-After.
- CMD`INVALID_ARGS`
Un argomento obbligatorio manca o non è valido.
- CMD`INVALID_CURSOR`
Il cursore è malformato o appartiene a un altro account o cartella.
- CMD`INTERNAL`
Errore del server. Il dettaglio viene scritto solo nel log del server.
