> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mycentralino.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Aggiungi conoscenza

> Aggiunge a un Agente AI di MyFlow un testo o una domanda frequente

# POST /v1/whatsapp/agents/\{id}/knowledge

Aggiunge un documento alla [conoscenza](https://docs.mycentralino.com/mycentralino-api/whatsapp-agents-knowledge.md) dell'agente: un **testo** con un titolo oppure una **domanda frequente** con la sua risposta. L'agente lo usa dal messaggio successivo.

I file (PDF, Word…) si caricano solo dal pannello, in **MyFlow → Agenti AI**. Dall'API puoi mandare il loro contenuto come testo.

## Parametri

| Parametro | Tipo | Obbligatorio | Descrizione |
| - | - | - | - |
| `id` | int | ✅ | ID dell'agente, nel percorso |

## Request Body

### Un testo

| Campo | Tipo | Obbligatorio | Descrizione |
| - | - | - | - |
| `type` | string | ✅ | `"text"` |
| `title` | string | ✅ | Di cosa parla, da 1 a 160 caratteri. Aiuta l'agente a trovarlo |
| `text` | string | ✅ | Il contenuto, anche su più righe |

### Una domanda frequente

| Campo | Tipo | Obbligatorio | Descrizione |
| - | - | - | - |
| `type` | string | ✅ | `"faq"` |
| `question` | string | ✅ | La domanda, da 1 a 500 caratteri |
| `answer` | string | ✅ | La risposta, da 1 a 4.000 caratteri |

> [!TIP]
>
> Le domande frequenti funzionano meglio dei testi lunghi: una domanda per documento, con la risposta che vuoi sentire dall'agente. Per un listino o un regolamento usa un testo, diviso per argomento in più documenti.

**Limiti.** Ogni agente ha al massimo 20 documenti e 200.000 caratteri in tutto: lo stato è in [`GET /v1/whatsapp/agents/{id}/knowledge`](https://docs.mycentralino.com/mycentralino-api/whatsapp-agents-knowledge). Il body di una richiesta non supera i 64 KB, quindi un testo molto lungo va diviso in più documenti.

## Richiesta

```bash cURL theme={null}
curl -X POST "https://api.mycentralino.com/v1/whatsapp/agents/7/knowledge" \
  -H "X-API-KEY: sk_mycentralino_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
      "type": "faq",
      "question": "Che orari fate?",
      "answer": "Dal lunedì al venerdì dalle 9 alle 18, il sabato dalle 9 alle 13."
  }'
```

```php PHP theme={null}
<?php
$data = [
    'type' => 'text',
    'title' => 'Servizi e prezzi',
    'text' => "Prima visita: 80 euro.\nControllo: 50 euro.\nPulizia dei denti: 70 euro.",
];

$ch = curl_init('https://api.mycentralino.com/v1/whatsapp/agents/7/knowledge');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'X-API-KEY: sk_mycentralino_your_api_key',
        'Content-Type: application/json'
    ]
]);
$response = curl_exec($ch);
curl_close($ch);
print_r(json_decode($response, true));
```

```python Python theme={null}
import requests

headers = {'X-API-KEY': 'sk_mycentralino_your_api_key'}
data = {
    "type": "faq",
    "question": "Che orari fate?",
    "answer": "Dal lunedì al venerdì dalle 9 alle 18, il sabato dalle 9 alle 13."
}
response = requests.post('https://api.mycentralino.com/v1/whatsapp/agents/7/knowledge', headers=headers, json=data)
print(response.json())
```

## Risposta

`201 Created` con il documento, nella forma di [un documento](https://docs.mycentralino.com/mycentralino-api/whatsapp-agents-knowledge.md#un-documento).

```json theme={null}
{
  "success": true,
  "data": {
    "id": 31,
    "type": "faq",
    "title": "Che orari fate?",
    "chars": 98,
    "file_name": null,
    "created_at": "2026-11-12T18:25:10+01:00",
    "question": "Che orari fate?",
    "answer": "Dal lunedì al venerdì dalle 9 alle 18, il sabato dalle 9 alle 13."
  }
}
```

Ogni aggiunta lascia una riga nel Log attività del pannello, con il titolo del documento.

## Errori

### 404 - agent\_not\_found

Non c'è un agente con questo `id` su questo account.

### 422 - invalid\_type

`type` manca o non è `text` o `faq`. Un file non si carica dall'API.

### 422 - invalid\_title / invalid\_text / invalid\_question / invalid\_answer

Campo mancante, vuoto o troppo lungo.

### 422 - unknown\_fields

Un campo che non appartiene al tipo scelto: per `text` valgono `title` e `text`, per `faq` valgono `question` e `answer`.

### 409 - knowledge\_limit

L'agente ha già 20 documenti, oppure con questo supererebbe i 200.000 caratteri. Il messaggio dice quale dei due. Togline qualcuno o accorcia i testi.

Gli errori comuni a tutte le rotte sono nell'[introduzione](https://docs.mycentralino.com/mycentralino-api/whatsapp-introduction.md#codici-di-errore).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.