CLI tools

Commands

Every command, option and exit code. This page is generated from the program itself, so it cannot describe a version that does not exist. For the same list as JSON, run tg commands --json.

How a command line is built:

tg [profile] [options] <resource> <verb> [arguments]

The first word is the profile when it is not a command: tg work chats list lists the chats of profile work, and tg chats list those of the default profile. TG_PROFILE does the same for a whole shell session; without either, the profile is default.

Options for every command

OptionWhat it does
-V, --versionoutput the version number.
-v, --verbosemore detail in what is shown: -v ids, -vv everything we know. Default: 0.
--jsonmachine-readable output: one JSON value on stdout, nothing else.
--jsonlmachine-readable output: one JSON object per line, for streaming and jq.
--quietdiagnostics off; a failure is still said.
--tracethe connection's own log lines on stderr — never message content.
--timeout <duration>give up on the whole command after this — 30s, 2m, 500ms.
--offlineanswer from what was recorded and never connect; fails if nothing was.
--yesgo ahead without the question an ask level puts before a write.
--recordkeep this run — ids and timings, never message content.
--no-recorddo not keep it, whatever the configuration says.

tg session

log this profile in to Telegram, or out

tg session start

log in by QR code (default) or by phone number, code and 2FA password

tg session start [method] [options]
ArgumentWhat it is
methodoptionalhow to log in. One of: qr, phone. Default: qr.
OptionWhat it does
--app <how>the first time only: how to get this profile's app from my.telegram.org. One of: browser, auto. Default: browser.
--qr-file <png>write the QR code to this PNG instead of drawing it, for an agent to pass on.

tg session end

log this profile out on Telegram's side and forget the session here

Changes something in Telegram.

tg session end

tg account

the logged-in account

tg account show

who this profile is logged in as; the phone number shows its last four digits

tg account show [options]
OptionWhat it does
--show-phoneprint the whole phone number.

tg account update

change the name, the description or the photo everyone sees on your profile

Changes something in Telegram.

tg account update [options]
OptionWhat it does
--first-name <name>your first name.
--last-name <name>your last name.
--description <text>about you.
--photo <file>a new profile photo — an image file.

tg account sessions

where else this account is logged in — not tg session, which is this tool's own login

tg account sessions list

every device and app logged in to this account; nothing is ended

tg account sessions list

tg account sessions end

log out every other device, your phone included; this one stays

Changes something in Telegram.

tg account sessions end [options]
OptionWhat it does
--othersevery session but this one.

tg chats

the account's chats

tg chats list

chats, newest first, archived ones included

tg chats list [options]
OptionWhat it does
--limit <n>how many to show.
--page <n>which page, starting at 1.
--allevery row, no paging.
--search <text>only chats whose name contains this; at least 3 characters.
--kind <kind>only chats of this kind: dialog, group, channel, saved.
--unreadonly chats with unread messages.

tg chats events

who joined, left, was added or removed, and by whom — from the chat's service messages

tg chats events <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--since-time <time>ISO 8601, or 2h / 1d ago; 7 days ago if not given.
--type <names>only these, comma-separated: join, leave, add, remove, create, title, pin.

tg chats inspect

what an invite or public link leads to, without joining it

tg chats inspect <link>
ArgumentWhat it is
linkrequiredan invite link or a public one.

tg chats show

one chat: its kind, unread count, last message time and who is in it

tg chats show <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

tg chats members

who is in a group

tg chats members list

everyone in a group, a page at a time, with their role and when they were last seen

tg chats members list <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--limit <n>how many to show.
--page <n>which page, starting at 1.
--allevery row, no paging.

tg chats members add

add people; they are told

Changes something in Telegram.

tg chats members add <chat> <person>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
personrequiredan id, or part of a name.

tg chats members remove

remove people; their messages stay

Changes something in Telegram.

tg chats members remove <chat> <person>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
personrequiredan id, or part of a name.

tg chats mark-read

mark a chat read; the other side sees that you read it

Changes something in Telegram.

tg chats mark-read <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--until <message>only up to this message id; the newest by default.

tg chats create

create a group or a channel; the people added are told

Changes something in Telegram.

tg chats create <title> [person] [options]
ArgumentWhat it is
titlerequiredthe group's name.
personoptionalpeople to add: an id, or part of a name.
OptionWhat it does
--channela private channel instead of a group; people join it by its link.

tg chats join

join a group or channel by its link; the others in it see that you joined

Changes something in Telegram.

tg chats join <link>
ArgumentWhat it is
linkrequiredan invite link, or a public one.

tg chats leave

leave a group or channel; the others in it see that you left

Changes something in Telegram.

tg chats leave <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

tg chats update

rename a group or channel, change its description, or turn one of its settings on or off

Changes something in Telegram.

tg chats update <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--title <title>the new name.
--description <text>the new description.
--all-can-pin <on|off>every member may pin messages.
--only-admins-add <on|off>only admins may add members.

a group's invite link

the invite link, if you may see it

tg chats link show <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

replace the invite link; the old one stops working

Changes something in Telegram.

tg chats link reset <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

tg chats admins

give or take back a member's admin rights

tg chats admins add

make a member an admin with these rights

Changes something in Telegram.

tg chats admins add <chat> <person> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
personrequiredan id, or part of a name.
OptionWhat it does
--can <rights>what they may do, comma-separated: members, admins, info, pin, link, post, edit, delete.

tg chats admins remove

take an admin's rights back; they stay a member

Changes something in Telegram.

tg chats admins remove <chat> <person>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
personrequiredan id, or part of a name.

tg chats folders

your chat folders

tg chats folders list

your chat folders, in the order the app shows them

tg chats folders list

tg chats folders create

create a chat folder

Changes something in Telegram.

tg chats folders create <title> [options]
ArgumentWhat it is
titlerequiredthe folder's name; the app may refuse a long one.
OptionWhat it does
--chat <chat>a chat to put in it, by id or name; repeat it for more.

tg chats folders update

rename a folder, or change which chats are in it

Changes something in Telegram.

tg chats folders update <folder> [options]
ArgumentWhat it is
folderrequiredfolder id, or its title exactly.
OptionWhat it does
--title <title>a new name.
--add <chat>put a chat in it; repeat it for more.
--remove <chat>take a chat out of it; repeat it for more.

tg chats folders delete

delete a folder; the chats in it stay

Changes something in Telegram.

tg chats folders delete <folder>
ArgumentWhat it is
folderrequiredfolder id, or its title exactly.

tg chats rules

what chats moderate judges a group by, kept in a file of this profile

tg chats rules show

the group's rules; the defaults, marked not saved, if it has none yet

tg chats rules show <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

tg chats rules set

change one rule; the group's first change writes every rule with its default

Changes something in Telegram.

tg chats rules set <chat> <key> <value>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
keyrequiredone of: trusted, blocked, blockedNames, links, invites, forwards, blockedPeople, flood.messages, flood.minutes, flood.action, newAccount.days, newAccount.action, consent.delete, consent.remove.
valuerequiredthe new value; a list is comma-separated.

tg chats rules unset

put one rule back to its default

Changes something in Telegram.

tg chats rules unset <chat> <key>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
keyrequiredone of: trusted, blocked, blockedNames, links, invites, forwards, blockedPeople, flood.messages, flood.minutes, flood.action, newAccount.days, newAccount.action, consent.delete, consent.remove.

tg chats moderate

judge a group's new messages and members by its rules, and act as they allow

Changes something in Telegram.

tg chats moderate <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--since-time <time>judge what came after this ISO 8601 time, or 2h / 1d ago; the saved point stays.
--dry-runjudge and plan; do nothing.
--allow-dangerousyes to every action whose level in the group's rules is ask.
--max-actions <n>at most this many actions in one run; 10 if not given.

tg contacts

people this account has a one-to-one chat with

tg contacts list

people you have a one-to-one chat with

tg contacts list [options]
OptionWhat it does
--limit <n>how many to show.
--page <n>which page, starting at 1.
--allevery row, no paging.
--order <recent|name>newest conversation first, or alphabetical. Default: recent.
--search <text>only people whose name or @username contains this.

tg contacts show

one person and the chats you share with them

tg contacts show <person>
ArgumentWhat it is
personrequiredtheir id, @username, or part of their name.

tg contacts lookup

who has this phone number — asks for it, or reads it from stdin; never an argument

tg contacts lookup

tg contacts sync

take the whole contact list from the messenger into the local store

tg contacts sync

tg contacts add

add a person to your contacts — contacts list still shows only people you have a dialog with

Changes something in Telegram.

tg contacts add <person>
ArgumentWhat it is
personrequiredperson id — contacts lookup finds one — or part of a known name.

tg contacts remove

remove a person from your contacts; the chat stays, a name you gave them may not

Changes something in Telegram.

tg contacts remove <person>
ArgumentWhat it is
personrequiredperson id — contacts lookup finds one — or part of a known name.

tg contacts block

stop a person from writing to you — they need not be a contact

Changes something in Telegram.

tg contacts block <person>
ArgumentWhat it is
personrequiredperson id — contacts lookup finds one — or part of a known name.

tg contacts unblock

let a blocked person write to you again

Changes something in Telegram.

tg contacts unblock <person>
ArgumentWhat it is
personrequiredperson id — contacts lookup finds one — or part of a known name.

tg contacts rename

give a person a name of your own — they do not see it

Changes something in Telegram.

tg contacts rename <person> <first-name> [last-name]
ArgumentWhat it is
personrequiredperson id — contacts lookup finds one — or part of a known name.
first-namerequiredthe name you want to see for them.
last-nameoptional

tg contacts import

upload phone numbers and add the people the messenger has under them

Changes something in Telegram.

tg contacts import <file>
ArgumentWhat it is
filerequiredone person per line: number, then a comma, a tab or a semicolon, then the name.

tg messages

read and send messages

tg messages list

a chat's messages, oldest to newest

tg messages list <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--limit <n>how many.
--before-id <id>only messages older than this message id.
--before-time <time>only messages older than this ISO 8601 time, or 2h / 1d ago.
--after-id <id>only messages newer than this message id.
--after-time <time>only messages newer than this ISO 8601 time, or 2h / 1d ago.
--transcribeturn voice messages not heard yet into text — by the messenger, or a model on this machine; can take minutes.
--model <id>which downloaded speech model hears them, with --transcribe; models audio list shows them.
--mark-readalso mark the chat read up to the newest message shown; the other person sees it.

search the local store — what was read, fetched or kept by serve; never asks the messenger

tg messages search <text> [options]
ArgumentWhat it is
textrequiredevery word must appear, as a word or the start of one: квартир finds квартира.
OptionWhat it does
--chat <chat>only this chat: a chat: its title or part of it, its id, @username, or me for Saved Messages.
--limit <n>how many.
--regexthe words are one regular expression, case-insensitive, tested against every stored text.

tg messages send

send a text message; without [text], the text is read from stdin

Changes something in Telegram.

tg messages send <chat> [text] [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
textoptionalthe message.
OptionWhat it does
--reply-to <message>answer this message, by its id in the same chat.
--send-id <id>repeat a send whose outcome was unknown, without risking a second copy.
--silentdeliver without a notification.
--no-previewno preview card for a link in the text.
--mdread bold, italic, ~~struck~~ and code in the text; \ keeps a mark literal.
--file <file>attach a file; the text becomes its caption.
--photo <file>attach a .jpg, .png or .webp as a photo; the text becomes its caption.
--as-filesend the --file as a file to download, a video included.
--voice <file>send an Ogg Opus file as a voice message, alone, with no text.
--allow-any-filesend a file even from a hidden folder, ~/.ssh or this CLI's own folders.
--at-time <time>let the messenger send it later, even with this machine off: 2026-09-25T09:00 (local time), or 30m, 2h, 1d from now.

tg messages show

one message, by its chat and id or by its msg: locator

tg messages show <chat> [message]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages; or a msg: locator, with no message id after it.
messageoptionalthe message id.

tg messages context

a message and what came either side of it, oldest first

tg messages context <chat> [message] [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages; or a msg: locator, with no message id after it.
messageoptionalthe message id.
OptionWhat it does
--before-n <n>how many before it. Default: 5.
--after-n <n>how many after it. Default: 5.

tg messages download

save a message's photos, files, videos and voice notes to a folder — or a whole chat's with --all

tg messages download <chat> [message] [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messageoptionalthe message id; left out with --all.
OptionWhat it does
--output-dir <dir>where to save them; created if missing. Default: ..
--allevery file of the chat, newest first; run it again to continue where it stopped.
--pause <duration>with --all, a pause between pages, to stay under the provider's limits. Default: 1s.

tg messages transcribe

a voice message as text — by Telegram where it can, else by a model on this machine

tg messages transcribe <chat> <message> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe id of a voice message.
OptionWhat it does
--localuse the model on this machine, never the messenger.
--model <id>which downloaded model; implies --local (models audio list).

tg messages edit

change the text of your own message; the other side may have read it already

Changes something in Telegram.

tg messages edit <chat> <message> [text] [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe id of your own message.
textoptionalthe new text; without it, read from stdin.
OptionWhat it does
--mdread bold, italic, ~~struck~~ and code in the text; \ keeps a mark literal.

tg messages delete

delete messages for you only; with --for-everyone, for everyone in the chat

Changes something in Telegram.

tg messages delete <chat> <messages> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagesrequiredthe message ids, at most 10.
OptionWhat it does
--for-everyonedelete for everyone in the chat, not only for you — they cannot get it back.
--allow-dangerousgo ahead without the question an ask level puts before a deletion.

tg messages forward

forward one message to another chat

Changes something in Telegram.

tg messages forward <chat> <message> [options]
ArgumentWhat it is
chatrequiredthe chat the message is in: a chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe message id.
OptionWhat it does
--to <chat>where it goes: a chat: its title or part of it, its id, @username, or me for Saved Messages.
--silentdeliver it without a notification.
--send-id <id>repeat a forward whose outcome was unknown, without risking a second copy.

tg messages pin

pin a message in a chat, quietly unless --notify

Changes something in Telegram.

tg messages pin <chat> <message> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe message id.
OptionWhat it does
--notifytell the chat's members about the pin.

tg messages unpin

unpin a message in a chat

Changes something in Telegram.

tg messages unpin <chat> <message>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe message id.

tg messages scheduled

messages waiting to be sent later in a chat, soonest first; cancel one in the app

tg messages scheduled <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

why a message is in its conversation: each link it has, and the chain of answers back to the start

tg messages links <chat> <message>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe message id.

tg reactions

react to messages

tg reactions add

put your reaction on a message; it replaces the one you had

Changes something in Telegram.

tg reactions add <chat> <message> <emoji>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe message id.
emojirequiredone emoji, for example 👍.

tg reactions remove

take your reaction off a message

Changes something in Telegram.

tg reactions remove <chat> <message>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe message id.

tg polls

read a poll, vote in it, close your own, create one

tg polls show

a poll and its answer ids, as the message carries it now

tg polls show <chat> <message>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe id of the message that carries the poll.

tg polls vote

vote in a poll, or take your vote back; the others see it unless the poll is anonymous

Changes something in Telegram.

tg polls vote <chat> <message> [answers] [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe id of the message that carries the poll.
answersoptionalanswer ids, as polls show prints them.
OptionWhat it does
--retracttake your vote back.

tg polls close

close your own poll; nobody can vote after that, and it cannot be reopened

Changes something in Telegram.

tg polls close <chat> <message>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
messagerequiredthe id of your own message that carries the poll.

tg polls create

send a poll to a chat, as a message of its own; public unless --anonymous

Changes something in Telegram.

tg polls create <chat> <question> <answers> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
questionrequiredthe question.
answersrequiredtwo answers or more.
OptionWhat it does
--multiplepeople may pick several answers.
--anonymousnobody sees who voted for what.
--revotepeople may change their vote.
--silentsend without a notification.
--send-id <id>repeat a create whose outcome was unknown, without risking a second poll.

tg models

models that run on this machine

tg models audio

speech models for transcribing voice messages

tg models audio list

the speech models, most suitable first, which are downloaded, and which one is the default

tg models audio list

tg models audio download

download a speech model once, checked against the sha256 this version expects

tg models audio download <model>
ArgumentWhat it is
modelrequireda model id from models audio list.

tg inbox

other people's unread messages in every chat; --new for what arrived since the last check

tg inbox [options]
OptionWhat it does
--newwhat arrived since the last check, each message once — for scheduled runs.
--since-time <time>what arrived after this ISO 8601 time, or 2h / 1d ago; the saved point stays put.
--limit <n>at most this many per chat, the newest.
--allmuted and archived chats too — left out unless they mention you or reply to you.
--transcribeturn voice messages not heard yet into text — by the messenger, or a model on this machine; can take minutes.
--model <id>which downloaded speech model hears them, with --transcribe; models audio list shows them.

tg review

every message, yours too, in chats that changed since a point — for reviewing who owes what

tg review [options]
OptionWhat it does
--since-time <time>where the last review ended — ISO 8601, or 2h / 1d ago; 3 days ago if not given.
--chat <chat>only this chat: a chat: its title or part of it, its id, @username, or me for Saved Messages.
--unanswered [duration]only questions to you or a group's admins that nobody answered, asked at least this long ago — 4h, 1d; 24h if not given.
--allmuted and archived chats too — left out unless they mention you or reply to you.
--transcribeturn voice messages not heard yet into text — by the messenger, or a model on this machine; can take minutes.
--model <id>which downloaded speech model hears them, with --transcribe; models audio list shows them.

tg topics

the topics of a forum group

tg topics list

a forum group's topics, newest activity first

tg topics list <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--limit <n>how many to show.
--page <n>which page, starting at 1.
--allevery row, no paging.

a forum group's topics whose title matches

tg topics search <chat> <text> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
textrequiredwords from the topic's title.
OptionWhat it does
--limit <n>how many to show.
--page <n>which page, starting at 1.
--allevery row, no paging.

tg watch

print new messages as they arrive, until Ctrl-C or --timeout (either ends it normally)

tg watch [options]
OptionWhat it does
--eventsalso edits, deletions and reactions; every line then names its event.

tg serve

keep the local store current until stopped — what a systemd or launchd unit runs

tg serve

tg server

tg serve in the background: start, stop, restart, status, logs; install adds a systemd or launchd unit

tg server start

start serve in the background — through the unit if one is installed — and answer once it connects

tg server start

tg server stop

stop this profile's serve — through the unit if it runs under one

tg server stop

tg server restart

stop it and start it again

tg server restart

tg server status

whether serve runs for this profile, since when, who started it, and the unit if there is one

tg server status

tg server logs

serve's latest log lines — from the journal under systemd, else its log file

tg server logs [options]
OptionWhat it does
-n, --lines <n>how many lines. Default: 50.

tg server install

write a systemd user unit or a launchd agent for this profile; starts nothing

tg server install

tg server uninstall

remove this profile's unit; stop it first

tg server uninstall

tg store

the local store of messages

tg store status

per chat: messages stored, the oldest and newest, and the stretches held completely

tg store status [chat]
ArgumentWhat it is
chatoptionala chat: its title or part of it, its id, @username, or me for Saved Messages.

tg store fetch

fetch a chat's history into the local store, newest first; run it again to continue

tg store fetch <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--limit <n>at most this many messages in this run; 1000 if not given.
--page-size <n>how many messages one request asks for; 100 if not given.
--pause <duration>pause between pages, to stay under the provider's limits. Default: 1s.
--since-time <time>stop once it reaches messages older than this: ISO 8601, or 2h / 1d ago.
--last <n>stop once the newest n messages are held.
--backgroundrun as a job that outlives this command; store jobs show follows it.
--estimateonly estimate how many messages, requests and minutes a full fetch would still take — from the store, no request.

tg store jobs

background fetch jobs

tg store jobs list

background fetch jobs, newest first

tg store jobs list

tg store jobs show

one background job — the newest when none is named — and what the store now holds of its chat

tg store jobs show [job]
ArgumentWhat it is
joboptionalthe job id store fetch --background printed.

tg store jobs cancel

stop a running background job after its current page; a later fetch resumes where it stopped

tg store jobs cancel <job>
ArgumentWhat it is
jobrequiredthe job id.

tg store export

a chat's stored messages as JSON lines, oldest first; never asks the messenger

tg store export <chat> [options]
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.
OptionWhat it does
--format <format>jsonl (the default): one message per line; markdown: a transcript with a heading per day, replies and forwards quoted.
--since-time <time>only from this ISO 8601 time, or 30m / 2h / 1d ago, on.
--output <file>write JSON lines, or the transcript, to this new file, readable only by you.

tg store clear

delete from the store the chats this account has left, with their messages

tg store clear [options]
OptionWhat it does
--leftthe chats this account has left — the only thing this clears.
--allow-dangerousyes, delete — it cannot be undone, and a chat you left cannot be fetched again.

tg store info

the store file: where it is, its size, its schema and how many rows it holds; changes nothing

tg store info

tg store check

whether the store is healthy — integrity, search indexes, disk, and which chats are behind

tg store check

tg store migrate

bring the store up to this build's schema, then normalize the messages stored before it

tg store migrate

tg store reindex

rebuild the word index and its typo vocabulary from the stored messages; loses no message

tg store reindex

tg store backup

copy the store into a new file, while it is in use; never overwrites a file

tg store backup <file>
ArgumentWhat it is
filerequiredthe new file.

tg store restore

put a backup in place of the store; the store it replaces is kept beside it, never deleted

tg store restore <file>
ArgumentWhat it is
filerequireda file store backup wrote.

tg conversations

the conversations inside a chat, found in the stored messages by replies, mentions and who wrote next

tg conversations build

find a chat's conversations in what the store holds, replacing the last build; never asks the messenger

tg conversations build [options]
OptionWhat it does
--chat <chat>a chat: its title or part of it, its id, @username, or me for Saved Messages.

tg conversations list

a chat's conversations, the newest first: when, how many messages, how many people

tg conversations list [options]
OptionWhat it does
--chat <chat>a chat: its title or part of it, its id, @username, or me for Saved Messages.
--since-time <time>only those that started at this ISO 8601 time, or 30m / 2h / 1d ago, or later.
--limit <n>how many.

tg conversations show

one conversation's messages, oldest first — by its id, or the one a message is in

tg conversations show <conversation> [message]
ArgumentWhat it is
conversationrequireda conversation id from conversations list; or a chat: its title or part of it, its id, @username, or me for Saved Messages, with a message.
messageoptionala message id in that chat: show the conversation it is in.

tg conversations batches

windows of a chat for your own AI agent to link: which earlier message each one answers

tg conversations batches status

how many messages still wait for an answer, in how many batches, and how much text

tg conversations batches status [options]
OptionWhat it does
--chat <chat>a chat: its title or part of it, its id, @username, or me for Saved Messages.
--size <n>messages to answer per batch, 10–200; 50 by default.

tg conversations batches next

the next window to answer, with the messages before it; message text goes to stdout only

tg conversations batches next [options]
OptionWhat it does
--chat <chat>a chat: its title or part of it, its id, @username, or me for Saved Messages.
--size <n>messages to answer per batch, 10–200; 50 by default.

your agent's answers: which earlier message each message of a batch answers

store your agent's answer to a batch, read as JSON from stdin: { "model", "answers": [{ "message", "parent", "confidence" }] }; all or nothing

tg conversations links add [options]
OptionWhat it does
--batch <id>the batch id conversations batches next printed.

drop your agent's answers for a chat, or only one model's; messages are never touched

tg conversations links clear [options]
OptionWhat it does
--chat <chat>a chat: its title or part of it, its id, @username, or me for Saved Messages.
--model <model>only the answers this model gave.

tg recipients

the chats this profile may send to, when the list is on

tg recipients list

the chats on the list; empty and off until the first add

tg recipients list

tg recipients add

allow sending to this chat; the first add turns the list on

Changes something in Telegram.

tg recipients add <chat>
ArgumentWhat it is
chatrequireda chat: its title or part of it, its id, @username, or me for Saved Messages.

tg recipients remove

stop allowing this chat; the list stays on

Changes something in Telegram.

tg recipients remove <chat>
ArgumentWhat it is
chatrequiredchat id, or the title as the list shows it.

tg recipients clear

delete the list, which turns it off: this profile may send to any chat again

Changes something in Telegram.

tg recipients clear

tg sends

every attempt to send from this profile — never the text

tg sends list

attempts to send, newest first: sent, refused, failed, or not known

tg sends list [options]
OptionWhat it does
--limit <n>how many to show.

tg runs

recorded runs — what this tool did, and when

tg runs list

recorded runs, newest first

tg runs list [options]
OptionWhat it does
--limit <n>how many to show. Default: 20.

tg runs show

one run: what it was, and one line per operation

tg runs show <run-id>
ArgumentWhat it is
run-idrequiredan id from tg runs list.

tg runs path

the directory holding one run

tg runs path <run-id>
ArgumentWhat it is
run-idrequiredan id from tg runs list.

tg config

the settings in force, and where each one came from

tg config show

the profile, the profiles that exist, and each setting with where it came from

tg config show [options]
OptionWhat it does
--botthe settings a bot command on this profile gets, rather than the personal account's.

tg config set

save a setting to the configuration file

Changes something in Telegram.

tg config set <setting> <value> [options]
ArgumentWhat it is
settingrequiredone of: limit, timeoutMs, color, senderColors, record, keepRunsForDays, readOnly, allow, permissions, sendsPerHour, transcribeWith, speechModel, readOtherBots, updateCheck, skillHint.
valuerequireda number, true or false, or for allow a list like send,reaction.
OptionWhat it does
--defaultschange what every profile gets, rather than this profile.
--personalonly for personal accounts — the personal section of the file.
--botonly for bots — the bot section of the file.

tg config unset

remove a setting from the configuration file

Changes something in Telegram.

tg config unset <setting> [options]
ArgumentWhat it is
settingrequiredone of: limit, timeoutMs, color, senderColors, record, keepRunsForDays, readOnly, allow, permissions, sendsPerHour, transcribeWith, speechModel, readOtherBots, updateCheck, skillHint.
OptionWhat it does
--defaultschange what every profile gets, rather than this profile.
--personalonly for personal accounts — the personal section of the file.
--botonly for bots — the bot section of the file.

tg doctor

the state this installation is in, without connecting unless --online

tg doctor [options]
OptionWhat it does
--onlinealso connect once and read the account; sends nothing.

tg doctor report

what a problem report holds; writes nothing

tg doctor report create

write a problem report to a file, and say where to send it

tg doctor report create [options]
OptionWhat it does
--run <id>the run the report is about; the newest failed one if not given.
--output <file>where to write it; a new file in this directory if not given.

tg commands

every command, option and exit code as JSON — what an agent reads instead of --help

tg commands

tg complete

shell completion: tg complete zsh prints the script to source

tg complete [words]
ArgumentWhat it is
wordsoptional

tg upgrade

upgrade tg with the package manager that installed it; --check only looks

tg upgrade [options]
OptionWhat it does
--checksay whether a newer version exists, and install nothing.

tg mcp

serve this profile to an agent over MCP, on stdin and stdout — claude mcp add tg -- tg mcp

tg mcp [options]
OptionWhat it does
--confirm-sendshow the owner every write in a form from the server first.
--allow-dangerousno form before a deletion whose permission level is ask.
--allow-sendno longer used — the profile's permissions decide; kept so an old setup still starts.
--allow-mark-readno longer used — the profile's permissions decide.
--allow-deleteno longer used — the profile's permissions decide.

tg mcp config

print the mcpServers entry for Claude Desktop, Cursor and others, with full paths; writes nothing

tg mcp config [options]
OptionWhat it does
--confirm-sendshow the owner every write in a form from the server first.
--allow-dangerousno form before a deletion whose permission level is ask.
--allow-sendno longer used — the profile's permissions decide; kept so an old setup still starts.
--allow-mark-readno longer used — the profile's permissions decide.
--allow-deleteno longer used — the profile's permissions decide.

tg bot

a Telegram bot, through the official Bot API and a bot token — not your personal account

tg bot auth

the bot token this profile uses

tg bot auth set

check a bot token with Telegram, then keep it — typed at a hidden prompt or piped on stdin

Changes something in Telegram.

tg bot auth set

tg bot auth show

where this profile's bot token comes from, and which bot it is

tg bot auth show

tg bot auth remove

forget this profile's bot token

Changes something in Telegram.

tg bot auth remove

tg bot list

every name on this machine that has a bot token; --check asks Telegram which bot each is

tg bot list [options]
OptionWhat it does
--checkask Telegram who each bot is.

tg bot chats

the chats this bot is in — Telegram gives a bot no list of them, so list shows the ones it has seen

tg bot chats list

chats this bot has seen on this machine — not a complete list from Telegram

tg bot chats list

tg bot chats show

one chat from Telegram, and remember it

tg bot chats show <chat>
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.

tg bot chats leave

take the bot out of a chat; only an admin of the chat can bring it back

Changes something in Telegram.

tg bot chats leave <chat>
ArgumentWhat it is
chatrequireda chat id, or the title of a chat this bot has seen.

tg bot chats action

show what the bot is doing in a chat — typing, sending a photo — for a few seconds

Changes something in Telegram.

tg bot chats action <chat> <action>
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
actionrequiredwhat the chat sees. One of: typing, photo, video, voice, file.

tg bot messages

the messages in the chats this bot is in

tg bot messages send

send a message as the bot; without [text], the text is read from stdin

Changes something in Telegram.

tg bot messages send <chat> [text] [options]
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
textoptionalthe message.
OptionWhat it does
--reply-to <message>answer this message, by its id in the same chat.
--silentdeliver without a notification.
--mdread bold, italic, ~~struck~~ and code in the text; \ keeps a mark literal.
--htmlthe text is HTML: , , , .
--file <file>attach a file; the text becomes its caption.
--photo <file>attach a .jpg, .png or .webp as a photo; the text becomes its caption.
--as-filesend the --file as a file to download, a video included.
--voice <file>send an Ogg Opus file as a voice message, alone, with no text.
--allow-any-filesend a file even from a hidden folder, ~/.ssh or this CLI's own folders.

tg bot messages list

the latest messages in a chat; where Telegram gives a bot no history, and with --offline, the ones this bot has seen on this machine

tg bot messages list <chat>
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.

tg bot messages show

one message by its id in a chat

tg bot messages show <chat> <message>
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
messagerequiredmessage id.

tg bot messages edit

replace the text of a message the bot sent

Changes something in Telegram.

tg bot messages edit <chat> <message> <text> [options]
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
messagerequiredmessage id.
textrequiredthe new text.
OptionWhat it does
--mdread bold, italic, ~~struck~~ and code in the text; \ keeps a mark literal.
--htmlthe text is HTML: , , , .

tg bot messages delete

delete messages in a chat the bot can delete in; it cannot be undone

Changes something in Telegram.

tg bot messages delete <chat> <messages> [options]
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
messagesrequiredmessage ids.
OptionWhat it does
--allow-dangerousdelete without asking.

tg bot messages pin

pin a message in a chat; quietly unless --notify

Changes something in Telegram.

tg bot messages pin <chat> <message> [options]
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
messagerequiredmessage id.
OptionWhat it does
--notifytell the chat's members.

tg bot messages unpin

unpin a message in a chat

Changes something in Telegram.

tg bot messages unpin <chat> <message>
ArgumentWhat it is
chatrequireda chat id, user: for a person, or the title of a chat this bot has seen.
messagerequiredmessage id.

tg bot recipients

the chats this bot may write to; with no list, every chat — clear removes the list

tg bot recipients list

the chats on the list, or nothing when there is no list

tg bot recipients list

tg bot recipients add

allow a chat: its id, user:<id>, or the title of a chat this bot has seen

Changes something in Telegram.

tg bot recipients add <chat>
ArgumentWhat it is
chatrequired

tg bot recipients remove

take a chat off the list

Changes something in Telegram.

tg bot recipients remove <chat>
ArgumentWhat it is
chatrequired

tg bot recipients clear

remove the list: the bot may write to any chat again

Changes something in Telegram.

tg bot recipients clear

tg bot sends

what this bot sent, edited and deleted from this machine — ids and outcomes, never text

tg bot sends list

tg bot sends list

tg skill

the instructions an agent is given for this tool

tg skill show

print SKILL.md — tg skill install puts it where Claude Code, Codex and Gemini CLI look for it

tg skill show [name]
ArgumentWhat it is
nameoptionalone of the skills shipped for a task: link-conversations.

tg skill install

write SKILL.md to ~/.claude/skills/tg-cli/ (Claude Code) and ~/.agents/skills/tg-cli/ (Codex, Gemini CLI)

tg skill install [options]
OptionWhat it does
--for <agents>which agents to install for. One of: claude, agents, all. Default: all.

Exit codes

Branch on the code, not on the text: the text can change, the code does not.

CodeWhen
0it worked
2validation_error
3configuration_error
4authentication_error
5permission_error
6not_found
7confirmation_required
8rate_limited
9timeout
10network_error
11provider_error
12provider_unavailable
13invalid_response
14outcome_unknown
130cancelled
1anything else

0 and only 0 means the operation was done. 14 (outcome_unknown) means a message may have gone: repeat it only with the same --send-id, which Telegram uses to drop a second copy.

On this page

Options for every commandtg sessiontg session starttg session endtg accounttg account showtg account updatetg account sessionstg account sessions listtg account sessions endtg chatstg chats listtg chats eventstg chats inspecttg chats showtg chats memberstg chats members listtg chats members addtg chats members removetg chats mark-readtg chats createtg chats jointg chats leavetg chats updatetg chats linktg chats link showtg chats link resettg chats adminstg chats admins addtg chats admins removetg chats folderstg chats folders listtg chats folders createtg chats folders updatetg chats folders deletetg chats rulestg chats rules showtg chats rules settg chats rules unsettg chats moderatetg contactstg contacts listtg contacts showtg contacts lookuptg contacts synctg contacts addtg contacts removetg contacts blocktg contacts unblocktg contacts renametg contacts importtg messagestg messages listtg messages searchtg messages sendtg messages showtg messages contexttg messages downloadtg messages transcribetg messages edittg messages deletetg messages forwardtg messages pintg messages unpintg messages scheduledtg messages linkstg reactionstg reactions addtg reactions removetg pollstg polls showtg polls votetg polls closetg polls createtg modelstg models audiotg models audio listtg models audio downloadtg inboxtg reviewtg topicstg topics listtg topics searchtg watchtg servetg servertg server starttg server stoptg server restarttg server statustg server logstg server installtg server uninstalltg storetg store statustg store fetchtg store jobstg store jobs listtg store jobs showtg store jobs canceltg store exporttg store cleartg store infotg store checktg store migratetg store reindextg store backuptg store restoretg conversationstg conversations buildtg conversations listtg conversations showtg conversations batchestg conversations batches statustg conversations batches nexttg conversations linkstg conversations links addtg conversations links cleartg recipientstg recipients listtg recipients addtg recipients removetg recipients cleartg sendstg sends listtg runstg runs listtg runs showtg runs pathtg configtg config showtg config settg config unsettg doctortg doctor reporttg doctor report createtg commandstg completetg upgradetg mcptg mcp configtg bottg bot authtg bot auth settg bot auth showtg bot auth removetg bot listtg bot chatstg bot chats listtg bot chats showtg bot chats leavetg bot chats actiontg bot messagestg bot messages sendtg bot messages listtg bot messages showtg bot messages edittg bot messages deletetg bot messages pintg bot messages unpintg bot recipientstg bot recipients listtg bot recipients addtg bot recipients removetg bot recipients cleartg bot sendstg bot sends listtg skilltg skill showtg skill installExit codes