Telegram Drive includes an opt-in local REST API for automating file, folder, search, storage, thumbnail, media, and bulk operations. The API is available in the desktop app on Windows, macOS, and Linux. It is disabled by default, binds only to the loopback interface, and requires the desktop app to remain open and signed in.
- Open Settings → Advanced in the desktop app.
- Generate an API key and copy it immediately. The app stores only its hash, so the plaintext key cannot be shown again.
- Choose an unused port. The default is
8550. - Enable the REST API and confirm that its status is running.
Regenerating the API key immediately invalidates the previous key. Keep the key out of source control, shell history, screenshots, and public issue reports.
http://127.0.0.1:8550/api/v1
The port is configurable. Replace 8550 in examples if a different port is selected in Settings. Do not expose, proxy, or forward this loopback service to a LAN or the internet.
All endpoints except /health require an API key passed in the request headers.
| Header | Type | Description |
|---|---|---|
X-API-Key |
String | Your Telegram Drive API access key |
curl -H "X-API-Key: YOUR_API_KEY" \
http://127.0.0.1:8550/api/v1/filesCheck API availability, status, and running version.
- URL:
/health - Method:
GET - Auth Required: No
{
"status": "ok",
"version": "x.y.z"
}Retrieve metadata for files stored in Telegram Drive.
- URL:
/files - Method:
GET - Auth Required: Yes
| Parameter | Type | Description |
|---|---|---|
page |
Integer | Page number (default: 1) |
limit |
Integer | Items per page (default: 20) |
folder_id |
Integer | Filter files inside a specific folder |
search |
String | Filter files by matching search term in filename |
offset_id |
Integer | Message ID offset for pagination |
sort |
String | Field to sort by: name, size, or created_at |
order |
String | Sort order: asc or desc |
mime_type |
String | Filter files by a specific MIME type |
created_after |
String | Include files created after this timestamp; use the same format returned by created_at |
created_before |
String | Include files created before this timestamp; use the same format returned by created_at |
size_min |
Integer | Minimum file size in bytes |
size_max |
Integer | Maximum file size in bytes |
fields |
String | Comma-separated response fields when a reduced representation is needed |
{
"data": [],
"files": [],
"page": 1,
"limit": 20,
"total": 0
}Retrieve detailed metadata for a specific file.
- URL:
/files/{message_id} - Method:
GET - Auth Required: Yes
{
"id": 123,
"folder_id": 456,
"name": "document.pdf",
"size": 102400,
"mime_type": "application/pdf",
"created_at": "2026-06-05T10:00:00Z"
}Stream or download a file directly from Telegram Drive.
- URL:
/files/{message_id}/download - Method:
GET - Auth Required: Yes
Search files by filename with optional filtering.
- URL:
/files/search - Method:
GET - Auth Required: Yes
| Parameter | Type | Description |
|---|---|---|
q |
String | Required. Search query string |
Upload a file to Telegram Drive.
- URL:
/files - Method:
POST - Auth Required: Yes
- Content-Type:
multipart/form-data
file: Exactly one binary file field, up to Telegram's 2,000,000,000-byte upload limitfolder_id(Optional): One integer target folder/channel ID; omit it for Saved Messages
Unknown fields, duplicate fields, malformed multipart bodies, and path-like filenames are rejected or normalized before upload. Bandwidth is reserved atomically and released automatically if staging, Telegram upload, or message creation fails.
curl -X POST \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@./report.pdf" \
-F "folder_id=456" \
http://127.0.0.1:8550/api/v1/filesThe endpoint returns 400 for invalid multipart fields, 413 for an oversized file, and 500 if local staging or Telegram delivery fails.
{
"id": 123,
"folder_id": 456,
"name": "uploaded_file.txt",
"size": 1024,
"mime_type": "text/plain",
"created_at": "2026-06-16T01:00:00Z"
}Delete a specific file.
- URL:
/files/{message_id} - Method:
DELETE - Auth Required: Yes
folder_id(Optional): ID of folder containing the file
Forward a file/message to another folder.
- URL:
/files/{message_id}/copy - Method:
POST - Auth Required: Yes
{
"folder_id": 789,
"source_folder_id": 456
}Rename (edit description) or move a file.
- URL:
/files/{message_id} - Method:
PATCH - Auth Required: Yes
{
"name": "new_name.txt",
"folder_id": 789,
"source_folder_id": 456
}- URL:
/folders - Method:
GET
- URL:
/folders - Method:
POST - Request Body:
{"name": "New Folder"}
- URL:
/folders/{folder_id} - Method:
PATCH - Request Body:
{"name": "New Folder Name"}
- URL:
/folders/{folder_id} - Method:
DELETE
Retrieve total storage consumed, file counts, and breakdown by folders and MIME types.
- URL:
/storage/stats - Method:
GET
{
"total_storage_used_bytes": 10485760,
"total_file_count": 12,
"folders": [
{ "id": 456, "name": "Documents", "file_count": 5, "size_bytes": 5242880 }
],
"mime_types": [
{ "mime_type": "application/pdf", "file_count": 5, "size_bytes": 5242880 }
]
}List groups of files with identical filenames and sizes.
- URL:
/storage/duplicates - Method:
GET
List folders that do not contain any files.
- URL:
/folders/empty - Method:
GET
Return the raw binary image data for a file's thumbnail.
- URL:
/files/{message_id}/thumbnail - Method:
GET - Query Param:
folder_id(Optional)
Return video duration, resolution, audio title, or audio performer metadata.
- URL:
/files/{message_id}/media-info - Method:
GET - Query Param:
folder_id(Optional)
Perform action operations (such as move, delete, or archive) across multiple files.
- URL:
/files/bulk - Method:
POST - Auth Required: Yes
Download selected files as a zip archive stream.
{
"action": "archive",
"file_ids": [123, 124, 125],
"folder_id": 456
}{
"action": "delete",
"file_ids": [123, 124, 125],
"folder_id": 456
}{
"action": "move",
"file_ids": [123],
"folder_id": 111,
"payload": {
"folder_id": 222
}
}- The API listens only on
127.0.0.1and is intended for trusted software running on the same computer. - Treat the API key as a password. Any local process or user with the key can use the enabled operations.
- Telegram Drive stores only a hash of the key and does not write the plaintext key to application logs.
- Encrypted files fail closed for plaintext REST access, including download, thumbnail, media-info, rename/move, copy, and delete operations that are not safely supported for encrypted objects.
- Telegram service limits, channel permissions, proxy/VPN settings, bandwidth limits, and flood waits still apply.
- Folder Sync, WebDAV, and the REST API operate on the same Telegram channels. Allow one operation to finish before changing the same file through another integration.
- Disabling the server or regenerating its key revokes access. The server is unavailable when the desktop app is closed or signed out.
See the Folder Sync guide, WebDAV guide, and Privacy Policy for related behavior.
The API returns standardized JSON error formats on failure:
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
}
}