# Telegram bot deep links: the start parameter and startgroup

> Build t.me links with start, startgroup, startapp and startattach, read the parameter in your bot, and fit referral tokens in 64 characters.

Published 2026-11-04. Z-API Omni team.

Send users to `https://t.me/<bot_username>?start=<parameter>` and your bot receives an ordinary message whose text is `/start <parameter>`. The parameter can be up to 64 characters, and only "A-Z, a-z, 0-9, _ and - are allowed" ([bot features](https://core.telegram.org/bots/features#deep-linking), accessed 2026-11-04). `startgroup` does the same when adding the bot to a group. `startapp` passes a value to a Mini App, up to 512 characters in direct links. Link formats come from Telegram's [deep links page](https://core.telegram.org/api/links) (accessed 2026-11-04), checked against Bot API 10.3 of August 24, 2026.

## Link types at a glance

| Link | What it opens | What arrives | Documented limit |
| --- | --- | --- | --- |
| `t.me/<bot>?start=<param>` | Private chat with the bot | Message text `/start <param>` | 64 characters, `A-Z a-z 0-9 _ -` |
| `t.me/<bot>?startgroup=<param>` | Group picker, then the bot is added | `/start@<bot> <param>` in the group | 64 base64url characters |
| `t.me/<bot>?startchannel&admin=<rights>` | Adds the bot to a channel as admin | No parameter | Channels take none |
| `t.me/<bot>?startapp=<param>` | The bot's Main Mini App | `start_param` in `initData` | Not stated for this form |
| `t.me/<bot>/<app>?startapp=<param>` | A Mini App by short name | `start_param` in `initData` | 512 characters |
| `t.me/<bot>?startattach=<param>` | Attachment menu app in the current chat | `start_param` in `initData` | Not stated |

The `tg://resolve?domain=<bot_username>&start=<parameter>` form opens the same private chat from inside apps that handle the `tg://` scheme.

## The start parameter in a private chat

Telegram's own example is `https://t.me/your_bot?start=airplane`, which reaches the bot as the message `/start airplane`. Your handler reads the text, splits it once on the first space and takes the rest.

When the link carries a parameter, the deep links page says the client replaces the input bar with a Start button. That happens even when the user started the bot earlier. Tapping it sends the parameter through `messages.startBot`. A returning user who taps a link again therefore sends `/start <param>` again, as the deep links page implies. Telegram doesn't say how often that can repeat, so handle the same parameter twice without side effects.

The 64-character limit and the character set rule out raw query strings. `=`, `&`, `%`, `.` and spaces are all outside the set. A full UTM string such as `utm_source=newsletter&utm_campaign=spring` can't travel as is.

## startgroup and startchannel

`https://t.me/your_bot?startgroup=spaceship` "prompts the user to select a group to add the bot to". The bot then receives `/start@your_bot spaceship` in that group. [The Telegram commands post](/academy/articles/telegram-bot-commands-menu-setmycommands/) parses that `@your_bot` form with message entities.

Both group and channel links accept `admin`, a list of rights joined by `+`. It's optional for groups and required for `startchannel`. The identifiers are `change_info`, `post_messages`, `edit_messages`, `delete_messages`, `restrict_members`, `invite_users`, `pin_messages`, `manage_topics`, `promote_members`, `manage_video_chats`, `anonymous`, `manage_chat`, `post_stories`, `edit_stories`, `delete_stories`, `manage_direct_messages` and `manage_tags`. If the bot is already an admin, Telegram combines its current rights with the requested ones. A link that asks for admin rights in a group looks like this:

```text
https://t.me/your_bot?startgroup=spaceship&admin=delete_messages+pin_messages
```

Whether the bot sees later group messages depends on privacy mode, covered in [Telegram bot privacy mode](/academy/articles/telegram-bot-privacy-mode-group-messages/).

## startapp and startattach for Mini Apps

`startapp` opens a Mini App instead of the chat. A non-empty value reaches the app as `initData.start_param` and as the GET parameter `tgWebAppStartParam`. Bot API 6.8 of August 18, 2023 "Increased to 512 characters the maximum length of the startapp parameter in direct Web App links" ([changelog](https://core.telegram.org/bots/api-changelog), accessed 2026-11-04). The changelog names only direct links, so don't count on 512 for the Main Mini App form.

Telegram documents no character set for `startapp`. Sticking to base64url characters is our recommendation, since they survive URL handling and match the `start` rule. Add `mode=compact` for a half-height app or `mode=fullscreen` for full screen. If the bot has no Main Mini App, `t.me/<bot>?startapp` falls back to a normal link to the bot.

Read `start_param` on the server from `initData` after you validate it. `initDataUnsafe` "should not be trusted", and the HMAC check is in [Telegram Mini Apps and initData](/academy/articles/telegram-mini-apps-validate-init-data/).

`startattach` opens an attachment menu app. The bare form opens it in the current chat. `t.me/<username>?attach=<bot_username>` targets one chat, and `t.me/<bot_username>?startattach&choose=users+bots+groups+channels` lets the user pick. The attachment menu is limited to major advertisers on the Telegram Ad Platform in production. Every bot can use it in the test environment.

## Referral, UTM and account linking

Telegram prescribes no pattern for referrals or campaign tracking. What follows is our recommendation. Put a short opaque token in the parameter and keep what it stands for (campaign, UTM values, the referring user) in your database. The link stays inside 64 characters, and nobody can edit the campaign by changing the URL.

`secrets.token_urlsafe` produces only `A-Z a-z 0-9 - _`, so its output fits the allowed set. Sixteen random bytes become 22 characters. If you'd rather carry the data itself in the link, base64url without padding holds up to 48 bytes in 64 characters, because each character carries 6 bits. Drop the `=` padding, since `=` is not allowed. Anyone can decode base64, so keep private data out of it.

```python
import base64
import secrets

def encode_start(payload: bytes) -> str:
    s = base64.urlsafe_b64encode(payload).rstrip(b"=").decode()
    if len(s) > 64:
        raise ValueError("start parameter over 64 characters")
    return s

def decode_start(param: str) -> bytes:
    return base64.urlsafe_b64decode(param + "=" * (-len(param) % 4))

def start_param(text: str):
    """Return the parameter from "/start <param>" or "/start@your_bot <param>"."""
    parts = text.split(maxsplit=1)
    return parts[1] if len(parts) == 2 and parts[0].split("@")[0] == "/start" else None

tokens = {}  # token -> what it stands for; use a database table with an expiry in production
token = secrets.token_urlsafe(16)
tokens[token] = {"utm_source": "newsletter", "utm_campaign": "spring"}
print(f"https://t.me/your_bot?start={token}")

param = start_param(f"/start {token}")
print(tokens.get(param))

readable = encode_start(b"product:8812")
print(readable, decode_start(readable))
```

The `start_param` helper accepts `/start@any_bot`, so compare the name after `@` with your bot's username if that matters.

For account linking, the same pattern works with a one-time token. Your site generates it for a logged-in user and shows the link. When `/start <token>` arrives, bind `message.from.id` to that site account and delete the token. Anyone who gets the link can claim it first, so keep the expiry short. This is also our design. The one linking flow Telegram documents is the Business one: tapping "Manage Bot" in a managed chat sends `/start bizChat<user_chat_id>`, covered in [Telegram Business bots](/academy/articles/telegram-business-bots-business-connection/).

Store the first-touch campaign once per user if you report on acquisition. A returning user can tap a new link and send a new `/start`. Decide whether a second token overwrites the first or is logged as a separate touch.

*Z-API Omni team*
