# File Library

## What is the file library?

Each bot has its own **media file library**—a centralized storage area for images, videos, audio, and documents. Files are uploaded once and can then be used in any number of blocks.

## Uploading files

### From the block editor

When editing a media block (Image, Video, Audio, or Document), click the upload button; the file will be automatically saved to both the block and the library.

### From the file manager

Click the **"Files"** button in the builder's header. This opens the library, where you can:
- Upload new files directly to the library.
- View all uploaded files, filtered by type (photo / video / audio / document).
- Delete unused files.

## Selecting a file from the library

When adding a media block, instead of uploading a new file, click the **"From library"** button. A file picker will open, featuring a name search and a file type filter.

Select the desired file, and it will be inserted into the block.

## `file_id` caching

After a file is sent to a user for the first time, Telegram returns a special file identifier—the **`file_id`**. The builder saves this automatically.

When sending the same file again, the bot uses the saved `file_id`; this significantly speeds up the sending process and reduces server load.

> The initial file transmission may take slightly longer while Telegram processes and caches the file. Subsequent transmissions will be instantaneous.

## Supported formats

| Type | Formats |
|---|---|
| **Image** | JPG, PNG, GIF, WEBP |
| **Video** | MP4 |
| **Audio** | MP3, OGG, M4A |
| **Document** | Any file (PDF, DOCX, XLSX, ZIP, etc.) | ## Tips

- Give files clear names when uploading them; these names appear in the file picker and help you quickly locate the right file.
- Use the library for frequently used files (e.g., bot logos, standard menu images).
- Files from the library can also serve as a source for [Inline Menus](Inline-menu.md) in dynamic mode.

## External ID (out_id)

When adding or editing a file, you can specify an **External ID**—a unique, custom identifier of your choice.

> Specify an External ID here if you plan to retrieve the file using it later.

An External ID is useful when you need to reference a specific file within bot scenarios without relying on its numeric ID. For example, you could set the ID to `welcome_banner` and always retrieve the correct file using that key, even if you replace the file and its numeric ID changes.

To retrieve a file using its External ID, use the **"Get file by External ID"** action within the [Database](Database.md) block (selecting "Files" as the source).

- The External ID is unique within a specific bot.
- When a file is copied, the External ID field is cleared to prevent conflicts.