telegram api method · layer 229 · #0330e77f

messages.sendMedia

usable by users and bots

Send a media

definition

messages.sendMedia#330e77f flags:# 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 media:InputMedia 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;

parameters

nametypedescription
flags#Flags, see TL conditional fields
silentflags.5?trueSend message silently (no notification should be triggered)
backgroundflags.6?trueSend message in background
clear_draftflags.7?trueClear the draft
noforwardsflags.14?trueOnly for bots, disallows forwarding and saving of the messages, even if the destination chat doesn't have content protection enabled
update_stickersets_orderflags.15?trueWhether to move used stickersets to top, see here for more info on this flag »
invert_mediaflags.16?trueIf set, any eventual webpage preview will be shown on top of the message instead of at the bottom.
allow_paid_floodskipflags.19?trueBots only: if set, allows sending up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance.
peerInputPeerDestination
reply_toflags.0?InputReplyToIf set, indicates that the message should be sent in reply to the specified message or story.
mediaInputMediaAttached media
messagestringCaption
random_idlongRandom ID to avoid resending the same message
reply_markupflags.2?ReplyMarkupReply markup for bot keyboards
entitiesflags.3?Vector<MessageEntity>Message entities for styled text
schedule_dateflags.10?intScheduled message date for scheduled messages
schedule_repeat_periodflags.24?int
send_asflags.13?InputPeerSend this message as the specified peer
quick_reply_shortcutflags.17?InputQuickReplyShortcutAdd the message to the specified quick reply shortcut », instead.
effectflags.18?longSpecifies a message effect » to use for the message.
allow_paid_starsflags.21?longFor paid messages », specifies the amount of Telegram Stars the user has agreed to pay in order to send the message.
suggested_postflags.22?SuggestedPostUsed to suggest a post to a channel, see here » for more info on the full flow.

returns

Updates

errors (122)

codeerrordescription
400BOT_GAMES_DISABLEDGames can't be sent to channels.
400BOT_PAYMENTS_DISABLEDPlease enable bot payments in botfather before calling this method.
400BROADCAST_PUBLIC_VOTERS_FORBIDDENYou can't forward polls with public voters.
400BUSINESS_CONNECTION_INVALIDThe connection_id passed to the wrapping invokeWithBusinessConnection call is invalid.
400BUSINESS_CONNECTION_NOT_ALLOWEDThis method was invoked over a business connection using invokeWithBusinessConnection, but either (1) we're a user, and users cannot invoke methods over a business connection; (2) we're a bot, but business mode was disabled in @botfather or (3); we're a bot, but this method cannot be invoked over a business connection.
400BUSINESS_PEER_INVALIDMessages can't be set to the specified peer through the current business connection.
400BUSINESS_PEER_USAGE_MISSINGYou cannot send a message to a user through a business connection if the user hasn't recently contacted us.
400BUTTON_COPY_TEXT_INVALIDThe specified keyboardButtonCopy.copy_text is invalid.
400BUTTON_DATA_INVALIDThe data of one or more of the buttons you provided is invalid.
400BUTTON_POS_INVALIDThe position of one of the keyboard buttons is invalid (i.e. a Game or Pay button not in the first position, and so on...).
400BUTTON_TYPE_INVALIDThe type of one or more of the buttons you provided is invalid.
400BUTTON_URL_INVALIDButton URL invalid.
400BUTTON_USER_PRIVACY_RESTRICTEDThe privacy setting of the user specified in a inputKeyboardButtonUserProfile button do not allow creating such a button.
400CHANNEL_INVALIDThe provided channel is invalid.
400CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
400CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
400CHAT_FORWARDS_RESTRICTEDYou can't forward messages from a protected chat.
400CHAT_RESTRICTEDYou can't send messages in this chat, you were restricted.
400CURRENCY_TOTAL_AMOUNT_INVALIDThe total amount of all prices is invalid.
400DOCUMENT_INVALIDThe specified document is invalid.
400EFFECT_CHAT_INVALIDMessage effects can only be used in private 1-on-1 chats, but the caller tried to send a message with an effect to a group or channel.
400EFFECT_ID_INVALIDThe specified effect ID is invalid.
400EMOTICON_INVALIDThe specified emoji is invalid.
400ENTITY_BOUNDS_INVALIDA specified entity offset or length is invalid, see here » for info on how to properly compute the entity offset/length.
400EXTENDED_MEDIA_AMOUNT_INVALIDThe specified stars_amount of the passed inputMediaPaidMedia is invalid.
400EXTENDED_MEDIA_EMPTYThe specified extended media is empty.
400EXTENDED_MEDIA_INVALIDThe specified paid media is invalid.
400EXTENDED_MEDIA_PEER_INVALIDPaid media is not allowed for the target peer.
400EXTERNAL_URL_INVALIDExternal URL invalid.
400FILE_PART_LENGTH_INVALIDThe length of a file part is invalid.
400FILE_PARTS_INVALIDThe number of file parts is invalid.
400FILE_REFERENCE_EMPTYAn empty file reference was specified.
400FILE_REFERENCE_EXPIREDFile reference expired, it must be refetched as described in the documentation.
400GAME_BOT_INVALIDBots can't send another bot's game.
400IMAGE_PROCESS_FAILEDFailure while processing image.
400INPUT_FILE_INVALIDThe specified InputFile is invalid.
400INPUT_USER_DEACTIVATEDThe specified user was deleted.
400INVOICE_PAYLOAD_INVALIDThe specified invoice payload is invalid.
400MD5_CHECKSUM_INVALIDThe MD5 checksums do not match.
400MEDIA_CAPTION_TOO_LONGThe caption is too long.
400MEDIA_EMPTYThe provided media object is invalid.
400MEDIA_FILE_INVALIDThe specified media file is invalid.
400MEDIA_INVALIDMedia invalid.
400MESSAGE_EMPTYThe provided message is empty.
400MESSAGE_TOO_LONGThe provided message is too long.
400MSG_ID_INVALIDInvalid message ID provided.
400PAYMENT_PROVIDER_INVALIDThe specified payment provider is invalid.
400PEER_ID_INVALIDThe provided peer id is invalid.
400PHOTO_EXT_INVALIDThe extension of the photo is invalid.
400PHOTO_INVALID_DIMENSIONSThe photo dimensions are invalid.
400PHOTO_SAVE_FILE_INVALIDInternal issues, try again later.
400POLL_ANSWER_INVALIDOne of the poll answers is not acceptable.
400POLL_ANSWERS_INVALIDInvalid poll answers were provided.
400POLL_OPTION_DUPLICATEDuplicate poll options provided.
400POLL_OPTION_INVALIDInvalid poll option provided.
400POLL_QUESTION_INVALIDOne of the poll questions is not acceptable.
400QUICK_REPLIES_BOT_NOT_ALLOWEDQuick replies cannot be used by bots.
400QUICK_REPLIES_TOO_MUCHA maximum of appConfig.`quick_replies_limit` shortcuts may be created, the limit was reached.
400QUIZ_CORRECT_ANSWER_INVALIDAn invalid value was provided to the correct_answers field.
400QUIZ_CORRECT_ANSWERS_EMPTYNo correct quiz answer was specified.
400QUIZ_CORRECT_ANSWERS_TOO_MUCHYou specified too many correct answers in a quiz, quizzes can only have one right answer!
400QUIZ_MULTIPLE_INVALIDQuizzes can't have the multiple_choice flag set!
400REPLY_MARKUP_BUY_EMPTYReply markup for buy button empty.
400REPLY_MARKUP_GAME_EMPTYA game message is being edited, but the newly provided keyboard doesn't have a keyboardButtonGame button.
400REPLY_MARKUP_INVALIDThe provided reply markup is invalid.
400REPLY_MARKUP_TOO_LONGThe specified reply_markup is too long.
400REPLY_MESSAGE_ID_INVALIDThe specified reply-to message ID is invalid.
400REPLY_MESSAGES_TOO_MUCHEach shortcut can contain a maximum of appConfig.`quick_reply_messages_limit` messages, the limit was reached.
400REPLY_TO_MONOFORUM_PEER_INVALIDThe specified inputReplyToMonoForum.monoforum_peer_id is invalid.
400SCHEDULE_BOT_NOT_ALLOWEDBots cannot schedule messages.
400SCHEDULE_DATE_TOO_LATEYou can't schedule a message this far in the future.
400SCHEDULE_TOO_MUCHThere are too many scheduled messages.
400SEND_AS_PEER_INVALIDYou can't send messages as the specified peer.
400STARS_INVOICE_INVALIDThe specified Telegram Star invoice is invalid.
400STORY_ID_INVALIDThe specified story ID is invalid.
400SUBSCRIPTION_EXPORT_MISSINGYou cannot send a bot subscription invoice directly, you may only create invoice links using payments.exportInvoice.
400SUGGESTED_POST_PEER_INVALIDYou cannot send suggested posts to non-monoforum peers.
400TERMS_URL_INVALIDThe specified invoice.terms_url is invalid.
400TODO_ITEM_DUPLICATEDuplicate checklist items detected.
400TODO_ITEMS_EMPTYA checklist was specified, but no checklist items were passed.
400TODO_ITEMS_TOO_MUCHYou specified too many todo list items.
400TOPIC_CLOSEDThis topic was closed, you can't send messages to it anymore.
400TOPIC_DELETEDThe specified topic was deleted.
400TTL_MEDIA_INVALIDInvalid media Time To Live was provided.
400USER_BANNED_IN_CHANNELYou're banned from sending messages in supergroups/channels.
400USER_BOT_TO_BOT_DISABLEDBot-to-bot messaging is disabled because one of the two bots hasn't enabled the Bot to Bot setting in @BotFather.
400USER_IS_BLOCKEDYou were blocked by this user.
400USER_IS_BOTBots can't send messages to other bots.
400VIDEO_CONTENT_TYPE_INVALIDThe video's content type is invalid.
400VOICE_MESSAGES_FORBIDDENThis user's privacy settings forbid you from sending voice messages.
400WEBDOCUMENT_MIME_INVALIDInvalid webdocument mime type provided.
400WEBPAGE_CURL_FAILEDFailure while fetching the webpage with cURL.
400WEBPAGE_MEDIA_EMPTYWebpage media empty.
400WEBPAGE_NOT_FOUNDA preview for the specified webpage url could not be generated.
400WEBPAGE_URL_INVALIDThe specified webpage url is invalid.
400YOU_BLOCKED_USERYou blocked this user.
401AUTH_KEY_UNREGISTEREDThe specified authorization key is not registered in the system (for example, a PFS temporary key has expired).
403ALLOW_PAYMENT_REQUIRED_%dThis peer charges %d Telegram Stars per message, but the allow_paid_stars was not set or its value is smaller than %d.
403CHAT_ADMIN_REQUIREDYou must be an admin in this chat to do this.
403CHAT_GUEST_SEND_FORBIDDENYou join the discussion group before commenting, see here » for more info.
403CHAT_SEND_AUDIOS_FORBIDDENYou can't send audio messages in this chat.
403CHAT_SEND_DOCS_FORBIDDENYou can't send documents in this chat.
403CHAT_SEND_GIFS_FORBIDDENYou can't send gifs in this chat.
403CHAT_SEND_MEDIA_FORBIDDENYou can't send media in this chat.
403CHAT_SEND_PHOTOS_FORBIDDENYou can't send photos in this chat.
403CHAT_SEND_PLAIN_FORBIDDENYou can't send non-media (text) messages in this chat.
403CHAT_SEND_POLL_FORBIDDENYou can't send polls in this chat.
403CHAT_SEND_ROUNDVIDEOS_FORBIDDENYou can't send round videos to this chat.
403CHAT_SEND_STICKERS_FORBIDDENYou can't send stickers in this chat.
403CHAT_SEND_VIDEOS_FORBIDDENYou can't send videos in this chat.
403CHAT_SEND_VOICES_FORBIDDENYou can't send voice recordings in this chat.
403CHAT_WRITE_FORBIDDENYou can't write in this chat.
403PREMIUM_ACCOUNT_REQUIREDA premium account is required to execute this action.
403PRIVACY_PREMIUM_REQUIREDYou need a Telegram Premium subscription to send a message to this user.
403USER_IS_BLOCKEDYou were blocked by this user.
406ALLOW_PAYMENT_REQUIREDThis peer only accepts paid messages »: this error is only emitted for older layers without paid messages support, so the client must be updated in order to use paid messages. .
406CHANNEL_PRIVATEYou haven't joined this channel/supergroup.
406PEER_ID_INVALIDThe provided peer id is invalid.
406TOPIC_CLOSEDThis topic was closed, you can't send messages to it anymore.
406TOPIC_DELETEDThe specified topic was deleted.
420SLOWMODE_WAIT_%dSlowmode is enabled in this chat: wait %d seconds before sending another message to this chat.
500RANDOM_ID_DUPLICATEYou provided a random ID that was already used.

history

present in layers 2–229 · constructor id changed 11×

idlayers
#a3c85d762–23
#c8f1679146–75
#b8d1262b76–104
#3491eba9105–134
#e25ff8e0135–147
#7547c966148–159
#72ccc23d160–175
#7bd66041176–179
#7852834e180–199
#a550cd78200–205
#ac55d9c1206–216
#0330e77f217–229