-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.txt
3703 lines (3264 loc) · 308 KB
/
api.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Telegram Bot API
The Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.
To learn how to create and set up a bot, please consult our Introduction to Bots and Bot FAQ.
Recent changes
Subscribe to @BotNews to be the first to know about the latest updates and join the discussion in @BotTalk
October 31, 2024
Bot API 7.11
Added the class CopyTextButton and the field copy_text in the class InlineKeyboardButton allowing bots to send and receive inline buttons that copy arbitrary text.
Added the parameter allow_paid_broadcast to the methods sendMessage, sendPhoto, sendVideo, sendAnimation, sendAudio, sendDocument, sendPaidMedia, sendSticker, sendVideoNote, sendVoice, sendLocation, sendVenue, sendContact, sendPoll, sendDice, sendInvoice, sendGame, sendMediaGroup and copyMessage.
Added the class TransactionPartnerTelegramApi for transactions related to paid broadcasted messages.
Introduced the ability to add media to existing text messages using the method editMessageMedia.
Added support for hashtag and cashtag entities with a specified chat username that opens a search for the relevant tag within the specified chat.
⚠️ WARNING! ⚠️
Starting December 1, 2024 messages with video that are sent, copied or forwarded to groups and channels with a sufficiently large audience can be automatically scheduled by the server until the respective video is reencoded. Such messages will have 0 as their message identifier and can't be used before they are actually sent.
September 6, 2024
Bot API 7.10
Added updates about purchased paid media, represented by the class PaidMediaPurchased and the field purchased_paid_media in the class Update.
Added the ability to specify a payload in sendPaidMedia that is received back by the bot in TransactionPartnerUser and purchased_paid_media updates.
Added the field prize_star_count to the classes GiveawayCreated, Giveaway, GiveawayWinners and ChatBoostSourceGiveaway.
Added the field is_star_giveaway to the class GiveawayCompleted.
Added the field SecondaryButton to the class WebApp.
Added the event secondaryButtonClicked for Mini Apps.
Added the field bottomBarColor and the method setBottomBarColor to the class WebApp.
Added the field bottom_bar_bg_color to the class ThemeParams.
August 14, 2024
Bot API 7.9
Added support for Super Channels, allowing received channel messages to have users or other channels as their senders.
Added the ability to send paid media to any chat.
Added the parameter business_connection_id to the method sendPaidMedia, allowing bots to send paid media on behalf of a business account.
Added the field paid_media to the class TransactionPartnerUser for transactions involving paid media.
Added the fields subscription_period and subscription_price to the class ChatInviteLink.
Added the method createChatSubscriptionInviteLink, allowing bots to create subscription invite links.
Added the method editChatSubscriptionInviteLink, allowing bots to edit the name of subscription invite links.
Added the field until_date to the class ChatMemberMember for members with an active subscription.
Added support for paid reactions and the class ReactionTypePaid.
July 31, 2024
Bot API 7.8
Added the option for bots to set a Main Mini App, which can be previewed and launched directly from a button in the bot's profile or a link.
Added the method shareToStory to the class WebApp.
Added the field has_main_web_app to the class User, which is returned in the response to getMe.
Added the parameter business_connection_id to the methods pinChatMessage and unpinChatMessage, allowing bots to manage pinned messages on behalf of a business account.
July 7, 2024
Bot API 7.7
Added the class RefundedPayment, containing information about a refunded payment.
Added the field refunded_payment to the class Message, describing a service message about a refunded payment.
Added the field isVerticalSwipesEnabled and the methods enableVerticalSwipes, disableVerticalSwipes to the class WebApp.
Added the event scanQrPopupClosed for Mini Apps.
See earlier changes »
Authorizing your bot
Each bot is given a unique authentication token when it is created. The token looks something like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11, but we'll use simply <token> in this document instead. You can learn about obtaining tokens and generating new ones in this document.
Making requests
All queries to the Telegram Bot API must be served over HTTPS and need to be presented in this form: https://api.telegram.org/bot<token>/METHOD_NAME. Like this for example:
https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe
We support GET and POST HTTP methods. We support four ways of passing parameters in Bot API requests:
URL query string
application/x-www-form-urlencoded
application/json (except for uploading files)
multipart/form-data (use to upload files)
The response contains a JSON object, which always has a Boolean field 'ok' and may have an optional String field 'description' with a human-readable description of the result. If 'ok' equals True, the request was successful and the result of the query can be found in the 'result' field. In case of an unsuccessful request, 'ok' equals false and the error is explained in the 'description'. An Integer 'error_code' field is also returned, but its contents are subject to change in the future. Some errors may also have an optional field 'parameters' of the type ResponseParameters, which can help to automatically handle the error.
All methods in the Bot API are case-insensitive.
All queries must be made using UTF-8.
Making requests when getting updates
If you're using webhooks, you can perform a request to the Bot API while sending an answer to the webhook. Use either application/json or application/x-www-form-urlencoded or multipart/form-data response content type for passing parameters. Specify the method to be invoked in the method parameter of the request. It's not possible to know that such a request was successful or get its result.
Please see our FAQ for examples.
Using a Local Bot API Server
The Bot API server source code is available at telegram-bot-api. You can run it locally and send the requests to your own server instead of https://api.telegram.org. If you switch to a local Bot API server, your bot will be able to:
Download files without a size limit.
Upload files up to 2000 MB.
Upload files using their local path and the file URI scheme.
Use an HTTP URL for the webhook.
Use any local IP address for the webhook.
Use any port for the webhook.
Set max_webhook_connections up to 100000.
Receive the absolute local path as a value of the file_path field without the need to download the file after a getFile request.
Do I need a Local Bot API Server
The majority of bots will be OK with the default configuration, running on our servers. But if you feel that you need one of these features, you're welcome to switch to your own at any time.
Getting updates
There are two mutually exclusive ways of receiving updates for your bot - the getUpdates method on one hand and webhooks on the other. Incoming updates are stored on the server until the bot receives them either way, but they will not be kept longer than 24 hours.
Regardless of which option you choose, you will receive JSON-serialized Update objects as a result.
Update
This object represents an incoming update.
At most one of the optional parameters can be present in any given update.
Field Type Description
update_id Integer The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This identifier becomes especially handy if you're using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
message Message Optional. New incoming message of any kind - text, photo, sticker, etc.
edited_message Message Optional. New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.
channel_post Message Optional. New incoming channel post of any kind - text, photo, sticker, etc.
edited_channel_post Message Optional. New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.
business_connection BusinessConnection Optional. The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot
business_message Message Optional. New message from a connected business account
edited_business_message Message Optional. New version of a message from a connected business account
deleted_business_messages BusinessMessagesDeleted Optional. Messages were deleted from a connected business account
message_reaction MessageReactionUpdated Optional. A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify "message_reaction" in the list of allowed_updates to receive these updates. The update isn't received for reactions set by bots.
message_reaction_count MessageReactionCountUpdated Optional. Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify "message_reaction_count" in the list of allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few minutes.
inline_query InlineQuery Optional. New incoming inline query
chosen_inline_result ChosenInlineResult Optional. The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.
callback_query CallbackQuery Optional. New incoming callback query
shipping_query ShippingQuery Optional. New incoming shipping query. Only for invoices with flexible price
pre_checkout_query PreCheckoutQuery Optional. New incoming pre-checkout query. Contains full information about checkout
purchased_paid_media PaidMediaPurchased Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat
poll Poll Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot
poll_answer PollAnswer Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
my_chat_member ChatMemberUpdated Optional. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.
chat_member ChatMemberUpdated Optional. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify "chat_member" in the list of allowed_updates to receive these updates.
chat_join_request ChatJoinRequest Optional. A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates.
chat_boost ChatBoostUpdated Optional. A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.
removed_chat_boost ChatBoostRemoved Optional. A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.
getUpdates
Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects.
Parameter Type Required Description
offset Integer Optional Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.
limit Integer Optional Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.
timeout Integer Optional Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
allowed_updates Array of String Optional A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.
Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.
Notes
1. This method will not work if an outgoing webhook is set up.
2. In order to avoid getting duplicate updates, recalculate offset after each server response.
setWebhook
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.
If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
Parameter Type Required Description
url String Yes HTTPS URL to send updates to. Use an empty string to remove webhook integration
certificate InputFile Optional Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
ip_address String Optional The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS
max_connections Integer Optional The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput.
allowed_updates Array of String Optional A JSON-serialized list of the update types you want your bot to receive. For example, specify ["message", "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.
Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.
drop_pending_updates Boolean Optional Pass True to drop all pending updates
secret_token String Optional A secret token to be sent in a header “X-Telegram-Bot-Api-Secret-Token” in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.
Notes
1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.
2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work.
3. Ports currently supported for webhooks: 443, 80, 88, 8443.
If you're having any trouble setting up webhooks, please check out this amazing guide to webhooks.
deleteWebhook
Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.
Parameter Type Required Description
drop_pending_updates Boolean Optional Pass True to drop all pending updates
getWebhookInfo
Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
WebhookInfo
Describes the current status of a webhook.
Field Type Description
url String Webhook URL, may be empty if webhook is not set up
has_custom_certificate Boolean True, if a custom certificate was provided for webhook certificate checks
pending_update_count Integer Number of updates awaiting delivery
ip_address String Optional. Currently used webhook IP address
last_error_date Integer Optional. Unix time for the most recent error that happened when trying to deliver an update via webhook
last_error_message String Optional. Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
last_synchronization_error_date Integer Optional. Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters
max_connections Integer Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
allowed_updates Array of String Optional. A list of update types the bot is subscribed to. Defaults to all update types except chat_member
Available types
All types used in the Bot API responses are represented as JSON-objects.
It is safe to use 32-bit signed integers for storing all Integer fields unless otherwise noted.
Optional fields may be not returned when irrelevant.
User
This object represents a Telegram user or bot.
Field Type Description
id Integer Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
is_bot Boolean True, if this user is a bot
first_name String User's or bot's first name
last_name String Optional. User's or bot's last name
username String Optional. User's or bot's username
language_code String Optional. IETF language tag of the user's language
is_premium True Optional. True, if this user is a Telegram Premium user
added_to_attachment_menu True Optional. True, if this user added the bot to the attachment menu
can_join_groups Boolean Optional. True, if the bot can be invited to groups. Returned only in getMe.
can_read_all_group_messages Boolean Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
supports_inline_queries Boolean Optional. True, if the bot supports inline queries. Returned only in getMe.
can_connect_to_business Boolean Optional. True, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in getMe.
has_main_web_app Boolean Optional. True, if the bot has a main Web App. Returned only in getMe.
Chat
This object represents a chat.
Field Type Description
id Integer Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
type String Type of the chat, can be either “private”, “group”, “supergroup” or “channel”
title String Optional. Title, for supergroups, channels and group chats
username String Optional. Username, for private chats, supergroups and channels if available
first_name String Optional. First name of the other party in a private chat
last_name String Optional. Last name of the other party in a private chat
is_forum True Optional. True, if the supergroup chat is a forum (has topics enabled)
ChatFullInfo
This object contains full information about a chat.
Field Type Description
id Integer Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
type String Type of the chat, can be either “private”, “group”, “supergroup” or “channel”
title String Optional. Title, for supergroups, channels and group chats
username String Optional. Username, for private chats, supergroups and channels if available
first_name String Optional. First name of the other party in a private chat
last_name String Optional. Last name of the other party in a private chat
is_forum True Optional. True, if the supergroup chat is a forum (has topics enabled)
accent_color_id Integer Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details.
max_reaction_count Integer The maximum number of reactions that can be set on a message in the chat
photo ChatPhoto Optional. Chat photo
active_usernames Array of String Optional. If non-empty, the list of all active chat usernames; for private chats, supergroups and channels
birthdate Birthdate Optional. For private chats, the date of birth of the user
business_intro BusinessIntro Optional. For private chats with business accounts, the intro of the business
business_location BusinessLocation Optional. For private chats with business accounts, the location of the business
business_opening_hours BusinessOpeningHours Optional. For private chats with business accounts, the opening hours of the business
personal_chat Chat Optional. For private chats, the personal channel of the user
available_reactions Array of ReactionType Optional. List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed.
background_custom_emoji_id String Optional. Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background
profile_accent_color_id Integer Optional. Identifier of the accent color for the chat's profile background. See profile accent colors for more details.
profile_background_custom_emoji_id String Optional. Custom emoji identifier of the emoji chosen by the chat for its profile background
emoji_status_custom_emoji_id String Optional. Custom emoji identifier of the emoji status of the chat or the other party in a private chat
emoji_status_expiration_date Integer Optional. Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any
bio String Optional. Bio of the other party in a private chat
has_private_forwards True Optional. True, if privacy settings of the other party in the private chat allows to use tg://user?id=<user_id> links only in chats with the user
has_restricted_voice_and_video_messages True Optional. True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat
join_to_send_messages True Optional. True, if users need to join the supergroup before they can send messages
join_by_request True Optional. True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators
description String Optional. Description, for groups, supergroups and channel chats
invite_link String Optional. Primary invite link, for groups, supergroups and channel chats
pinned_message Message Optional. The most recent pinned message (by sending date)
permissions ChatPermissions Optional. Default chat member permissions, for groups and supergroups
can_send_paid_media True Optional. True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.
slow_mode_delay Integer Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds
unrestrict_boost_count Integer Optional. For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions
message_auto_delete_time Integer Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds
has_aggressive_anti_spam_enabled True Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators.
has_hidden_members True Optional. True, if non-administrators can only get the list of bots and administrators in the chat
has_protected_content True Optional. True, if messages from the chat can't be forwarded to other chats
has_visible_history True Optional. True, if new chat members will have access to old messages; available only to chat administrators
sticker_set_name String Optional. For supergroups, name of the group sticker set
can_set_sticker_set True Optional. True, if the bot can change the group sticker set
custom_emoji_sticker_set_name String Optional. For supergroups, the name of the group's custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group.
linked_chat_id Integer Optional. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
location ChatLocation Optional. For supergroups, the location to which the supergroup is connected
Message
This object represents a message.
Field Type Description
message_id Integer Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent
message_thread_id Integer Optional. Unique identifier of a message thread to which the message belongs; for supergroups only
from User Optional. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats
sender_chat Chat Optional. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats.
sender_boost_count Integer Optional. If the sender of the message boosted the chat, the number of boosts added by the user
sender_business_bot User Optional. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.
date Integer Date the message was sent in Unix time. It is always a positive number, representing a valid date.
business_connection_id String Optional. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.
chat Chat Chat the message belongs to
forward_origin MessageOrigin Optional. Information about the original message for forwarded messages
is_topic_message True Optional. True, if the message is sent to a forum topic
is_automatic_forward True Optional. True, if the message is a channel post that was automatically forwarded to the connected discussion group
reply_to_message Message Optional. For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
external_reply ExternalReplyInfo Optional. Information about the message that is being replied to, which may come from another chat or forum topic
quote TextQuote Optional. For replies that quote part of the original message, the quoted part of the message
reply_to_story Story Optional. For replies to a story, the original story
via_bot User Optional. Bot through which the message was sent
edit_date Integer Optional. Date the message was last edited in Unix time
has_protected_content True Optional. True, if the message can't be forwarded
is_from_offline True Optional. True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message
media_group_id String Optional. The unique identifier of a media message group this message belongs to
author_signature String Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator
text String Optional. For text messages, the actual UTF-8 text of the message
entities Array of MessageEntity Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
link_preview_options LinkPreviewOptions Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changed
effect_id String Optional. Unique identifier of the message effect added to the message
animation Animation Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
audio Audio Optional. Message is an audio file, information about the file
document Document Optional. Message is a general file, information about the file
paid_media PaidMediaInfo Optional. Message contains paid media; information about the paid media
photo Array of PhotoSize Optional. Message is a photo, available sizes of the photo
sticker Sticker Optional. Message is a sticker, information about the sticker
story Story Optional. Message is a forwarded story
video Video Optional. Message is a video, information about the video
video_note VideoNote Optional. Message is a video note, information about the video message
voice Voice Optional. Message is a voice message, information about the file
caption String Optional. Caption for the animation, audio, document, paid media, photo, video or voice
caption_entities Array of MessageEntity Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
show_caption_above_media True Optional. True, if the caption must be shown above the message media
has_media_spoiler True Optional. True, if the message media is covered by a spoiler animation
contact Contact Optional. Message is a shared contact, information about the contact
dice Dice Optional. Message is a dice with random value
game Game Optional. Message is a game, information about the game. More about games »
poll Poll Optional. Message is a native poll, information about the poll
venue Venue Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set
location Location Optional. Message is a shared location, information about the location
new_chat_members Array of User Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
left_chat_member User Optional. A member was removed from the group, information about them (this member may be the bot itself)
new_chat_title String Optional. A chat title was changed to this value
new_chat_photo Array of PhotoSize Optional. A chat photo was change to this value
delete_chat_photo True Optional. Service message: the chat photo was deleted
group_chat_created True Optional. Service message: the group has been created
supergroup_chat_created True Optional. Service message: the supergroup has been created. This field can't be received in a message coming through updates, because bot can't be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.
channel_chat_created True Optional. Service message: the channel has been created. This field can't be received in a message coming through updates, because bot can't be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.
message_auto_delete_timer_changed MessageAutoDeleteTimerChanged Optional. Service message: auto-delete timer settings changed in the chat
migrate_to_chat_id Integer Optional. The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
migrate_from_chat_id Integer Optional. The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.
pinned_message MaybeInaccessibleMessage Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
invoice Invoice Optional. Message is an invoice for a payment, information about the invoice. More about payments »
successful_payment SuccessfulPayment Optional. Message is a service message about a successful payment, information about the payment. More about payments »
refunded_payment RefundedPayment Optional. Message is a service message about a refunded payment, information about the payment. More about payments »
users_shared UsersShared Optional. Service message: users were shared with the bot
chat_shared ChatShared Optional. Service message: a chat was shared with the bot
connected_website String Optional. The domain name of the website on which the user has logged in. More about Telegram Login »
write_access_allowed WriteAccessAllowed Optional. Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess
passport_data PassportData Optional. Telegram Passport data
proximity_alert_triggered ProximityAlertTriggered Optional. Service message. A user in the chat triggered another user's proximity alert while sharing Live Location.
boost_added ChatBoostAdded Optional. Service message: user boosted the chat
chat_background_set ChatBackground Optional. Service message: chat background set
forum_topic_created ForumTopicCreated Optional. Service message: forum topic created
forum_topic_edited ForumTopicEdited Optional. Service message: forum topic edited
forum_topic_closed ForumTopicClosed Optional. Service message: forum topic closed
forum_topic_reopened ForumTopicReopened Optional. Service message: forum topic reopened
general_forum_topic_hidden GeneralForumTopicHidden Optional. Service message: the 'General' forum topic hidden
general_forum_topic_unhidden GeneralForumTopicUnhidden Optional. Service message: the 'General' forum topic unhidden
giveaway_created GiveawayCreated Optional. Service message: a scheduled giveaway was created
giveaway Giveaway Optional. The message is a scheduled giveaway message
giveaway_winners GiveawayWinners Optional. A giveaway with public winners was completed
giveaway_completed GiveawayCompleted Optional. Service message: a giveaway without public winners was completed
video_chat_scheduled VideoChatScheduled Optional. Service message: video chat scheduled
video_chat_started VideoChatStarted Optional. Service message: video chat started
video_chat_ended VideoChatEnded Optional. Service message: video chat ended
video_chat_participants_invited VideoChatParticipantsInvited Optional. Service message: new participants invited to a video chat
web_app_data WebAppData Optional. Service message: data sent by a Web App
reply_markup InlineKeyboardMarkup Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
MessageId
This object represents a unique message identifier.
Field Type Description
message_id Integer Unique message identifier. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent
InaccessibleMessage
This object describes a message that was deleted or is otherwise inaccessible to the bot.
Field Type Description
chat Chat Chat the message belonged to
message_id Integer Unique message identifier inside the chat
date Integer Always 0. The field can be used to differentiate regular and inaccessible messages.
MaybeInaccessibleMessage
This object describes a message that can be inaccessible to the bot. It can be one of
Message
InaccessibleMessage
MessageEntity
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
Field Type Description
type String Type of the entity. Currently, can be “mention” (@username), “hashtag” (#hashtag or #hashtag@chatusername), “cashtag” ($USD or $USD@chatusername), “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” ([email protected]), “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “blockquote” (block quotation), “expandable_blockquote” (collapsed-by-default block quotation), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames), “custom_emoji” (for inline custom emoji stickers)
offset Integer Offset in UTF-16 code units to the start of the entity
length Integer Length of the entity in UTF-16 code units
url String Optional. For “text_link” only, URL that will be opened after user taps on the text
user User Optional. For “text_mention” only, the mentioned user
language String Optional. For “pre” only, the programming language of the entity text
custom_emoji_id String Optional. For “custom_emoji” only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker
TextQuote
This object contains information about the quoted part of a message that is replied to by the given message.
Field Type Description
text String Text of the quoted part of a message that is replied to by the given message
entities Array of MessageEntity Optional. Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, spoiler, and custom_emoji entities are kept in quotes.
position Integer Approximate quote position in the original message in UTF-16 code units as specified by the sender
is_manual True Optional. True, if the quote was chosen manually by the message sender. Otherwise, the quote was added automatically by the server.
ExternalReplyInfo
This object contains information about a message that is being replied to, which may come from another chat or forum topic.
Field Type Description
origin MessageOrigin Origin of the message replied to by the given message
chat Chat Optional. Chat the original message belongs to. Available only if the chat is a supergroup or a channel.
message_id Integer Optional. Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel.
link_preview_options LinkPreviewOptions Optional. Options used for link preview generation for the original message, if it is a text message
animation Animation Optional. Message is an animation, information about the animation
audio Audio Optional. Message is an audio file, information about the file
document Document Optional. Message is a general file, information about the file
paid_media PaidMediaInfo Optional. Message contains paid media; information about the paid media
photo Array of PhotoSize Optional. Message is a photo, available sizes of the photo
sticker Sticker Optional. Message is a sticker, information about the sticker
story Story Optional. Message is a forwarded story
video Video Optional. Message is a video, information about the video
video_note VideoNote Optional. Message is a video note, information about the video message
voice Voice Optional. Message is a voice message, information about the file
has_media_spoiler True Optional. True, if the message media is covered by a spoiler animation
contact Contact Optional. Message is a shared contact, information about the contact
dice Dice Optional. Message is a dice with random value
game Game Optional. Message is a game, information about the game. More about games »
giveaway Giveaway Optional. Message is a scheduled giveaway, information about the giveaway
giveaway_winners GiveawayWinners Optional. A giveaway with public winners was completed
invoice Invoice Optional. Message is an invoice for a payment, information about the invoice. More about payments »
location Location Optional. Message is a shared location, information about the location
poll Poll Optional. Message is a native poll, information about the poll
venue Venue Optional. Message is a venue, information about the venue
ReplyParameters
Describes reply parameters for the message that is being sent.
Field Type Description
message_id Integer Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified
chat_id Integer or String Optional. If the message to be replied to is from a different chat, unique identifier for the chat or username of the channel (in the format @channelusername). Not supported for messages sent on behalf of a business account.
allow_sending_without_reply Boolean Optional. Pass True if the message should be sent even if the specified message to be replied to is not found. Always False for replies in another chat or forum topic. Always True for messages sent on behalf of a business account.
quote String Optional. Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, and custom_emoji entities. The message will fail to send if the quote isn't found in the original message.
quote_parse_mode String Optional. Mode for parsing entities in the quote. See formatting options for more details.
quote_entities Array of MessageEntity Optional. A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode.
quote_position Integer Optional. Position of the quote in the original message in UTF-16 code units
MessageOrigin
This object describes the origin of a message. It can be one of
MessageOriginUser
MessageOriginHiddenUser
MessageOriginChat
MessageOriginChannel
MessageOriginUser
The message was originally sent by a known user.
Field Type Description
type String Type of the message origin, always “user”
date Integer Date the message was sent originally in Unix time
sender_user User User that sent the message originally
MessageOriginHiddenUser
The message was originally sent by an unknown user.
Field Type Description
type String Type of the message origin, always “hidden_user”
date Integer Date the message was sent originally in Unix time
sender_user_name String Name of the user that sent the message originally
MessageOriginChat
The message was originally sent on behalf of a chat to a group chat.
Field Type Description
type String Type of the message origin, always “chat”
date Integer Date the message was sent originally in Unix time
sender_chat Chat Chat that sent the message originally
author_signature String Optional. For messages originally sent by an anonymous chat administrator, original message author signature
MessageOriginChannel
The message was originally sent to a channel chat.
Field Type Description
type String Type of the message origin, always “channel”
date Integer Date the message was sent originally in Unix time
chat Chat Channel chat to which the message was originally sent
message_id Integer Unique message identifier inside the chat
author_signature String Optional. Signature of the original post author
PhotoSize
This object represents one size of a photo or a file / sticker thumbnail.
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
width Integer Photo width
height Integer Photo height
file_size Integer Optional. File size in bytes
Animation
This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
width Integer Video width as defined by the sender
height Integer Video height as defined by the sender
duration Integer Duration of the video in seconds as defined by the sender
thumbnail PhotoSize Optional. Animation thumbnail as defined by the sender
file_name String Optional. Original animation filename as defined by the sender
mime_type String Optional. MIME type of the file as defined by the sender
file_size Integer Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
Audio
This object represents an audio file to be treated as music by the Telegram clients.
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
duration Integer Duration of the audio in seconds as defined by the sender
performer String Optional. Performer of the audio as defined by the sender or by audio tags
title String Optional. Title of the audio as defined by the sender or by audio tags
file_name String Optional. Original filename as defined by the sender
mime_type String Optional. MIME type of the file as defined by the sender
file_size Integer Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
thumbnail PhotoSize Optional. Thumbnail of the album cover to which the music file belongs
Document
This object represents a general file (as opposed to photos, voice messages and audio files).
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
thumbnail PhotoSize Optional. Document thumbnail as defined by the sender
file_name String Optional. Original filename as defined by the sender
mime_type String Optional. MIME type of the file as defined by the sender
file_size Integer Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
Story
This object represents a story.
Field Type Description
chat Chat Chat that posted the story
id Integer Unique identifier for the story in the chat
Video
This object represents a video file.
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
width Integer Video width as defined by the sender
height Integer Video height as defined by the sender
duration Integer Duration of the video in seconds as defined by the sender
thumbnail PhotoSize Optional. Video thumbnail
file_name String Optional. Original filename as defined by the sender
mime_type String Optional. MIME type of the file as defined by the sender
file_size Integer Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
VideoNote
This object represents a video message (available in Telegram apps as of v.4.0).
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
length Integer Video width and height (diameter of the video message) as defined by the sender
duration Integer Duration of the video in seconds as defined by the sender
thumbnail PhotoSize Optional. Video thumbnail
file_size Integer Optional. File size in bytes
Voice
This object represents a voice note.
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
duration Integer Duration of the audio in seconds as defined by the sender
mime_type String Optional. MIME type of the file as defined by the sender
file_size Integer Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
PaidMediaInfo
Describes the paid media added to a message.
Field Type Description
star_count Integer The number of Telegram Stars that must be paid to buy access to the media
paid_media Array of PaidMedia Information about the paid media
PaidMedia
This object describes paid media. Currently, it can be one of
PaidMediaPreview
PaidMediaPhoto
PaidMediaVideo
PaidMediaPreview
The paid media isn't available before the payment.
Field Type Description
type String Type of the paid media, always “preview”
width Integer Optional. Media width as defined by the sender
height Integer Optional. Media height as defined by the sender
duration Integer Optional. Duration of the media in seconds as defined by the sender
PaidMediaPhoto
The paid media is a photo.
Field Type Description
type String Type of the paid media, always “photo”
photo Array of PhotoSize The photo
PaidMediaVideo
The paid media is a video.
Field Type Description
type String Type of the paid media, always “video”
video Video The video
Contact
This object represents a phone contact.
Field Type Description
phone_number String Contact's phone number
first_name String Contact's first name
last_name String Optional. Contact's last name
user_id Integer Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
vcard String Optional. Additional data about the contact in the form of a vCard
Dice
This object represents an animated emoji that displays a random value.
Field Type Description
emoji String Emoji on which the dice throw animation is based
value Integer Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji
PollOption
This object contains information about one answer option in a poll.
Field Type Description
text String Option text, 1-100 characters
text_entities Array of MessageEntity Optional. Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts
voter_count Integer Number of users that voted for this option
InputPollOption
This object contains information about one answer option in a poll to be sent.
Field Type Description
text String Option text, 1-100 characters
text_parse_mode String Optional. Mode for parsing entities in the text. See formatting options for more details. Currently, only custom emoji entities are allowed
text_entities Array of MessageEntity Optional. A JSON-serialized list of special entities that appear in the poll option text. It can be specified instead of text_parse_mode
PollAnswer
This object represents an answer of a user in a non-anonymous poll.
Field Type Description
poll_id String Unique poll identifier
voter_chat Chat Optional. The chat that changed the answer to the poll, if the voter is anonymous
user User Optional. The user that changed the answer to the poll, if the voter isn't anonymous
option_ids Array of Integer 0-based identifiers of chosen answer options. May be empty if the vote was retracted.
Poll
This object contains information about a poll.
Field Type Description
id String Unique poll identifier
question String Poll question, 1-300 characters
question_entities Array of MessageEntity Optional. Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions
options Array of PollOption List of poll options
total_voter_count Integer Total number of users that voted in the poll
is_closed Boolean True, if the poll is closed
is_anonymous Boolean True, if the poll is anonymous
type String Poll type, currently can be “regular” or “quiz”
allows_multiple_answers Boolean True, if the poll allows multiple answers
correct_option_id Integer Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.
explanation String Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters
explanation_entities Array of MessageEntity Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation
open_period Integer Optional. Amount of time in seconds the poll will be active after creation
close_date Integer Optional. Point in time (Unix timestamp) when the poll will be automatically closed
Location
This object represents a point on the map.
Field Type Description
latitude Float Latitude as defined by the sender
longitude Float Longitude as defined by the sender
horizontal_accuracy Float Optional. The radius of uncertainty for the location, measured in meters; 0-1500
live_period Integer Optional. Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only.
heading Integer Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only.
proximity_alert_radius Integer Optional. The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only.
Venue
This object represents a venue.
Field Type Description
location Location Venue location. Can't be a live location
title String Name of the venue
address String Address of the venue
foursquare_id String Optional. Foursquare identifier of the venue
foursquare_type String Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
google_place_id String Optional. Google Places identifier of the venue
google_place_type String Optional. Google Places type of the venue. (See supported types.)
WebAppData
Describes data sent from a Web App to the bot.
Field Type Description
data String The data. Be aware that a bad client can send arbitrary data in this field.
button_text String Text of the web_app keyboard button from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.
ProximityAlertTriggered
This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user.
Field Type Description
traveler User User that triggered the alert
watcher User User that set the alert
distance Integer The distance between the users
MessageAutoDeleteTimerChanged
This object represents a service message about a change in auto-delete timer settings.
Field Type Description
message_auto_delete_time Integer New auto-delete time for messages in the chat; in seconds
ChatBoostAdded
This object represents a service message about a user boosting a chat.
Field Type Description
boost_count Integer Number of boosts added by the user
BackgroundFill
This object describes the way a background is filled based on the selected colors. Currently, it can be one of
BackgroundFillSolid
BackgroundFillGradient
BackgroundFillFreeformGradient
BackgroundFillSolid
The background is filled using the selected color.
Field Type Description
type String Type of the background fill, always “solid”
color Integer The color of the background fill in the RGB24 format
BackgroundFillGradient
The background is a gradient fill.
Field Type Description
type String Type of the background fill, always “gradient”
top_color Integer Top color of the gradient in the RGB24 format
bottom_color Integer Bottom color of the gradient in the RGB24 format
rotation_angle Integer Clockwise rotation angle of the background fill in degrees; 0-359
BackgroundFillFreeformGradient
The background is a freeform gradient that rotates after every message in the chat.
Field Type Description
type String Type of the background fill, always “freeform_gradient”
colors Array of Integer A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
BackgroundType
This object describes the type of a background. Currently, it can be one of
BackgroundTypeFill
BackgroundTypeWallpaper
BackgroundTypePattern
BackgroundTypeChatTheme
BackgroundTypeFill
The background is automatically filled based on the selected colors.
Field Type Description
type String Type of the background, always “fill”
fill BackgroundFill The background fill
dark_theme_dimming Integer Dimming of the background in dark themes, as a percentage; 0-100
BackgroundTypeWallpaper
The background is a wallpaper in the JPEG format.
Field Type Description
type String Type of the background, always “wallpaper”
document Document Document with the wallpaper
dark_theme_dimming Integer Dimming of the background in dark themes, as a percentage; 0-100
is_blurred True Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12
is_moving True Optional. True, if the background moves slightly when the device is tilted
BackgroundTypePattern
The background is a PNG or TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be combined with the background fill chosen by the user.
Field Type Description
type String Type of the background, always “pattern”
document Document Document with the pattern
fill BackgroundFill The background fill that is combined with the pattern
intensity Integer Intensity of the pattern when it is shown above the filled background; 0-100
is_inverted True Optional. True, if the background fill must be applied only to the pattern itself. All other pixels are black in this case. For dark themes only
is_moving True Optional. True, if the background moves slightly when the device is tilted
BackgroundTypeChatTheme
The background is taken directly from a built-in chat theme.
Field Type Description
type String Type of the background, always “chat_theme”
theme_name String Name of the chat theme, which is usually an emoji
ChatBackground
This object represents a chat background.
Field Type Description
type BackgroundType Type of the background
ForumTopicCreated
This object represents a service message about a new forum topic created in the chat.
Field Type Description
name String Name of the topic
icon_color Integer Color of the topic icon in RGB format
icon_custom_emoji_id String Optional. Unique identifier of the custom emoji shown as the topic icon
ForumTopicClosed
This object represents a service message about a forum topic closed in the chat. Currently holds no information.
ForumTopicEdited
This object represents a service message about an edited forum topic.
Field Type Description
name String Optional. New name of the topic, if it was edited
icon_custom_emoji_id String Optional. New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed
ForumTopicReopened
This object represents a service message about a forum topic reopened in the chat. Currently holds no information.
GeneralForumTopicHidden
This object represents a service message about General forum topic hidden in the chat. Currently holds no information.
GeneralForumTopicUnhidden
This object represents a service message about General forum topic unhidden in the chat. Currently holds no information.
SharedUser
This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUsers button.
Field Type Description
user_id Integer Identifier of the shared user. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.
first_name String Optional. First name of the user, if the name was requested by the bot
last_name String Optional. Last name of the user, if the name was requested by the bot
username String Optional. Username of the user, if the username was requested by the bot
photo Array of PhotoSize Optional. Available sizes of the chat photo, if the photo was requested by the bot
UsersShared
This object contains information about the users whose identifiers were shared with the bot using a KeyboardButtonRequestUsers button.
Field Type Description
request_id Integer Identifier of the request
users Array of SharedUser Information about users shared with the bot.
ChatShared
This object contains information about a chat that was shared with the bot using a KeyboardButtonRequestChat button.
Field Type Description
request_id Integer Identifier of the request
chat_id Integer Identifier of the shared chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.
title String Optional. Title of the chat, if the title was requested by the bot.
username String Optional. Username of the chat, if the username was requested by the bot and available.
photo Array of PhotoSize Optional. Available sizes of the chat photo, if the photo was requested by the bot
WriteAccessAllowed
This object represents a service message about a user allowing a bot to write messages after adding it to the attachment menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess.
Field Type Description
from_request Boolean Optional. True, if the access was granted after the user accepted an explicit request from a Web App sent by the method requestWriteAccess
web_app_name String Optional. Name of the Web App, if the access was granted when the Web App was launched from a link
from_attachment_menu Boolean Optional. True, if the access was granted when the bot was added to the attachment or side menu
VideoChatScheduled
This object represents a service message about a video chat scheduled in the chat.
Field Type Description
start_date Integer Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator
VideoChatStarted
This object represents a service message about a video chat started in the chat. Currently holds no information.
VideoChatEnded
This object represents a service message about a video chat ended in the chat.
Field Type Description
duration Integer Video chat duration in seconds
VideoChatParticipantsInvited
This object represents a service message about new members invited to a video chat.
Field Type Description
users Array of User New members that were invited to the video chat
GiveawayCreated
This object represents a service message about the creation of a scheduled giveaway.
Field Type Description
prize_star_count Integer Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
Giveaway
This object represents a message about a scheduled giveaway.
Field Type Description
chats Array of Chat The list of chats which the user must join to participate in the giveaway
winners_selection_date Integer Point in time (Unix timestamp) when winners of the giveaway will be selected
winner_count Integer The number of users which are supposed to be selected as winners of the giveaway
only_new_members True Optional. True, if only users who join the chats after the giveaway started should be eligible to win
has_public_winners True Optional. True, if the list of giveaway winners will be visible to everyone
prize_description String Optional. Description of additional giveaway prize
country_codes Array of String Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
prize_star_count Integer Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
premium_subscription_month_count Integer Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
GiveawayWinners
This object represents a message about the completion of a giveaway with public winners.
Field Type Description
chat Chat The chat that created the giveaway
giveaway_message_id Integer Identifier of the message with the giveaway in the chat
winners_selection_date Integer Point in time (Unix timestamp) when winners of the giveaway were selected
winner_count Integer Total number of winners in the giveaway
winners Array of User List of up to 100 winners of the giveaway
additional_chat_count Integer Optional. The number of other chats the user had to join in order to be eligible for the giveaway
prize_star_count Integer Optional. The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only
premium_subscription_month_count Integer Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only
unclaimed_prize_count Integer Optional. Number of undistributed prizes
only_new_members True Optional. True, if only users who had joined the chats after the giveaway started were eligible to win
was_refunded True Optional. True, if the giveaway was canceled because the payment for it was refunded
prize_description String Optional. Description of additional giveaway prize
GiveawayCompleted
This object represents a service message about the completion of a giveaway without public winners.
Field Type Description
winner_count Integer Number of winners in the giveaway
unclaimed_prize_count Integer Optional. Number of undistributed prizes
giveaway_message Message Optional. Message with the giveaway that was completed, if it wasn't deleted
is_star_giveaway True Optional. True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.
LinkPreviewOptions
Describes the options used for link preview generation.
Field Type Description
is_disabled Boolean Optional. True, if the link preview is disabled
url String Optional. URL to use for the link preview. If empty, then the first URL found in the message text will be used
prefer_small_media Boolean Optional. True, if the media in the link preview is supposed to be shrunk; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview
prefer_large_media Boolean Optional. True, if the media in the link preview is supposed to be enlarged; ignored if the URL isn't explicitly specified or media size change isn't supported for the preview
show_above_text Boolean Optional. True, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text
UserProfilePhotos
This object represent a user's profile pictures.
Field Type Description
total_count Integer Total number of profile pictures the target user has
photos Array of Array of PhotoSize Requested profile pictures (in up to 4 sizes each)
File
This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile.
The maximum file size to download is 20 MB
Field Type Description
file_id String Identifier for this file, which can be used to download or reuse the file
file_unique_id String Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
file_size Integer Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
file_path String Optional. File path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
WebAppInfo
Describes a Web App.
Field Type Description
url String An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps
ReplyKeyboardMarkup
This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). Not supported in channels and for messages sent on behalf of a Telegram Business account.
Field Type Description
keyboard Array of Array of KeyboardButton Array of button rows, each represented by an Array of KeyboardButton objects
is_persistent Boolean Optional. Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to false, in which case the custom keyboard can be hidden and opened with a keyboard icon.
resize_keyboard Boolean Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app's standard keyboard.
one_time_keyboard Boolean Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can press a special button in the input field to see the custom keyboard again. Defaults to false.
input_field_placeholder String Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters
selective Boolean Optional. Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply to a message in the same chat and forum topic, sender of the original message.
Example: A user requests to change the bot's language, bot replies to the request with a keyboard to select the new language. Other users in the group don't see the keyboard.
KeyboardButton
This object represents one button of the reply keyboard. At most one of the optional fields must be used to specify type of the button. For simple text buttons, String can be used instead of this object to specify the button text.
Field Type Description
text String Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed
request_users KeyboardButtonRequestUsers Optional. If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a “users_shared” service message. Available in private chats only.
request_chat KeyboardButtonRequestChat Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a “chat_shared” service message. Available in private chats only.
request_contact Boolean Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only.
request_location Boolean Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only.
request_poll KeyboardButtonPollType Optional. If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.
web_app WebAppInfo Optional. If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a “web_app_data” service message. Available in private chats only.
Note: request_users and request_chat options will only work in Telegram versions released after 3 February, 2023. Older clients will display unsupported message.
KeyboardButtonRequestUsers
This object defines the criteria used to request suitable users. Information about the selected users will be shared with the bot when the corresponding button is pressed. More about requesting users »
Field Type Description
request_id Integer Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message
user_is_bot Boolean Optional. Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied.
user_is_premium Boolean Optional. Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied.
max_quantity Integer Optional. The maximum number of users to be selected; 1-10. Defaults to 1.
request_name Boolean Optional. Pass True to request the users' first and last names
request_username Boolean Optional. Pass True to request the users' usernames
request_photo Boolean Optional. Pass True to request the users' photos
KeyboardButtonRequestChat
This object defines the criteria used to request a suitable chat. Information about the selected chat will be shared with the bot when the corresponding button is pressed. The bot will be granted requested rights in the chat if appropriate. More about requesting chats ».
Field Type Description
request_id Integer Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message
chat_is_channel Boolean Pass True to request a channel chat, pass False to request a group or a supergroup chat.
chat_is_forum Boolean Optional. Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied.
chat_has_username Boolean Optional. Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied.
chat_is_created Boolean Optional. Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied.
user_administrator_rights ChatAdministratorRights Optional. A JSON-serialized object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied.
bot_administrator_rights ChatAdministratorRights Optional. A JSON-serialized object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied.
bot_is_member Boolean Optional. Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied.
request_title Boolean Optional. Pass True to request the chat's title
request_username Boolean Optional. Pass True to request the chat's username
request_photo Boolean Optional. Pass True to request the chat's photo
KeyboardButtonPollType
This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
Field Type Description
type String Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type.
ReplyKeyboardRemove
Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). Not supported in channels and for messages sent on behalf of a Telegram Business account.
Field Type Description
remove_keyboard True Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)
selective Boolean Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply to a message in the same chat and forum topic, sender of the original message.
Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.
InlineKeyboardMarkup
This object represents an inline keyboard that appears right next to the message it belongs to.
Field Type Description
inline_keyboard Array of Array of InlineKeyboardButton Array of button rows, each represented by an Array of InlineKeyboardButton objects
InlineKeyboardButton
This object represents one button of an inline keyboard. Exactly one of the optional fields must be used to specify type of the button.
Field Type Description
text String Label text on the button
url String Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id=<user_id> can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings.
callback_data String Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes
web_app WebAppInfo Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account.
login_url LoginUrl Optional. An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.
switch_inline_query String Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline query in the input field. May be empty, in which case just the bot's username will be inserted. Not supported for messages sent on behalf of a Telegram Business account.
switch_inline_query_current_chat String Optional. If set, pressing the button will insert the bot's username and the specified inline query in the current chat's input field. May be empty, in which case only the bot's username will be inserted.
This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent on behalf of a Telegram Business account.
switch_inline_query_chosen_chat SwitchInlineQueryChosenChat Optional. If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. Not supported for messages sent on behalf of a Telegram Business account.
copy_text CopyTextButton Optional. Description of the button that copies the specified text to the clipboard.
callback_game CallbackGame Optional. Description of the game that will be launched when the user presses the button.
NOTE: This type of button must always be the first button in the first row.
pay Boolean Optional. Specify True, to send a Pay button. Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.
LoginUrl
This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in:
TITLE
Telegram apps support these buttons as of version 5.7.
Sample bot: @discussbot
Field Type Description
url String An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.
NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization.