Skip to content

Making Requests

Request URL

Bot API request URL format:

https://api.example.com/bot{token}/{method}
  • {token} — Bot Token
  • {method} — API method name (lowercase)

Example:

POST https://api.example.com/bot123456:ABC-DEF/sendmessage

HTTP Methods

  • Most methods support both GET and POST
  • Methods that send media files only support POST (using multipart/form-data)

Request Formats

JSON

bash
curl -X POST "https://api.example.com/bot{token}/sendmessage" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 123456789,
    "text": "Hello"
  }'

multipart/form-data

Used for sending files:

bash
curl -X POST "https://api.example.com/bot{token}/sendphoto" \
  -F "chat_id=123456789" \
  -F "photo=@/path/to/photo.jpg" \
  -F "caption=My photo"

Response Format

All responses are in JSON format.

Success Response

json
{
  "ok": true,
  "result": { }
}

The result field contains the request result. Its type varies depending on the method.

Error Response

json
{
  "ok": false,
  "error_code": 400,
  "description": "Bad Request: chat not found",
  "trace_id": "abc123"
}

File Upload

Via file_id

If a file has already been uploaded, you can reference it by file_id:

json
{
  "chat_id": 123456789,
  "photo": "AgACAgIAAxkBAAI..."
}

Via multipart/form-data

Upload files directly:

bash
curl -X POST "https://api.example.com/bot{token}/senddocument" \
  -F "chat_id=123456789" \
  -F "document=@/path/to/file.pdf"

File Size Limits

TypeMax Size
Photo10 MB
Document100 MB
Media GroupUp to 10 files

Common Error Codes

CodeDescription
400Bad request parameters
401Invalid or expired Token
403Bot lacks permission for this action
404Method not found
429Too many requests (rate limited)
500Internal server error