Sends a message to a chat
API section: Working with messages
messages.sendMessage#545cd15a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates;
| Name | Type | Description |
|---|---|---|
| flags | # | Bit mask: a field written flags.N?T is present only when bit N is set. |
| no_webpage | flags.1?true | Do not generate a link preview. |
| silent | flags.5?true | Send without sound: the recipient gets no notification. |
| background | flags.6?true | Background send: no notification and the chat is not bumped. |
| clear_draft | flags.7?true | Clear the draft in this chat after sending. |
| noforwards | flags.14?true | |
| update_stickersets_order | flags.15?true | |
| invert_media | flags.16?true | Show the attachment below the text rather than above it. |
| allow_paid_floodskip | flags.19?true | |
| peer | InputPeer | The user or chat the request is about. |
| reply_to | flags.0?InputReplyTo | What the message replies to. |
| message | string | Message text. |
| random_id | long | A random number from the client. The server uses it to discard duplicates when a request goes out twice. |
| reply_markup | flags.2?ReplyMarkup | Keyboard shown under the message. |
| entities | flags.3?Vector<MessageEntity> | Text markup — bold, links, mentions and so on, as a list of ranges. |
| schedule_date | flags.10?int | When to send, unix time. If set, the message goes out later. |
| schedule_repeat_period | flags.24?int | |
| send_as | flags.13?InputPeer | Which identity to send as — a channel or another profile. |
| quick_reply_shortcut | flags.17?InputQuickReplyShortcut | |
| effect | flags.18?long | |
| allow_paid_stars | flags.21?long | |
| suggested_post | flags.22?SuggestedPost |
Read out of the handler itself — this is what the server actually returns for this method.
| Code | Type | What it means |
|---|---|---|
| 403 | USER_NOT_PARTICIPANT |
You are not a member of this chat. |
| 403 | YOU_BLOCKED_USER |
You have blocked this user — unblock them first. |
| Code | Type | What it means |
|---|---|---|
| 401 | AUTH_KEY_UNREGISTERED |
The server does not know this session: the key was revoked, expired, or the call was made before authorisation. |
| 401 | API_ID_INVALID |
This api_id was never issued or has been blocked. Keys come from my.ansible.su. |
| 400 | CONNECTION_LAYER_INVALID |
The client did not declare a layer, or declared one the server does not know. |
| 420 | FLOOD_WAIT_X |
Too often. Do not retry for X seconds — the number arrives in the error text. |
| 500 | INTERNAL |
A failure on our side. The request may be retried; if it keeps failing, it is a bug of ours. |
This call counts as expensive: its cost grows with the amount of data, so under peak load it goes through admission control and may answer
FLOOD_WAITwhere cheap calls always pass. Build retries with a backoff.