Skip to content

Configuration Reference

Complete reference for all configuration options.

Configuration Methods

Best for Docker deployments

  • Easy to set in docker-compose.yml
  • Format: TDL_SECTION_KEY (uppercase, underscore-separated)
environment:
  - TDL_API_ID=12345678
  - TDL_DAEMON_ENABLED=true

Good for long source lists and patterns

  • Read from /app/config.yaml (fixed path). With Docker, mount it there: ./config.yaml:/app/config.yaml:ro
  • Optional when environment variables are set
  • Keys match the field names below, nested the same way
  • Values can use ${VAR} or ${VAR:-default} to pull in environment variables
api_id: 12345678

daemon:
  enabled: true

Priority order

You can use both. Each environment variable overrides the matching setting from /app/config.yaml, and settings no variable sets keep the file's value. The order is: environment variable, then the file, then the default.

Sources are one setting: if any TDL_SOURCES_N_* variable is set, the sources from environment variables replace the file's sources list.

The Docker image sets TDL_DOWNLOAD_DIR, TDL_SESSION_DIR and TDL_DAEMON_HEALTH_FILE itself, so those three always come from the environment there.

Environment Variable Format

Format: TDL_SECTION_KEY (uppercase, underscore-separated)

Examples: - TDL_API_ID → api_id - TDL_DAEMON_ENABLED → daemon.enabled - TDL_SOURCES_0_URL → sources[0].url

Core Settings

Telegram API Credentials

TDL_API_ID and TDL_API_HASH are required.

Variable Type Required Description
TDL_API_ID integer Yes API ID from https://my.telegram.org/apps
TDL_API_HASH string Yes API hash from https://my.telegram.org/apps
TDL_PHONE_NUMBER string No Phone number with country code (e.g., +1234567890). If omitted, you are asked for it at first login
- TDL_API_ID=12345678
- TDL_API_HASH=abcdef1234567890abcdef1234567890
- TDL_PHONE_NUMBER=+1234567890
api_id: 12345678
api_hash: "abcdef1234567890abcdef1234567890"
phone_number: "+1234567890"

Paths and Storage

Variable Type Default Description
TDL_DOWNLOAD_DIR path /downloads Base directory for downloaded files
TDL_FLAT_STRUCTURE boolean false Store all files in download dir without per-channel subfolders
TDL_TRACK_DOWNLOADS boolean true Track downloaded files to prevent re-downloads after move/rename

When TDL_FLAT_STRUCTURE is false (default), files are organized as {download_dir}/{channel_name}/{filename}. When true, all files go directly into {download_dir}/{filename}.

Channel and file names are sanitized before they touch the filesystem. Letters and digits in any script are kept (e.g. 中文文件.zip, Документ.txt, café.pdf), along with ., _ and -. Spaces, path separators, characters that are invalid on Windows (: * ? " < > |) and control characters are replaced with _. Leading dots and trailing dots/spaces are trimmed, and Windows reserved names such as CON or NUL.txt are prefixed with _.

When TDL_TRACK_DOWNLOADS is true (default), a persistent history of downloaded files is kept in the state database. This prevents re-downloading files that have been moved, renamed, or processed by external tools (e.g., media servers, Paperless-ngx, mergerfs). The tracking uses Telegram's file_unique_id, which is stable and unique per file content regardless of source. Set to false to disable and rely only on file-exists checks.

Docker Environment

These are standard Docker environment variables, not prefixed with TDL_.

Variable Type Default Description
PUID integer 1000 User ID for file ownership (arr-stack convention)
PGID integer 1000 Group ID for file ownership
TZ string UTC Container timezone (e.g., Europe/Lisbon)
- PUID=1000
- PGID=1000
- TZ=Europe/Lisbon
- TDL_FLAT_STRUCTURE=true
- TDL_TRACK_DOWNLOADS=true
flat_structure: true
track_downloads: true
# PUID, PGID, and TZ are Docker-only (not in config.yaml)

Dry run

Set TDL_DRY_RUN=true (or dry_run: true in YAML) to preview a run without writing anything. Filters are evaluated the same way as a real run. Each matching file is logged as a would-download line with its name, size, source, and destination path. Files that would be skipped are logged with the reason: extension, size, pattern, date, already tracked, or duplicate.

No files are downloaded, destination folders are not created, and cursors, history, and the pending queue are not updated. A dry-run also does not create the session directory, state.db, or WAL files, and it does not migrate state.yaml. If state.db already exists, cursors and history are read through an in-memory copy so the on-disk state stays untouched.

The preview tracks planned file_unique_id values and destination paths in memory across sources, so a file already counted earlier is skipped as already tracked, and same-name collisions use the same resolve_conflict() suffix a real run would pick.

Dry-run scans from the current cursor only and does not read or write the pending queue, so retries waiting below the cursor are not included. max_downloads_per_run is not applied, so the preview lists every match instead of one limited batch.

The run summary reports the count and total bytes that would transfer.

Dry-run pairs naturally with single-shot mode (TDL_DAEMON_ENABLED=false). If it is left on in daemon mode, every check logs a warning so the flag is not forgotten.

Variable Type Default Description
TDL_DRY_RUN boolean false Preview what would download, without writing files or state

Daemon Configuration

Controls continuous background operation.

Every check has a deadline. With the default 300-second interval, a check times out after 600 seconds, marks health as an error and retries at the next interval. Set daemon.check_timeout in YAML or TDL_DAEMON_CHECK_TIMEOUT to override that deadline. There is no unlimited default.

The health file keeps its existing first three lines (status, UTC timestamp, optional reason). A fourth line adds versioned JSON with updated_at, started_at, last_success, last_progress and max_check_age. The heartbeat refreshes only liveness, not successful-check progress. Docker rejects stale liveness after 600 seconds (overridable with TDL_DAEMON_HEALTH_MAX_AGE), and rejects stalled check progress after the check interval plus the check timeout plus one 60-second heartbeat interval. This second deadline also detects a check that ignores cancellation while the event loop is still alive.

Skipping a check outside configured active hours advances last_progress but preserves last_success, so an intentional overnight idle period stays healthy without pretending a download check succeeded. Legacy two-line and three-line health files remain readable using their existing timestamp freshness check.

Variable Type Default Description
TDL_DAEMON_ENABLED boolean false Enable daemon mode
TDL_DAEMON_CHECK_INTERVAL integer 300 Seconds between checks (60-86400)
TDL_DAEMON_CHECK_TIMEOUT integer twice the check interval Maximum seconds for one check, including downloads. Must be positive. Increase for large files or slow connections.
TDL_DAEMON_HEALTH_FILE path /app/health_status.txt Health check file path
TDL_DAEMON_LOG_LEVEL string unset Log level: DEBUG, INFO, WARNING, ERROR or CRITICAL, any case. Any other value stops startup with a config error. When unset, TDL_VERBOSITY decides (INFO by default)
- TDL_DAEMON_ENABLED=true
- TDL_DAEMON_CHECK_INTERVAL=300  # Check every 5 minutes
- TDL_DAEMON_LOG_LEVEL=INFO
daemon:
  enabled: true
  check_interval: 300  # Check every 5 minutes
  log_level: "INFO"

Notification Configuration

Discord webhooks and generic HTTP POST notifications. Nothing is sent unless TDL_NOTIFICATIONS_ENABLED=true and at least one webhook URL is set.

Variable Type Default Description
TDL_NOTIFICATIONS_ENABLED boolean false Enable notifications
TDL_NOTIFICATIONS_THROTTLE_SECONDS integer 60 Minimum seconds between notifications (10-3600)
TDL_NOTIFICATIONS_DISCORD_WEBHOOK_URL URL - Discord webhook URL
TDL_NOTIFICATIONS_DISCORD_USERNAME string Telegram Downloader Discord bot username
TDL_NOTIFICATIONS_GENERIC_WEBHOOK_URL URL - Generic webhook URL (JSON POST)
- TDL_NOTIFICATIONS_ENABLED=true
- TDL_NOTIFICATIONS_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/123/abc
notifications:
  enabled: true
  discord_webhook_url: "https://discord.com/api/webhooks/123/abc"

Metrics

Opt-in Prometheus /metrics endpoint. It is off by default and starts an HTTP server in a background thread when enabled. The endpoint is unauthenticated, so bind it to a private network.

Variable Type Default Description
TDL_METRICS_ENABLED boolean false Expose the /metrics endpoint
TDL_METRICS_PORT integer 9184 Listen port (1-65535)
- TDL_METRICS_ENABLED=true
- TDL_METRICS_PORT=9184
metrics:
  enabled: true
  port: 9184
ports:
  - "127.0.0.1:9184:9184"
environment:
  - TDL_METRICS_ENABLED=true
  - TDL_METRICS_PORT=9184

The published port is bound to loopback so the unauthenticated endpoint is not reachable from other hosts. If Prometheus runs on the same Compose network, scrape telegram-downloader:9184 and omit the ports mapping.

The counters follow the same events as the run summary. Dry-run checks record duration and last-check time, but they do not increment download, skip, or failure counters. See the metrics guide for the scrape snippet, the full metric list, and a starter Grafana dashboard.

Source Configuration

Configure download sources (channels, groups, forum topics, private chats).

Source URL Format

Source Type URL Format Example
Public channel https://t.me/username https://t.me/example_channel
Public group https://t.me/groupname https://t.me/example_group
Private channel or group https://t.me/c/CHAT_ID https://t.me/c/1234567890
Forum topic https://t.me/c/CHAT_ID/TOPIC_ID https://t.me/c/1234567890/123
Private chat https://t.me/username https://t.me/friend_username
Saved messages https://t.me/me https://t.me/me

In a t.me/c/ link, a second number is read as a forum topic ID, so leave message IDs off the link.

Source Settings

Format: TDL_SOURCES_N_KEY where N is the source index (0, 1, 2, ...)

Variable Type Required Description
TDL_SOURCES_N_URL URL Yes* Source URL (see formats above)
TDL_SOURCES_N_CHAT_ID integer Yes* Numeric chat ID instead of a URL (e.g., -1001234567890)
TDL_SOURCES_N_TOPIC_ID integer No Forum topic ID, used with TDL_SOURCES_N_CHAT_ID
TDL_SOURCES_N_NAME string No Custom folder name (auto-generated if omitted)

*Each source needs either a URL or a chat ID.

- TDL_SOURCES_0_URL=https://t.me/channel1
- TDL_SOURCES_0_NAME=Channel One
- TDL_SOURCES_1_URL=https://t.me/c/1234567890/123
- TDL_SOURCES_1_NAME=Forum Topic
sources:
  - url: "https://t.me/channel1"
    name: "Channel One"
  - url: "https://t.me/c/1234567890/123"
    name: "Forum Topic"

Filter Configuration

Per-source filters override global defaults. A per-source value replaces the global one; a list, size or date left empty falls back to the global value.

Variable Type Default Description
TDL_SOURCES_N_FILTERS_EXTENSIONS list global value File extensions (comma-separated, with dots)
TDL_SOURCES_N_FILTERS_ALLOW_ARCHIVES boolean global value Also download archives
TDL_SOURCES_N_FILTERS_ARCHIVE_EXTS list global value Archive extensions used when archives are allowed
TDL_SOURCES_N_FILTERS_MIN_SIZE string - Minimum file size (e.g., "100KB", "5MB")
TDL_SOURCES_N_FILTERS_MAX_SIZE string - Maximum file size (e.g., "2GB")
TDL_SOURCES_N_FILTERS_ONLY_AFTER date - Oldest message date to download, inclusive (ISO format: YYYY-MM-DD)
TDL_SOURCES_N_FILTERS_ONLY_BEFORE date - Newest message date to download, inclusive
TDL_SOURCES_N_FILTERS_INCLUDE_PATTERNS list - Only download files whose name matches one of these
TDL_SOURCES_N_FILTERS_EXCLUDE_PATTERNS list - Skip files whose name matches one of these (checked first)
TDL_SOURCES_N_FILTERS_INCLUDE_PHOTOS boolean global value Also download compressed Telegram photos
- TDL_SOURCES_0_FILTERS_EXTENSIONS=.pdf,.epub,.mobi
- TDL_SOURCES_0_FILTERS_MIN_SIZE=100KB
- TDL_SOURCES_0_FILTERS_MAX_SIZE=500MB
- TDL_SOURCES_0_FILTERS_ONLY_AFTER=2026-01-01
sources:
  - url: "https://t.me/channel1"
    filters:
      extensions: [".pdf", ".epub", ".mobi"]
      min_size: "100KB"
      max_size: "500MB"
      only_after: "2026-01-01"
      include_patterns: ["*ebook*", "*book*"]

List settings take comma-separated values in environment variables, e.g. TDL_SOURCES_0_FILTERS_INCLUDE_PATTERNS=*ebook*,*book*.

Size format: Number + unit: B, KB, MB, GB or TB, 1024-based (e.g., 500KB, 1.5GB). A bare number without a unit is rejected at startup. Date format: YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS, read as UTC. A date alone means midnight at the start of that day, so ONLY_BEFORE=2026-01-31 stops at the start of 31 January; use 2026-01-31T23:59:59 to include the whole day. Pattern format: Wildcards (* = any characters, ? = single character), or a regex when the pattern starts with ^, ends with $, or contains any of ( ) [ ] { } | +. Patterns are matched against the file name.

Photos: Telegram compressed photos are ignored by default, because photo-heavy chats can be huge. Set TDL_GLOBAL_FILTERS_INCLUDE_PHOTOS=true (or the per-source flag) to download them. The largest size is saved as photo_<YYYY-MM-DD>_<file-unique-id>.jpg (or photo_<YYYY-MM-DD>_<chat-id>_<message-id>.jpg when the unique id is missing), so photos from different chats do not collide in a shared folder. Size, date and pattern filters still apply; the generated .jpg name is what the pattern and extension filters see. Photos are accepted when the flag is on even if .jpg is not in the extension list. When photos are left off and a source contains them, the skip count is logged at DEBUG.

Global Filter Defaults

Applied to all sources unless overridden.

Variable Type Default Description
TDL_GLOBAL_FILTERS_EXTENSIONS list .pdf,.epub,.mobi Default file extensions
TDL_GLOBAL_FILTERS_MIN_SIZE string - Default minimum size
TDL_GLOBAL_FILTERS_MAX_SIZE string - Default maximum size
TDL_GLOBAL_FILTERS_ALLOW_ARCHIVES boolean false Also download archives
TDL_GLOBAL_FILTERS_ARCHIVE_EXTS list .zip,.rar,.7z Archive extensions used when archives are allowed
TDL_GLOBAL_FILTERS_INCLUDE_PATTERNS list - Default include patterns
TDL_GLOBAL_FILTERS_EXCLUDE_PATTERNS list - Default exclude patterns
TDL_GLOBAL_FILTERS_ONLY_AFTER date - Default oldest message date
TDL_GLOBAL_FILTERS_ONLY_BEFORE date - Default newest message date
TDL_GLOBAL_FILTERS_INCLUDE_PHOTOS boolean false Also download compressed Telegram photos

Retry Configuration

How a failed download is retried within one check.

Variable Type Default Description
TDL_MAX_RETRIES integer 2 Attempts per file within one check, counting the first try (2 = one try and one retry). Minimum 1
TDL_BASE_DELAY integer 2 Seconds before the first retry, doubled for each later retry (minimum 1)
TDL_MAX_DELAY integer 60 Upper limit for the delay between retries, in seconds (minimum 1)
TDL_MAX_DOWNLOAD_ATTEMPTS integer 5 Checks a file is retried in before it is given up on (minimum 1)

Example:

- TDL_MAX_RETRIES=3
- TDL_BASE_DELAY=2
- TDL_MAX_DELAY=120

Other Settings

Variable Type Default Description
TDL_SESSION_DIR path /app/.sessions Telegram session and state database. Mount a volume here
TDL_MAX_CONCURRENT_DOWNLOADS integer 1 Downloads running at the same time (1-10)
TDL_SCHEDULE_ACTIVE_HOURS string unset Only run checks inside these windows, e.g. 02:00-08:00,22:00-23:59 (local time via TZ)
TDL_MAX_DOWNLOAD_SPEED string unset Cap on total download speed, e.g. 500KB or 5MB
TDL_MIN_FREE_SPACE string 1GB Free space to keep on the download volume, e.g. 5GB. A file that would go below it (counting downloads already running) stays pending and an error notification is sent. When the volume is already below it, the check is skipped. 0 turns the check off
TDL_POST_DOWNLOAD_HOOK string unset Command run after each successful download (see the README for placeholders)
TDL_POST_DOWNLOAD_HOOK_TIMEOUT integer 300 Seconds before the hook is stopped (1-86400)
TDL_VERBOSITY string normal quiet (WARNING), normal (INFO) or verbose (DEBUG)
TDL_LOG_FILE path unset Also write logs to this file
TDL_TEST_MODE boolean false Connect to Telegram's test servers (needs a test account)

config.yaml Example

Can be used alone or together with environment variables:

api_id: 12345678
api_hash: "abcdef1234567890abcdef1234567890"
phone_number: "+1234567890"
download_dir: "/downloads"
flat_structure: true
track_downloads: true

daemon:
  enabled: true
  check_interval: 300
  health_file: "/app/health_status.txt"

notifications:
  enabled: true
  discord_webhook_url: "https://discord.com/api/webhooks/123/abc"

metrics:
  enabled: false
  port: 9184

sources:
  - url: "https://t.me/channel1"
    name: "Channel One"
    filters:
      extensions: [".pdf", ".epub", ".mobi"]
      min_size: "100KB"
      max_size: "500MB"
  - url: "https://t.me/c/1234567890/123"
    name: "Forum Topic"

Note: Any setting also set through an environment variable takes the environment value.