sendGift
Sends a gift to the given user or channel chat
Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns True on success.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
user_id | Integer | Optional | Required if chat_id is not specified. Unique identifier of the target user who will receive the gift. |
chat_id | Integer or String | Optional | Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format @username) that will receive the gift. |
gift_id | String | Yes | Identifier of the gift; limited gifts can't be sent to channel chats |
pay_for_upgrade | Boolean | Optional | Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver |
text | String | Optional | Text that will be shown along with the gift; 0-128 characters |
text_parse_mode | String | Optional | Mode for parsing entities in the text. See formatting options for more details. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", "custom_emoji", and "date_time" are ignored. |
text_entities | Array of MessageEntity | Optional | A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than "bold", "italic", "underline", "strikethrough", "spoiler", "custom_emoji", and "date_time" are ignored. |
Example
PHP — Call sendGift on Botlify Cloud
<?php
// ── Botlify Cloud .env — auto-injected, never hardcode secrets ──
$BOT_TOKEN = getenv('BOT_TOKEN'); // Telegram bot token from @BotFather
$ADMIN_CHAT_ID = getenv('ADMIN_CHAT_ID'); // Your numeric admin Telegram user ID
$BOT_USERNAME = getenv('BOT_USERNAME'); // Bot username without @
$resp = bot('sendGift', [
'gift_id' => 'value',
]);
if ($resp['ok'] ?? false) {
$result = $resp['result']; // handle the response
}Botlify Cloud Runtime
Credentials are auto-injected in
Credentials are auto-injected in
.env — always load them with getenv(): BOT_TOKEN, ADMIN_CHAT_ID, BOT_USERNAME. Main database: database.db (SQLite, WAL mode). Runtime errors: error.log. Quick test: send to $ADMIN_CHAT_ID. Full details: Runtime Reference.