Skip to content

sendMessage ​

Send a text message to a specified chat.

Request ​

POST /:token/sendMessage

Parameters ​

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
textStringYesText content of the message
parse_modeStringNoText parsing mode, supports HTML or Markdown
reply_markupObjectNoCustom keyboard or inline keyboard markup, JSON-serialized object
reply_to_message_idIntegerNoID of the message to reply to. When set, the message will be sent as a quoted reply

Response ​

Returns the sent Message object on success.

json
{
  "ok": true,
  "result": {
    "message_id": 100,
    "from": {
      "id": 123456789,
      "is_bot": true,
      "first_name": "MyBot",
      "username": "my_bot"
    },
    "chat": {
      "id": 987654321,
      "first_name": "User",
      "username": "user123",
      "type": "private"
    },
    "date": 1700000000,
    "text": "Hello, World!"
  }
}

Error Codes ​

CodeDescription
400Bad request parameters, e.g. missing text or chat_id
401Invalid or expired token
403Bot was blocked by the user or does not have permission to send messages to this chat
404Chat not found
500Internal server error

Examples ​

cURL ​

bash
curl -X POST "https://api.example.com/<token>/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "text": "Hello, World!",
    "parse_mode": "HTML"
  }'

Message with Inline Keyboard ​

bash
curl -X POST "https://api.example.com/<token>/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "text": "Please choose an option:",
    "reply_markup": {
      "inline_keyboard": [
        [
          {"text": "Option A", "callback_data": "option_a"},
          {"text": "Option B", "callback_data": "option_b"}
        ]
      ]
    }
  }'

Reply to a Message ​

bash
curl -X POST "https://api.example.com/<token>/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "text": "This is a reply",
    "reply_to_message_id": 99
  }'