sendGame
Send a game card to the specified chat. Users can tap the button on the card to open the game.
Request
POST /:token/sendGame
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer/String | Yes | Unique identifier or username of the target chat |
| game_short_name | String | Yes | Short name of the game, serving as the unique identifier of the game, created via /newgame with @BotFather |
| reply_markup | Object | No | Inline keyboard markup (InlineKeyboardMarkup). If omitted, a "Play + game title" button is added automatically; if customized, the first button of the first row must be a callback_game button |
Response
Returns the sent Message object, whose game field is the game object.
json
{
"ok": true,
"result": {
"message_id": 100,
"from": {
"id": 123456789,
"is_bot": true,
"first_name": "MyBot",
"username": "my_bot"
},
"chat": {
"id": 987654321,
"type": "private"
},
"date": 1700000000,
"game": {
"title": "Tower Blocks",
"description": "Stack the blocks and chase the high score!",
"photo": [
{ "file_id": "AgACAgIAAx...", "width": 640, "height": 360 }
]
},
"reply_markup": {
"inline_keyboard": [
[{ "text": "▶️ Play Tower Blocks", "callback_game": {} }]
]
}
}
}Error Codes
| Code | Description |
|---|---|
| 400 | Bad request parameters, e.g. game_short_name does not exist or is not registered |
| 401 | Invalid or expired token |
| 403 | Bot does not have permission to send messages to this chat |
| 404 | Chat does not exist |
| 500 | Internal server error |
Examples
cURL
bash
curl -X POST "https://api.safew.bot/<token>/sendGame" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 987654321,
"game_short_name": "tower_blocks"
}'Custom buttons
bash
curl -X POST "https://api.safew.bot/<token>/sendGame" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 987654321,
"game_short_name": "tower_blocks",
"reply_markup": {
"inline_keyboard": [
[{ "text": "▶️ Play", "callback_game": {} }],
[{ "text": "How to play", "url": "https://example.com/how-to-play" }]
]
}
}'