Questions and answers
For developers
Short answers about buying and selling Stars, gifts, Premium and paying — with links to the full guides.
For developers
Is there an official Fragment API?
No: Fragment has no public API for buying Stars and Premium. Services that call themselves a "Fragment API" are third parties. Never give them your wallet's seed phrase or your Telegram sign-in.
What does connecting cost?
The key and the requests cost nothing: you pay for orders only, with a 3 % margin.
Can I buy Stars for somebody else's account?
Yes, for any public @username. Check the recipient before paying: a channel, group or bot cannot receive Stars, and an account with paid messages takes no fewer Stars than its message costs.
What happens if the Stars could not be delivered?
The order is refunded by the bot's rules, usually as Stars to the key owner's wallet, and its status becomes refunded.
What if I repeat a request after a dropped connection?
Send the same request with the same idempotency_key: the same order comes back, never a second one.
56 questions more
How many orders can I create?
One Stars invoice at a time, and no more than ten unpaid invoices within ten minutes. You set the ceilings for one invoice and for a day's invoices yourself in /api.
Where is the full documentation?
In the API documentation: every address, field, error code and examples in Python, Node.js and PHP. The machine-readable description is /api/v1/openapi.json.
Does the agent need a Telegram account?
No. A person creates the key in the bot, and the agent works with the key alone. Stars and Premium reach the @username the agent names in the order.
How much do Stars cost through the MCP server?
The same as through the HTTP API: 3 % over the Fragment price of the Stars. get_prices returns the exact price in USDT, GRAM and wallet Stars, and max_price in the order refuses anything above your ceiling.
What if the connection drops after an order?
Repeat create_order with the same idempotency_key. The server returns the order it already created instead of making a second one.
Where do I get a Telegram api_id and api_hash?
On my.telegram.org: log in with your phone number, open "API development tools" and fill in the app form.
Does a bot need an api_id?
No. A bot works through the Bot API with a token from @BotFather. api_id and api_hash are for programs that sign in to Telegram as a user.
Can I get several api_ids?
Only one api_id per phone number.
How do I add Stars payments to a Telegram bot?
Issue an invoice with sendInvoice or createInvoiceLink in XTR with an empty provider_token, answer pre-checkout within 10 seconds and deliver after successful_payment.
Do I need a payment provider for Stars?
No. For Stars, provider_token is an empty string.
How do I refund Stars to a buyer?
With the refundStarPayment method and the telegram_payment_charge_id from the payment message.
When can I withdraw a bot's Stars?
Through Fragment — from 1,000 Stars, each available 21 days after it arrives.
How do I create a Telegram bot without coding?
You can register a bot in a minute through @BotFather, but to make it do anything you need code. Telegram itself notes that creating a bot takes at least some programming skills.
How much does it cost to create a Telegram bot?
Nothing: Telegram doesn't charge users or developers for the bot platform. You only pay for your own server if you host the bot there.
What is BotFather?
Telegram's official bot for creating bots and managing them: name, description, picture, commands and token.
How do I get a BotFather token?
The token arrives right after /newbot. If it leaks, the /token command in BotFather issues a new one.
What username can a bot have?
5–32 characters: Latin letters, digits and underscores, and it must end in bot, for example my_shop_bot.
How do I add buttons to a Telegram bot?
Buttons are defined in the bot's code: inline buttons under a message and reply keyboards. The command list for the / menu is set in BotFather with /setcommands.
Which is better for a bot — getUpdates or a webhook?
getUpdates is easier for development and testing because it needs no public address. A webhook suits a bot that has a server with HTTPS and should get events instantly.
How do I receive messages in a Telegram bot through the API?
Call getUpdates in a loop with a timeout of about 30 seconds, and after each batch pass the last update_id plus one as offset. Or set an address with setWebhook.
Why doesn't getUpdates work?
Most likely a webhook is set on the bot: while it is active, getUpdates does not work. Remove it with deleteWebhook.
How do I check that a webhook works?
Call getWebhookInfo: it shows how many updates are waiting and the last delivery error, if there was one.
How long does Telegram keep messages for a bot?
No longer than 24 hours. If the bot stays offline for longer, the events are lost.
Which ports can a webhook use?
443, 80, 88 and 8443.
How do I send a message in Telegram through the API?
Call sendMessage with the bot's token, a chat_id and a text: curl "https://api.telegram.org/bot<TOKEN>/sendMessage" --data-urlencode "chat_id=<ID>" --data-urlencode "text=Hello".
How do I find the chat_id for sendMessage?
Send the bot any message and call getUpdates: the number is in message.chat.id. For a public channel you can use the channel's @username.
What does "chat not found" mean in Telegram?
The bot doesn't know that chat: either chat_id is wrong, or the person has never written to the bot. As a rule a bot can't start the conversation.
What does "bot was blocked by the user" mean?
It's a 403 error: the user blocked the bot, so you can't write to them.
Can I send a message from my own account instead of a bot?
Not with a token: requests made with a bot token are made by the bot, and the messages go out in its name.
How do I send a message to a channel through a bot?
Add the bot to the channel as an administrator and put the public channel's @username in chat_id.
How do I get a Telegram API token for a bot?
Send @BotFather the command /newbot: after you pick a name and a username it sends the token. For a bot that already exists, /token generates a new one.
More: The Telegram bot token: where to get it, how to check and protect it
What is a Telegram bot token?
It is the key that authorizes requests to the Bot API: it tells Telegram which bot a request comes from. The token is part of the address https://api.telegram.org/bot<token>/METHOD.
More: The Telegram bot token: where to get it, how to check and protect it
How do I check a bot token?
Call the getMe method: curl "https://api.telegram.org/bot<TOKEN>/getMe". With a valid token the reply has "ok": true and the bot's data.
More: The Telegram bot token: where to get it, how to check and protect it
What should I do if my bot token leaks?
Generate a new token in BotFather with /token, put it everywhere the bot uses it, and check with getWebhookInfo that the webhook points to your address.
More: The Telegram bot token: where to get it, how to check and protect it
How is a token different from api_id and api_hash?
The token belongs to a bot. api_id and api_hash are for programs that sign in to Telegram as a user, and you get them elsewhere: how to get them.
More: The Telegram bot token: where to get it, how to check and protect it
Can I keep the token in the code?
No: code easily ends up in a repository or in the wrong hands. Keep the token in an environment variable or in a file outside the repository.
More: The Telegram bot token: where to get it, how to check and protect it
Where can I host a Telegram bot?
Your own computer is fine for testing; for round-the-clock work use a VPS or managed hosting. What matters is that the bot's program keeps running and can reach the internet.
More: Where to host a Telegram bot: VPS, hosting and how to choose
Do I need hosting for a Telegram bot?
A bot answers only while its program runs. If that is your computer, you need no hosting, but the bot goes quiet when you switch the computer off. For a bot that is always available, run the program on a server.
More: Where to host a Telegram bot: VPS, hosting and how to choose
Does Telegram provide hosting for bots?
No. The webhook guide says Telegram offers neither hosting nor domain name services and tells you to pick a provider yourself.
More: Where to host a Telegram bot: VPS, hosting and how to choose
Do I need a domain for a Telegram bot?
Not for getUpdates: no domain, no certificate, no open ports. A webhook needs a server with a domain name and HTTPS; with a self-signed certificate an IP address can stand in for the domain.
More: Where to host a Telegram bot: VPS, hosting and how to choose
Is a VPS good enough for a bot?
Yes, it is the most common choice. On a VPS the bot runs all the time, and you can set up either getUpdates or a webhook on it.
More: Where to host a Telegram bot: VPS, hosting and how to choose
Should I choose getUpdates or a webhook?
Without a domain and a certificate use getUpdates: it is simpler. A webhook fits when you have a server with HTTPS and want updates instantly, or when the bot runs on an on-demand functions platform.
More: Where to host a Telegram bot: VPS, hosting and how to choose
How do I set commands for a Telegram bot?
Send @BotFather the /setcommands command, choose the bot and send a list of lines in the form command - description. From code, the setMyCommands method does the same.
More: Telegram Bot API commands: setMyCommands and the command menu
How many commands can a bot have?
setMyCommands takes at most 100 commands per scope. A command name is 1–32 characters and a description is 1–256.
More: Telegram Bot API commands: setMyCommands and the command menu
Can I show different commands to different people?
Yes. setMyCommands has the scope parameter (all private chats, groups, administrators, one chat or one member) and language_code (a language).
More: Telegram Bot API commands: setMyCommands and the command menu
What are the Telegram bot API commands?
They are the Bot API methods for the list of commands: setMyCommands, getMyCommands and deleteMyCommands. They are described in the Bot API documentation.
More: Telegram Bot API commands: setMyCommands and the command menu
Do I still have to handle a command that is in the list?
Yes. The list only suggests what to type. The bot receives the command as an ordinary message, and your program has to answer it.
More: Telegram Bot API commands: setMyCommands and the command menu
What does a Telegram API error mean?
It is a Bot API response with "ok": false: error_code holds a numeric code, description the reason, and sometimes parameters adds a hint such as retry_after. Read the reason in description.
More: Telegram Bot API errors: what 400, 401, 403, 409 and 429 mean
What does error 403 Forbidden: bot was blocked by the user mean?
The person blocked the bot, so you can't write to them. Repeating won't help. They can receive messages again only if they unblock the bot.
More: Telegram Bot API errors: what 400, 401, 403, 409 and 429 mean
How do I fix error 409 Conflict in a Telegram bot?
Run only one instance of the bot. If the error mentions a webhook, remove it with deleteWebhook or stop calling getUpdates.
More: Telegram Bot API errors: what 400, 401, 403, 409 and 429 mean
What should I do on a 429 Too Many Requests error?
Wait the number of seconds given in retry_after and repeat the request. To avoid it, send no more than one message a second to one chat and no more than 20 a minute to a group.
More: Telegram Bot API errors: what 400, 401, 403, 409 and 429 mean
Why does my bot get 401 Unauthorized?
The token is wrong or has been replaced. Check it with getMe and, if needed, get a new one from @BotFather.
More: Telegram Bot API errors: what 400, 401, 403, 409 and 429 mean
What does 400 Bad Request: chat not found mean?
The bot couldn't find the chat: check chat_id, and make sure the person has started the bot and that the bot is a member of the group or channel.
More: Telegram Bot API errors: what 400, 401, 403, 409 and 429 mean
Didn't find your answer?
@barboskich · Monday to Saturday, 12:00–23:00 Moscow time (UTC+3)