---
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/privacy/routes/run-commands

Preferenze di tracking: Route

# Run Commands

L'unico punto di accesso per le preferenze di tracking. Invia da 1 a 20 comandi in una richiesta e ricevi un risultato per comando.

POST `https://g.sendcorex.com/v1/privacy`

Stessa busta di Logs, Contacts e Bounce e reclami. Le pagine sotto questa documentano ogni comando.

Gli errori sono riportati per comando. Un comando che fallisce non blocca gli altri e lo stato HTTP resta `200`.

## Parametri del body

- `commands` object[] obbligatorio
Da 1 a 20 comandi, eseguiti in ordine. L'intero body può arrivare a 1 MB.
- `commands[].command` string obbligatorio
`get_preferences`, `get_many`, `get_history`, `list_changes` o `set_preferences`.
- `commands[].args` object facoltativo
Gli argomenti del comando.
- `commands[].id` string facoltativo
Il tuo identificatore per il risultato. Predefinito l'indice (`"0"`, `"1"`…).

## Avvio rapido

```
import axios from 'axios';

const response = await axios.post(
  'https://g.sendcorex.com/v1/privacy',
  {
    commands: [
      {
        command: "set_preferences",
        id: "set",
        args: {
          email: "jane.doe@example.com",
          track_opens: false
        }
      },
      {
        command: "get_preferences",
        id: "get",
        args: {
          email: "jane.doe@example.com"
        }
      }
    ]
  },
  { headers: { Authorization: process.env.SENDCOREX_API_KEY } },
);

for (const result of response.data.results) {
  if (result.type !== 'SUCCESS') console.error(result.id, result.code, result.message);
  else console.log(result.id, result.data);
}
```

## Risposta

```
{
  "type": "SUCCESS",
  "results": [
    {
      "command": "set_preferences",
      "id": "set",
      "type": "SUCCESS",
      "took_ms": 9,
      "data": {
        "changed": true,
        "preference": {
          "email": "jane.doe@example.com",
          "track_opens": false,
          "track_clicks": true,
          "source": "api",
          "updated_at": "2026-10-24T07:20:12.031Z"
        }
      }
    },
    {
      "command": "get_preferences",
      "id": "get",
      "type": "SUCCESS",
      "took_ms": 3,
      "data": {
        "preference": {
          "email": "jane.doe@example.com",
          "track_opens": false,
          "track_clicks": true,
          "source": "api",
          "updated_at": "2026-10-24T07:20:12.031Z"
        }
      }
    }
  ]
}
```

### Campi della risposta

- `type`
Sempre `SUCCESS` quando la richiesta stessa è stata accettata.
- `results[].command`
Il comando che ha prodotto questo risultato.
- `results[].id`
L'`id` che hai inviato, o l'indice del comando.
- `results[].type`
`SUCCESS` o `ERROR`.
- `results[].took_ms`
Tempo impiegato dal comando nel server.
- `results[].data`
L'output del comando. Presente solo quando `type` è `SUCCESS`.
- `results[].code / message`
L'errore. Presente solo quando `type` è `ERROR`.

## Autenticazione

Usa la API key che crei nella dashboard, in Developers → API Keys.

- `Authorization`
Invia `Authorization: <api key>` o `Authorization: Bearer <api key>`.
- `privacy:read`
Get Preferences, Get Many, Get History e List Changes.
- `privacy:write`
Set Preferences.
- `Token delle caselle`
Il token della webmail qui non funziona. Viene rifiutato con `WRONG_CREDENTIAL_TYPE`.
- `IP consentiti`
Se la chiave ha una allowlist di IP, le richieste da altri IP ricevono `403 IP_NOT_ALLOWED`.

## Rate limit e cache

I limiti si applicano per IP + API key. Quando li superi, la richiesta viene rifiutata con HTTP 429 e un header `Retry-After`.

- `15 richieste / secondo`
Picco di 15. Contano anche le risposte servite dalla cache.
- `15 in corso`
Al massimo 15 richieste elaborate contemporaneamente.
- `Cache di lettura: 1,5 s`
La stessa lettura entro 1,5 secondi restituisce lo stesso risultato. Set Preferences non viene mai messo in cache.

## Errori

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

- 400`INVALID_JSON`
Il body non è {"commands":[...]} o supera 1 MB.
- 400`INVALID_ARGS`
La richiesta non ha comandi o ne ha più di 20.
- 401`MISSING_AUTH_HEADER`
Non è stato inviato nessun header Authorization.
- 401`INVALID_API_KEY`
La API key non esiste, è stata revocata o disattivata nella dashboard.
- 401`API_KEY_EXPIRED`
La API key ha superato la data di scadenza impostata nella dashboard.
- 401`WRONG_CREDENTIAL_TYPE`
È stato inviato un token di casella. Questa API richiede una API key della dashboard.
- 403`IP_NOT_ALLOWED`
La richiesta proviene da un IP che non è tra gli IP consentiti della chiave.
- 403`ACCOUNT_BLOCKED`
L'account è bloccato.
- 403`MISSING_SCOPE`
La chiave non ha né `privacy:read` né `privacy:write`, quindi nessun comando può essere eseguito.
- 429`RATE_LIMITED`
Più di 15 richieste/s o 15 in corso per la stessa IP + API key. Attendi i secondi indicati in Retry-After.
- 503`AUTH_UNAVAILABLE`
L'autenticazione è temporaneamente non disponibile. Riprova.
- CMD`UNKNOWN_COMMAND`
Il nome del comando non esiste.
- CMD`INTERNAL`
Errore del server. Il dettaglio viene scritto solo nel log del server.
