Methods 
Telegram Mini Apps methods are events, which execute some predefined action. They are always called by a Mini App.
Web 
As long as the web version of Telegram displays the front-end application in <iframe/> tag, it uses the default way of communication between 2 iframes - sending messages through window.parent.postMessage function.
As the first parameter, you should pass a JSON object converted to a string. The object should have this interface:
interface MessageJSON {
  eventType: string;
  eventData: any;
}interface MessageJSON {
  eventType: string;
  eventData: any;
}The second parameter is targetOrigin - allowed parent iframe origin. We recommend avoiding the usage of wildcard * as long as it is not secure - your application could be inserted not by Telegram, but by another iframe that will still be able to communicate with your app and receive some data.
As a default value, you could use https://web.telegram.org.
So, as you see, each method has its own name expressed by eventType and parameters stored in eventData property. Here is the usage example:
const data = JSON.stringify({
  eventType: 'web_app_setup_back_button',
  eventData: {
    is_visible: true,
  },
});
window.parent.postMessage(data, 'https://web.telegram.org');const data = JSON.stringify({
  eventType: 'web_app_setup_back_button',
  eventData: {
    is_visible: true,
  },
});
window.parent.postMessage(data, 'https://web.telegram.org');This code will make the Telegram BackButton appear.
Desktop and mobile 
Unlike the web, desktop and mobile applications use a bit more unusual way of calling methods. Both of these platforms will create a global function window.TelegramWebviewProxy.postEvent.
As the first argument, this function accepts the event name. The second one - the parameters object, converted to a string. Here is how it works:
const data = JSON.stringify({ is_visible: true });
window
  .TelegramWebviewProxy
  .postEvent('web_app_setup_back_button', data);const data = JSON.stringify({ is_visible: true });
window
  .TelegramWebviewProxy
  .postEvent('web_app_setup_back_button', data);Windows Phone 
Telegram Windows Phone app provides such function as window.external.notify. It accepts the same parameter as the web version does:
const data = JSON.stringify({
  eventType: 'web_app_setup_back_button',
  eventData: { is_visible: true },
});
window.external.notify(data);const data = JSON.stringify({
  eventType: 'web_app_setup_back_button',
  eventData: { is_visible: true },
});
window.external.notify(data);Available methods 
This section contains a list of available methods to call with their names, description, and parameters. In case, Mini App does not satisfy the minimal method version requirement, nothing will happen. The native app just doesn't know which method should be called as long as it is not defined internally.
iframe_ready 
Notifies parent iframe about the current frame is ready. This method is only used in the Web version of Telegram. As a result, Mini App will receive set_custom_style event.
| Field | Type | Description | 
|---|---|---|
| reload_supported | boolean | Optional. True, if current Mini App supports native reloading. | 
iframe_will_reload 
Notifies parent iframe about the current iframe is going to reload.
web_app_close 
Closes Mini App.
web_app_close_scan_qr_popup 
Available since: v6.4
Closes a QR scanner. The Telegram application creates the scan_qr_popup_closed event.
web_app_data_send 
Sends data to the bot. When this method is called, a service message is sent to the bot containing the data of the length up to 4096 bytes. Then, Mini App will be closed.
To get more information, take a look at web_app_data field in the class Message.
| Field | Type | Description | 
|---|---|---|
| data | string | Data to send to a bot. Should not have size of more than 4096 bytes. | 
web_app_expand 
Expands the Mini App.
web_app_invoke_custom_method 
Available since: v6.9
| Field | Type | Description | 
|---|---|---|
| req_id | string | Current invocation unique identifier. | 
| method | string | Method name. | 
| params | unknown | Parameters according to method. | 
web_app_open_invoice 
Available since: v6.1
Opens an invoice by its specified slug. More information about invoices in this documentation.
| Field | Type | Description | 
|---|---|---|
| slug | string | Invoice unique identifier. | 
web_app_open_link 
Opens link in the default browser. Mini App will not be closed.
| Field | Type | Description | Available since | 
|---|---|---|---|
| url | string | URL to be opened by Telegram application. Should be a full path with httpsprotocol. | |
| try_instant_view | boolean | Optional. Link will be opened in Instant View mode if possible. | v6.4 | 
web_app_open_popup 
Available since: v6.2
Opens a new popup. When user closes the popup, Telegram creates the popup_closed event.
| Field | Type | Description | 
|---|---|---|
| title | string | The text to be displayed in the popup title, 0-64 characters | 
| message | string | The message to be displayed in the body of the popup, 1-256 characters | 
| buttons | PopupButton[] | List of buttons to be displayed in the popup, 1-3 buttons | 
PopupButton 
| Field | Type | Description | 
|---|---|---|
| id | string | Identifier of the button, 0-64 characters. | 
| type | string | Type of the button. Values: 
 | 
| text | string | The text to be displayed on the button, 0-64 characters. Ignored when typeisok,closeorcancel. | 
web_app_open_scan_qr_popup 
Available since: v6.4
Opens a QR scanner. When the scanner was closed, the Telegram application creates the scan_qr_popup_closed event. When the scanner reads QR, Telegram creates the qr_text_received event.
| Field | Type | Description | 
|---|---|---|
| text | string | Optional. Text to be displayed in the QR scanner. | 
web_app_open_tg_link 
Available since: v6.1
Opens the Telegram link by its pathname and query parameters. The link will be opened in the Telegram app, Mini App will be closed.
| Field | Type | Description | 
|---|---|---|
| path_full | string | Should be a value taken from the link of this format: https://t.me/{path_full}. Can additionally contain query parameters. | 
web_app_read_text_from_clipboard 
Available since: v6.4
Reads text from the clipboard. The method accepts a request identifier which is used to appropriately retrieve the method execution result from the clipboard_text_received event.
| Field | Type | Description | 
|---|---|---|
| req_id | string | Unique request identifier. Should be any unique string to handle the generated event appropriately. | 
web_app_ready 
Notifies Telegram about current application is ready to be shown. This method will make Telegram to remove application loader and display Mini App.
web_app_request_phone 
Available since: v6.9
Requests access to current user's phone.
web_app_request_theme 
Requests current theme from Telegram. As a result, Telegram will create theme_changed event.
web_app_request_viewport 
Requests current viewport information from Telegram. As a result, Telegram will create viewport_changed event.
web_app_request_write_access 
Available since: v6.9
Requests write message access to current user.
web_app_set_background_color 
Available since: v6.1
Updates the Mini App background color.
| Field | Type | Description | 
|---|---|---|
| color | string | The Mini App background color in #RRGGBBformat. | 
web_app_set_header_color 
Available since: v6.1
Updates the Mini App header color. This method should accept color_key or color property.
| Field | Type | Description | Available since | 
|---|---|---|---|
| color_key | string | The Mini App header color key. Could be either bg_colororsecondary_bg_color. | |
| color | string | Color in RGB format. | v6.9 | 
web_app_setup_back_button 
Available since: v6.1
Updates the Back Button settings.
| Field | Type | Description | 
|---|---|---|
| is_visible | boolean | Should the Back Button be visible. | 
web_app_setup_closing_behavior 
Updates current closing behavior.
| Field | Type | Description | 
|---|---|---|
| need_confirmation | boolean | Will user be prompted in case, an application is going to be closed. | 
web_app_setup_main_button 
Updates the Main Button settings.
| Field | Type | Description | 
|---|---|---|
| is_visible | boolean | Optional. Should the Main Button be displayed. | 
| is_active | boolean | Optional. Should the Main Button be enabled. | 
| is_progress_visible | boolean | Optional. Should loader inside the Main Button be displayed. Use this property in case, some operation takes time. This loader will make user notified about it. | 
| text | string | Optional. Text inside the Main Button. | 
| color | string | Optional. The Main Button background color in #RRGGBBformat. | 
| text_color | string | Optional. The Main Button text color in #RRGGBBformat. | 
web_app_setup_settings_button 
Available since: v6.10
Updates current state of Settings Button.
| Field | Type | Description | 
|---|---|---|
| is_visible | boolean | Should the Settings Button be displayed. | 
web_app_switch_inline_query 
Available since: v6.7
Inserts the bot's username and the specified inline query in the current chat's input field. Query may be empty, in which case only the bot's username will be inserted. The client prompts the user to choose a specific chat, then opens that chat and inserts the bot's username and the specified inline query in the input field.
| Field | Type | Description | 
|---|---|---|
| query | string | Text which should be inserted in the input after the current bot name. Max length is 256 symbols. | 
| chat_types | string[] | List of chat types which could be chosen to send the message. Could be empty list. Values: 
 | 
web_app_trigger_haptic_feedback 
Available since: v6.1
Generates the haptic feedback event.
| Field | Type | Description | 
|---|---|---|
| type | string | Type of haptic event. Values: 
 | 
| impact_style | string | Required when typeisimpact. Values:
 | 
| notification_type | string | Required when typeisnotification. Values:
 | 
 Telegram Mini Apps
Telegram Mini Apps