> For the complete documentation index, see [llms.txt](https://docs-en.dydu.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-en.dydu.ai/developers/api-reference/import-export-knowledge-base.md).

# Import/Export Knowledge Base

These APIs let you export, import or delete the knowledge base of a bot, in XML format.

Before you start, you need:

* the **bot identifier** (botUUID) and, for imports, your **account identifier** (accountUUID). They are displayed on the **Preferences > Api > API access** page (see [Access to APIs](https://docs-en.dydu.ai/developers/api-reference/access-to-apis));
* an **authorization** for the **Authorization** field (see [Authentication](https://docs-en.dydu.ai/developers/api-reference/authentication)).

These APIs are in the Swagger interface: go to **Preferences > Api > API access**, click the link provided, then **Bot knowledge base**.

## Export a knowledge base

Exports are reserved for administrators.

1. Click **GET /bot/knowledgebase/export/{botUUID}/{excludeGalleryContent}**, then **Try it out**.
2. Fill in the fields:
   * **botUUID**: identifier of the bot to export;
   * **excludeGalleryContent**: `true` to exclude the gallery from the export, `false` to include it;
   * **Authorization**: your token.
3. Click **Execute**.
4. Click **Download file** to get the knowledge base.

## Import a knowledge base

Imports are reserved for administrators.

1. Click **POST /bot/knowledgebase/import/{botUUID}/{accountUUID}**, then **Try it out**.
2. Fill in the fields:
   * **botUUID**: identifier of the bot to import the knowledge base into;
   * **accountUUID**: your account identifier;
   * **Authorization**: your token.
3. Click **Choose file** and select the XML file to import.
4. Click **Execute**. The import may take some time.

The API returns an import report in XML format (`import-knowledgeBase-<identifier>.xml` file). Read it to check the result of the import.

## Delete a knowledge base

{% hint style="warning" %}
Deletion is permanent. It deletes the knowledge, matching groups, context conditions, consultation spaces and, unless you exclude it, the gallery. Export the knowledge base before deleting it.
{% endhint %}

Deletion is reserved for super users.

1. Click **DELETE /bot/knowledgebase/delete/{botUUID}/{excludeGalleryContent}**, then **Try it out**.
2. Fill in the fields:
   * **botUUID**: identifier of the bot whose knowledge base you want to delete;
   * **excludeGalleryContent**: `true` to keep the gallery, `false` to delete it too;
   * **Authorization**: your token.
3. Click **Execute**.
