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/sendmessageHTTP Methods
- Most methods support both
GETandPOST - Methods that send media files only support
POST(usingmultipart/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
| Type | Max Size |
|---|---|
| Photo | 10 MB |
| Document | 100 MB |
| Media Group | Up to 10 files |
Common Error Codes
| Code | Description |
|---|---|
| 400 | Bad request parameters |
| 401 | Invalid or expired Token |
| 403 | Bot lacks permission for this action |
| 404 | Method not found |
| 429 | Too many requests (rate limited) |
| 500 | Internal server error |
