-
Notifications
You must be signed in to change notification settings - Fork 8
/
schema.yaml
2312 lines (2249 loc) · 74.1 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.1.10
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).
#### [PrimeBot](https://tt.me/primebot) commands:
`/start` — start a dialog with a bot
`/create` — create a bot, assign the unique short name to it (from 4 to 64 characters)
`/set_name [name]` — assign a short or full name to the bot (up to 200 characters)
`/set_description [description]` — enter the description for the bot profile (up to 400 characters)
`/set_picture [URL]` — enter the URL of bot's picture
`/delete [username]` — delete the bot
`/list` — show the list of all bots
`/get_token` — obtain a token for a bot
`/revoke` — request a new token
`/help` — help
## 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 dialog 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.
## Message buttons
You can program buttons for users answering a bot.
TamTam supports the following types of buttons:
`callback` — sends a notification 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)
You may also send a message with an [InlineKeyboard]() type attachment to start creating buttons. When the user presses a button, the bot receives the answer with filled callback field. It is recommended to edit that message so the user can receive updated buttons.
# 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 created [Java library](https://github.com/tamtam-chat/tamtam-bot-api) to make using API easier.
# Changelog
##### Version 0.1.9
- Added method to [get chat administrators](#operation/getAdmins)
- For `type: dialog` chats [added](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/ff9e2472941d4dd2de540db0d0ea8b9c3d0ed01a#diff-7e9de78f42fb0d2ae80878b90c87300aR1160) `dialog_with_user`
- Added `url` for [messages](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/137dd9dfa4e583d429f017ba69c20caa9deac105) in public chats/channels
- [**Removed**](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/ff9e2472941d4dd2de540db0d0ea8b9c3d0ed01a) `callback_id` of `InlineKeyboardAttachment`
- [**Removed**](https://github.com/tamtam-chat/tamtam-bot-api-schema/commit/2ebf36b22758ea3487304f5b0d0d811798e78b61) `user_id` of `CallbackAnswer`. It is no longer required. Just use `callback_id` of `Callback`
- Several minor improvements: check [diff](https://github.com/tamtam-chat/tamtam-bot-api-schema/compare/beccbe5f4fbed32182a13e257ca1cfae7f40ea8d...master) for all changes
##### Version 0.1.8
- Added `code`, `width`, `height` to [StickerAttachment](https://github.com/tamtam-chat/tamtam-bot-api-schema/blob/master/schema.yaml#L1580)
- `token` is now only one required property for video/audio/file attachments
- `sender` and `chat_id` of [LinkedMessage](https://github.com/tamtam-chat/tamtam-bot-api-schema/blob/master/schema.yaml#L1401) are now optional
- Added clarifying `message` to [SimpleQueryResult](https://github.com/tamtam-chat/tamtam-bot-api-schema/blob/master/schema.yaml#L1938)
##### Version 0.1.7
- It is now **required** to pass `marker` parameter in [/updates](#operation/getUpdates) requests, except initial
- Added full `User` object to update types: bot_started, bot_added, bot_removed, user_added, user_removed, chat_title_changed
- Added `size` and `filename` to [`FileAttachment`](https://github.com/tamtam-chat/tamtam-bot-api-schema/blob/master/schema.yaml#L1503)
- Added [`token`](https://github.com/tamtam-chat/tamtam-bot-api-schema/blob/master/schema.yaml#L1525) property to video/audio/file attachments allows you to reuse attachments uploaded by another user
##### Version 0.1.6
- Added method to [edit bot info](#operation/editMyInfo)
- Added statistics for messages in channel
- `Message.sender` and `UserWithPhoto.avatar_url/full_avatar_url` removed from required properties
servers:
- url: 'https://botapi.tamtam.chat'
security:
- access_token: []
x-tagGroups:
- name: Methods
tags:
- bots
- chats
- messages
- subscriptions
- upload
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/{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}/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 **adminstrator** 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
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
schema:
uniqueItems: true
items:
type: string
nullable: true
- name: from
description: Start time for requested messages
in: query
schema:
$ref: '#/components/schemas/bigint'
- name: to
description: End time for requested messages
in: query
schema:
$ref: '#/components/schemas/bigint'
- name: count
description: Maximum amount of messages in response
in: query
schema:
type: integer
format: int32
default: 50
minimum: 1
maximum: 100
responses:
'200':
description: Returns list of messages
content:
application/json:
schema:
$ref: '#/components/schemas/MessageList'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
description: This exception happens when user suspended bot or it doesn't have access to chat
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
$ref: '#/components/responses/InternalError'
post:
tags:
- messages
operationId: sendMessage
description: |-
Sends a message to a chat.
As a result for this method new message identifier returns.
### Attaching media
Attaching media to messages is a three-step process.
At first step, you should [obtain a URL to upload](#operation/getUploadUrl) your media files.
At the second, you should upload binary of appropriate format to URL you obtained at the previous step. See [upload](https://dev.tamtam.chat/#operation/getUploadUrl) section for details.
Finally, if the upload process was successful, you will receive JSON-object in a response body. Use this object to create attachment. Construct an object with two properties:
- `type` with the value set to appropriate media type
- and `payload` filled with the JSON you've got.
For example, you can attach a video to message this way:
1. Get URL to upload. Execute following:
```shell
curl -X POST 'https://botapi.tamtam.chat/uploads?access_token=%access_token%&type=video'
```
As the result it will return URL for the next step.
```json
{
"url": "http://vu.mycdn.me/upload.do…"
}
```
2. Use this url to upload your binary:
```shell
curl -i -X POST
-H "Content-Type: multipart/form-data"
-F "data=@movie.mp4" "http://vu.mycdn.me/upload.do…"
```
As the result it will return JSON you can attach to message:
```json
{
"token": "_3Rarhcf1PtlMXy8jpgie8Ai_KARnVFYNQTtmIRWNh4"
}
```
3. Send message with attach:
```json
{
"text": "Message with video",
"attachments": [
{
"type": "video",
"payload": {
"token": "_3Rarhcf1PtlMXy8jpgie8Ai_KARnVFYNQTtmIRWNh4"
}
}
]
}
```
**Important notice**:
It may take time for the server to process your file (audio/video or any binary).
While a file is not processed you can't attach it. It means the last step will fail with `400` error.
Try to send a message again until you'll get a successful result.
summary: Send message
parameters:
- name: user_id
description: Fill this parameter if you want to send message to user
in: query
required: false
schema:
type: integer
format: int64
- name: chat_id
description: Fill this if you send message to chat
schema:
type: integer
format: int64
in: query
required: false
- name: disable_link_preview
description: "If `true`, server will generate media preview for links in text"
in: query
required: false
schema:
type: boolean
default: false
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NewMessageBody'
responses:
'200':
description: Returns info about created message
content:
application/json:
schema:
$ref: '#/components/schemas/SendMessageResult'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
put:
tags:
- messages
operationId: editMessage
description: 'Updated message should be sent as `NewMessageBody` in a request body. In case `attachments` field is `null`, the current message attachments won’t be changed. In case of sending an empty list in this field, all attachments will be deleted.'
summary: Edit message
parameters:
- name: message_id
description: Editing message identifier
required: true
in: query
schema:
type: string
minLength: 1
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NewMessageBody'
responses:
'200':
description: Returns info about created message
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalError'
delete:
tags:
- messages
operationId: deleteMessage
summary: Delete message
description: Deletes message in a dialog or in a chat if bot has permission to delete messages.
parameters:
- name: message_id
description: Deleting message identifier
required: true
in: query
schema:
type: string
minLength: 1
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'500':
$ref: '#/components/responses/InternalError'
/answers:
post:
tags:
- messages
operationId: answerOnCallback
description: This method should be called to send an answer after a user has clicked the button. The answer may be an updated message or/and a one-time user notification.
summary: Answer on callback
parameters:
- name: callback_id
description: Identifies a button clicked by user. Bot receives this identifier after user pressed button as part of `MessageCallbackUpdate`
required: true
in: query
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CallbackAnswer'
responses:
'200':
$ref: '#/components/responses/SuccessResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'405':
$ref: '#/components/responses/NotAllowed'
'500':
$ref: '#/components/responses/InternalError'
/updates:
get:
operationId: getUpdates
tags:
- subscriptions
description: |-
You can use this method for getting updates in case your bot is not subscribed to WebHook. The method is based on long polling.
Every update has its own sequence number. `marker` property in response points to the next upcoming update.
All previous updates are considered as *committed* after passing `marker` parameter.
If `marker` parameter is **not passed**, your bot will get all updates happened after the last commitment.
summary: Get updates
parameters:
- name: limit
description: Maximum number of updates to be retrieved
in: query
schema:
type: integer
minimum: 1
maximum: 1000
default: 100
- name: timeout
description: Timeout in seconds for long polling
in: query
schema:
type: integer
minimum: 0
maximum: 90
default: 30
- name: marker
description: Pass `null` to get updates you didn't get yet
in: query
schema:
type: integer
format: int64
nullable: true
- name: types
description: Comma separated list of update types your bot want to receive
in: query
example: 'types=message_created,message_callback'
schema:
type: array
uniqueItems: true
items:
type: string
nullable: true
style: simple
responses:
'200':
description: List of updates
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateList'
'401':
$ref: '#/components/responses/Unauthorized'
'405':
$ref: '#/components/responses/NotAllowed'
'500':
$ref: '#/components/responses/InternalError'
components:
securitySchemes:
access_token:
type: apiKey
name: access_token
description: |-
A token is given to you by [PrimeBot](https://tt.me/primebot) after you have created a bot.
In all subsequent requests to the Bot API, you **must** pass the received token as an `access_token` parameter to the HTTP request.
If [Terms and Conditions of TamTam usage](https://team.tamtam.chat/en/terms/) have been violated, the TamTam administration may withdraw tokens by aborting user sessions.
If your token has been compromised, you can request a new one by sending a `/revoke` command to **[PrimeBot](https://tt.me/primebot)**.
in: query
responses:
SuccessResponse:
description: Success or not result
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleQueryResult'
InternalError:
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
Unauthorized:
description: Authorization Error. No `access_token` provided or token is invalid