-
Notifications
You must be signed in to change notification settings - Fork 8
/
schema.yaml
3188 lines (3081 loc) · 105 KB
/
schema.yaml
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
openapi: 3.0.0
info:
version: 0.5.6
title: TamTam Bot API
license:
name: Apache 2.0
description: |-
# About
Bot API allows bots to interact with TamTam. Methods are called by sending HTTPS requests to [botapi.tamtam.chat](https://botapi.tamtam.chat) domain.
Bots are third-party applications that use TamTam features. A bot can legitimately take part in a conversation. It can be achieved through HTTP requests to the TamTam Bot API.
## Features
TamTam bots of the current version are able to:
- Communicate with users and respond to requests
- Recommend users complete actions via programmed buttons
- Request personal data from users (name, short reference, phone number)
We'll keep working on expanding bot capabilities in the future.
## Examples
Bots can be used for the following purposes:
- Providing support, answering frequently asked questions
- Sending typical information
- Voting
- Likes/dislikes
- Following external links
- Forwarding a user to a chat/channel
## @PrimeBot
[PrimeBot](https://tt.me/primebot) is the main bot in TamTam, all bots creator. Use PrimeBot to create and edit
your bots. Feel free to contact us for any questions, [@support](https://tt.me/support) or [team@tamtam.chat](mailto:team@tamtam.chat).
## HTTP verbs
`GET` — getting resources, parameters are transmitted via URL
`POST` — creation of resources (for example, sending new messages)
`PUT` — editing resources
`DELETE` — deleting resources
`PATCH` — patching resources
## HTTP response codes
`200` — successful operation
`400` — invalid request
`401` — authentication error
`404` — resource not found
`405` — method is not allowed
`429` — the number of requests is exceeded
`503` — service unavailable
## Resources format
For content requests (PUT and POST) and responses, the API uses the JSON format.
All strings are UTF-8 encoded.
Date/time fields are represented as the number of milliseconds that have elapsed since 00:00 January 1, 1970 in the long format. To get it, you can simply multiply the UNIX timestamp by 1000. All date/time fields have a UTC timezone.
## Error responses
In case of an error, the API returns a response with the corresponding HTTP code and JSON with the following fields:
`code` - the string with the error key
`message` - a string describing the error </br>
For example:
```bash
> http https://botapi.tamtam.chat/chats?access_token={EXAMPLE_TOKEN}
HTTP / 1.1 403 Forbidden
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 57
Content-Type: application / json; charset = utf-8
Set-Cookie: web_ui_lang = ru; Path = /; Domain = .tamtam.chat; Expires = 2019-03-24T11: 45: 36.500Z
{
"code": "verify.token",
"message": "Invalid access_token"
}
```
## Receiving notifications
TamTam Bot API supports 2 options of receiving notifications on new events for bots:
- Push notifications via WebHook. To receive data via WebHook, you'll have to [add subscription](https://dev.tamtam.chat/#operation/subscribe);
- Notifications upon request via [long polling](#operation/getUpdates) API. All data can be received via long polling **by default** after creating the bot.
Both methods **cannot** be used simultaneously.
Refer to the response schema of [/updates](https://dev.tamtam.chat/#operation/getUpdates) method to check all available types of updates.
### Webhook
There is some notes about how we handle webhook subscription:
- Sometimes webhook notification cannot be delivered in case when bot server or network is down.
In such case we will retry delivery in a short period of time (from 30 to 60 seconds) and will do this until get
`200 OK` status code from your server, but not longer than **8 hours** (*may change over time*) since update happened.
Subscription can be cancelled if bot doesn't response to webhook notification.
We also consider any non `200` response from server as failed delivery.
- To protect your bot from unexpected high load we send **no more than 100** notifications per second by default.
If you want increase this limit, contact us at [@support](https://tt.me/support).
It should be from one of the following subnets:
```
185.16.150.0/30
185.16.150.84/30
185.16.150.152/30
185.16.150.192/30
```
## Message buttons
You can program buttons for users answering a bot.
TamTam supports the following types of buttons:
`callback` — sends a notification with payload to a bot (via WebHook or long polling)
`link` — makes a user to follow a link
`request_contact` — requests the user permission to access contact information (phone number, short link, email)
`request_geo_location` — asks user to provide current geo location
`chat` — creates chat associated with message
To start create buttons [send message](#operation/sendMessage) with `InlineKeyboardAttachment`:
```json
{
"text": "It is message with inline keyboard",
"attachments": [
{
"type": "inline_keyboard",
"payload": {
"buttons": [
[
{
"type": "callback",
"text": "Press me!",
"payload": "button1 pressed"
}
],
[
{
"type": "chat",
"text": "Discuss",
"chat_title": "Message discussion"
}
]
]
}
}
]
}
```
### Chat button
Chat button is a button that starts chat assosiated with the current message. It will be **private** chat with a link, bot will be added as administrator by default.
Chat will be created as soon as the first user taps on button. Bot will receive `message_chat_created` update.
Bot can set title and description of new chat by setting `chat_title` and `chat_description` properties.
Whereas keyboard can contain several `chat` buttons there is `uuid` property to distinct them between each other.
In case you do not pass `uuid` we will generate it. If you edit message, pass `uuid` so we know that this button starts the same chat as before.
Chat button also can contain `start_payload` that will be sent to bot as part of `message_chat_created` update.
## Deep linking
TamTam supports deep linking mechanism for bots. It allows passing additional payload to the bot on startup.
Deep link can contain any data encoded into string up to **128** characters long. Longer strings will be omitted and **not** passed to the bot.
Each bot has start link that looks like:
```
https://tt.me/%BOT_USERNAME%/start/%PAYLOAD%
```
As soon as user clicks on such link we open dialog with bot and send this payload to bot as part of `bot_started` update:
```json
{
"update_type": "bot_started",
"timestamp": 1573226679188,
"chat_id": 1234567890,
"user": {
"user_id": 1234567890,
"name": "Boris",
"username": "borisd84"
},
"payload": "any data meaningful to bot"
}
```
Deep linking mechanism is supported for iOS version 2.7.0 and Android 2.9.0 and higher.
## Constructors
Constructor is a bot that can create a message for user: add buttons, attach some media, insert text.
You can enable constructor mode for your bot via [@PrimeBot](https://tt.me/primebot)
sending [/constructor_mode](https://tt.me/primebot/start/constructor_mode) command.
For bot developers, it looks like request-response interaction where TamTam application
sends `message_construction_request` on behalf of user. Bot [responds](#operation/construct)
to it with `messages` ready to go or `keyboard` in case it requires further action from user.
Bot also can set up UI parts such as `hint` or `placeholder`, allow or not user's input:
![Constructor UI parts](https://dev.tamtam.chat/static/hint-079a332a51a2e9e6d415ec716389661b.png)
As soon as user finishes composing a message, they can post it. Bot will receive `message_constructed_update`
with posted message.
Constructors are supported for iOS version 2.7.0 and Android 2.9.0 and higher.
## Text formatting
Message text can be improved with basic formatting such as: **strong**, *emphasis*, ~strikethough~,
<ins>underline</ins>, `code` or link. You can use either markdown-like or HTML formatting.
To enable text formatting set the `format` property of [NewMessageBody](#tag/new_message_model).
### TamTam flavored Markdown
To enable [Markdown](https://spec.commonmark.org/0.29/) parsing, set the `format` property of [NewMessageBody](#tag/new_message_model) to `markdown`.
We currently support only the following syntax:
`*empasized*` or `_empasized_` for *italic* text
`**strong**` or `__strong__` for __bold__ text
`~~strikethough~~` for ~strikethough~ text
`++underline++` for <ins>underlined</ins> text
``` `code` ``` for inline `monospaced` text (line endings inside this block are treated like spaces)
` ```code``` ` for `monospaced` text block
`^^important^^` for highlighted text (colored in red, by default)
`[Inline URL](https://dev.tamtam.chat/)` for inline URLs
`[User mention](tamtam://user/%user_id%)` for user mentions without username
`# Header` for header
### HTML support
To enable HTML parsing, set the `format` property of [NewMessageBody](#tag/new_message_model) to `html`.
Only the following HTML tags are supported. All others will be stripped:
Emphasized: `<i>` or `<em>`
Strong: `<b>` or `<strong>`
Strikethrough: `<del>` or `<s>`
Underlined: `<ins>` or `<u>`
Link: `<a href="https://dev.tamtam.chat">Docs</a>`
Monospaced text: `<pre>` or `<code>`
Highlighted text: `<mark>`
Header: `<h1>`
Text formatting is supported for iOS since version 3.1 and Android since 2.20.0.
# Versioning
API models and interface may change over time. To make sure your bot will get the right info, we strongly recommend adding API version number to each request. You can add it as `v` parameter to each HTTP-request. For instance, `v=0.1.2`.
To specify the data model version you are getting through WebHook subscription, use the `version` property in the request body of the [subscribe](https://dev.tamtam.chat/#operation/subscribe) request.
# Libraries
We have developed the official [Java client](https://github.com/tamtam-chat/tamtam-bot-api) and [SDK](https://github.com/tamtam-chat/tamtam-bot-sdk).
Also check out unofficial libraries, created by our enthusiasts:
- [Kotlin DSL client](https://github.com/Namazed/TamTamBotApiClientDsl)
- [GO client](https://github.com/neonxp/tamtam)
- [Node.js module](https://github.com/vershininivan/node-tamtam-botapi)
#### Python:
- [Python client](https://github.com/asvbkr/openapi_client)
- [tamtam.py](https://github.com/uwinx/tamtam.py)
- [registriren/botapitamtam](https://github.com/registriren/botapitamtam)
# Changelog
##### Version 0.3.0
- Added methods to [pin](#operation/pinMessage)/[unpin](#operation/unpinMessage) messages in chats/channels
- Added `is_bot` flag to [`User`](#tag/user_model) model
Check out the complete [diff](https://github.com/tamtam-chat/tamtam-bot-api-schema/compare/v0.2.1..v0.3.0) for this release.
##### Version 0.2.1
- [Added](#operation/getChatByLink) method to get chat by its `@link`
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/compare/v0.2.0..HEAD#diff-7e9de78f42fb0d2ae80878b90c87300aR1240) `description` for users in some cases
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/compare/v0.2.0..HEAD#diff-7e9de78f42fb0d2ae80878b90c87300aR2555) `user_locale` to `message_created` update in dialogs
Check out the complete [diff](https://github.com/tamtam-chat/tamtam-bot-api-schema/compare/v0.2.0..v0.2.1) for this release.
##### Version 0.2.0
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/09c95259d6c8c424f82b50eab93872e7db2ca208) new type of button to start new chat
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/ea4581d83d7132663d6cc5c2c61c058a2bd46aac) Constructors API that allows bots to create message on behalf of a user
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/c5ff03175407819aceebd9c25de49eed566a0ce1) support for deep-links
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/ff4cc4f93662d6c25db11fac72d9fcbf1f66cad8) ability to block users in chats
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/b965bfb0d02933e819435312e6ab184a3dfc0250) `chat_id` and `user_id` to `message_removed` update
- Added meta information for video attachments
- Other minor improvements and fixes. Check out complete [diff](https://github.com/tamtam-chat/tamtam-bot-api-schema/compare/v0.1.11...v0.1.10) for this version
##### Version 0.1.10
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/a9ef3a1b8f4e1a75b55a9b80877eddc2c6f07ec4) `disable_link_preview` parameter to POST:/messages method to disable links parsing in text
- [Added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/eb99e8ab97b55fa196d9957fca34d2316a4ca8aa) `sending_file` action
- [Removed](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/7a5ab5f0ea1336b3460d1827a6a7b3b141e19776) several deprecated properties
- `photo` upload type [renamed](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/74505883e6acb306686a6d141414aeaf5131ef49) to `image`. *C* is for consistency
To see changelog for older versions visit our [GitHub](https://github.com/tamtam-chat/tamtam-bot-api-schema/releases).
servers:
- url: 'https://botapi.tamtam.chat'
security:
- access_token: []
tags:
- name: user_model
x-displayName: User
description: |
<SchemaDefinition schemaRef="#/components/schemas/User"/>
- name: chat_model
x-displayName: Chat
description: |
<SchemaDefinition schemaRef="#/components/schemas/Chat"/>
- name: message_model
x-displayName: Message
description: |
<SchemaDefinition schemaRef="#/components/schemas/Message"/>
- name: new_message_model
x-displayName: New message
description: |
<SchemaDefinition schemaRef="#/components/schemas/NewMessageBody"/>
- name: update_model
x-displayName: Update
description: |
<SchemaDefinition schemaRef="#/components/schemas/Update"/>
x-tagGroups:
- name: Methods
tags:
- bots
- chats
- messages
- subscriptions
- upload
- name: Objects
tags:
- user_model
- chat_model
- message_model
- new_message_model
- update_model
paths:
/me:
get:
tags:
- bots
summary: Get current bot info
operationId: getMyInfo
description: 'Returns info about current bot. Current bot can be identified by access token. Method returns bot identifier, name and avatar (if any)'
responses:
'200':
description: Bot info
content:
application/json:
schema:
$ref: '#/components/schemas/BotInfo'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
patch:
tags:
- bots
summary: Edit current bot info
operationId: editMyInfo
description: Edits current bot info. Fill only the fields you want to update. All remaining fields will stay untouched
responses:
'200':
description: Modified bot info
content:
application/json:
schema:
$ref: '#/components/schemas/BotInfo'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BotPatch'
/chats:
get:
tags:
- chats
operationId: getChats
description: 'Returns information about chats that bot participated in: a result list and marker points to the next page'
summary: Get all chats
parameters:
- description: Number of chats requested
name: count
in: query
schema:
type: integer
format: int32
minimum: 1
maximum: 100
default: 50
- description: Points to next data page. `null` for the first page
name: marker
in: query
schema:
$ref: '#/components/schemas/bigint'
responses:
'200':
description: Returns paginated response of chats
content:
application/json:
schema:
$ref: '#/components/schemas/ChatList'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatLink}':
get:
tags:
- chats
x-opGroup: chat
operationId: getChatByLink
description: Returns chat/channel information by its public link or dialog with user by username
summary: Get chat by link
parameters:
- name: chatLink
description: Public chat link or username
required: true
in: path
schema:
type: string
pattern: '@?[a-zA-Z]+[a-zA-Z0-9-_]*'
responses:
'200':
description: Chat information
content:
application/json:
schema:
$ref: '#/components/schemas/Chat'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatId}':
get:
tags:
- chats
x-opGroup: chat
operationId: getChat
description: Returns info about chat.
summary: Get chat
parameters:
- name: chatId
description: Requested chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
responses:
'200':
description: Chat information
content:
application/json:
schema:
$ref: '#/components/schemas/Chat'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
patch:
tags:
- chats
x-opGroup: chat
operationId: editChat
description: 'Edits chat info: title, icon, etc…'
summary: Edit chat info
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ChatPatch'
responses:
'200':
description: 'If success, returns updated chat object'
content:
application/json:
schema:
$ref: '#/components/schemas/Chat'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatId}/actions':
post:
tags:
- chats
operationId: sendAction
description: Send bot action to chat.
summary: Send action
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ActionRequestBody'
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatId}/pin':
get:
tags:
- chats
operationId: getPinnedMessage
description: Get pinned message in chat or channel.
summary: Get pinned message
parameters:
- name: chatId
description: Chat identifier to get its pinned message
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
responses:
'200':
description: Pinned message
content:
application/json:
schema:
$ref: '#/components/schemas/GetPinnedMessageResult'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
put:
tags:
- chats
operationId: pinMessage
description: Pins message in chat or channel.
summary: Pin message
parameters:
- name: chatId
description: Chat identifier where message should be pinned
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PinMessageBody'
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
delete:
tags:
- chats
operationId: unpinMessage
description: Unpins message in chat or channel.
summary: Unpin message
parameters:
- name: chatId
description: Chat identifier to remove pinned message
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatId}/members/me':
get:
tags:
- chats
x-opGroup: myMembership
operationId: getMembership
summary: Get chat membership
description: Returns chat membership info for current bot
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
responses:
'200':
description: Current bot membership info
content:
application/json:
schema:
$ref: '#/components/schemas/ChatMember'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
delete:
tags:
- chats
operationId: leaveChat
x-opGroup: myMembership
summary: Leave chat
description: Removes bot from chat members.
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatId}/members/admins':
get:
tags:
- chats
operationId: getAdmins
summary: Get chat admins
description: Returns all chat administrators. Bot must be **administrator** in requested chat.
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
responses:
'200':
description: Administrators list
content:
application/json:
schema:
$ref: '#/components/schemas/ChatMembersList'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
'/chats/{chatId}/members':
get:
tags:
- chats
operationId: getMembers
summary: Get members
description: Returns users participated in chat.
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
- name: user_ids
description: |-
*Since* version [0.1.4](#section/About/Changelog).
Comma-separated list of users identifiers to get their membership. When this parameter is passed, both `count` and `marker` are ignored
required: false
in: query
schema:
type: array
uniqueItems: true
items:
type: integer
format: int64
nullable: true
style: simple
- name: marker
description: Marker
in: query
schema:
type: integer
format: int64
- name: count
description: Count
in: query
schema:
type: integer
minimum: 1
maximum: 100
default: 20
responses:
'200':
description: Returns members list and pointer to the next data page
content:
application/json:
schema:
$ref: '#/components/schemas/ChatMembersList'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
post:
tags:
- chats
operationId: addMembers
description: Adds members to chat. Additional permissions may require.
summary: Add members
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserIdsList'
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
delete:
tags:
- chats
operationId: removeMember
description: Removes member from chat. Additional permissions may require.
summary: Remove member
parameters:
- name: chatId
description: Chat identifier
required: true
in: path
schema:
type: integer
format: int64
pattern: \-?\d+
- name: user_id
description: User id to remove from chat
required: true
in: query
schema:
type: integer
format: int64
- name: block
description: |-
Set to `true` if user should be blocked in chat.
Applicable only for chats that have public or private link. Ignored otherwise
required: false
in: query
schema:
type: boolean
default: false
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalError'
/subscriptions:
get:
tags:
- subscriptions
operationId: getSubscriptions
description: 'In case your bot gets data via WebHook, the method returns list of all subscriptions'
summary: Get subscriptions
responses:
'200':
description: As expected
content:
application/json:
schema:
$ref: '#/components/schemas/GetSubscriptionsResult'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
post:
tags:
- subscriptions
operationId: subscribe
description: |-
Subscribes bot to receive updates via WebHook. After calling this method, the bot will receive notifications about new events in chat rooms at the specified URL.
Your server **must** be listening on one of the following ports: **80, 8080, 443, 8443, 16384-32383**
summary: Subscribe
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionRequestBody'
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
delete:
tags:
- subscriptions
operationId: unsubscribe
description: 'Unsubscribes bot from receiving updates via WebHook. After calling the method, the bot stops receiving notifications about new events. Notification via the long-poll API becomes available for the bot'
summary: Unsubscribe
parameters:
- name: url
in: query
description: URL to remove from WebHook subscriptions
required: true
schema:
type: string
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
/uploads:
post:
tags:
- upload
operationId: getUploadUrl
description: |-
Returns the URL for the subsequent file upload.
For example, you can upload it via curl:
```curl -i -X POST
-H "Content-Type: multipart/form-data"
-F "data=@movie.mp4" "%UPLOAD_URL%"```
Two types of an upload are supported:
- single request upload (multipart request)
- and resumable upload.
##### Multipart upload
This type of upload is a simpler one but it is less
reliable and agile. If a `Content-Type`: multipart/form-data header is passed in a request our service indicates
upload type as a simple single request upload.
This type of an upload has some restrictions:
- Max. file size - 2 Gb
- Only one file per request can be uploaded
- No possibility to restart stopped / failed upload
##### Resumable upload
If `Content-Type` header value is not equal to `multipart/form-data` our service indicated upload type
as a resumable upload.
With a `Content-Range` header current file chunk range and complete file size
can be passed. If a network error has happened or upload was stopped you can continue to upload a file from
the last successfully uploaded file chunk. You can request the last known byte of uploaded file from server
and continue to upload a file.
##### Get upload status
To GET an upload status you simply need to perform HTTP-GET request to a file upload URL.
Our service will respond with current upload status,
complete file size and last known uploaded byte. This data can be used to complete stopped upload
if something went wrong. If `REQUESTED_RANGE_NOT_SATISFIABLE` or `INTERNAL_SERVER_ERROR` status was returned
it is a good point to try to restart an upload
summary: Get upload URL
parameters:
- description: 'Uploaded file type: photo, audio, video, file'
name: type
required: true
in: query
schema:
$ref: '#/components/schemas/UploadType'
responses:
'200':
description: Returns URL to upload attachment
content:
application/json:
schema:
$ref: '#/components/schemas/UploadEndpoint'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
/messages:
get:
tags:
- messages
operationId: getMessages
description: 'Returns messages in chat: result page and marker referencing to the next page. Messages traversed in reverse direction so the latest message in chat will be first in result array. Therefore if you use `from` and `to` parameters, `to` must be **less than** `from`'
summary: Get messages
parameters:
- description: Chat identifier to get messages in chat
name: chat_id
in: query
schema:
$ref: '#/components/schemas/bigint'
- description: Comma-separated list of message ids to get
name: message_ids
in: query
style: simple