sendInvoice
Sends an invoice for payment.
Returns: On success, returns Message.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | Integer or String | Yes | Chat ID or @username |
message_thread_id | Integer | Optional | Forum topic ID |
direct_messages_topic_id | Integer | Optional | Direct messages topic ID (Bot API 10.0) |
title | String | Yes | Product title (1-32) |
description | String | Yes | Product description (1-255) |
payload | String | Yes | Payload |
provider_token | String | Optional | Payment provider token |
currency | String | Yes | Currency (XTR for Stars) |
prices | Array of LabeledPrice | Yes | JSON LabeledPrice array |
max_tip_amount | Integer | Optional | Maximum tip amount |
suggested_tip_amounts | Array of Integer | Optional | JSON array of suggested tip amounts |
start_parameter | String | Optional | Deep link for payment |
provider_data | String | Optional | JSON data for provider |
photo_url | String | Optional | Product photo URL |
photo_size | Integer | Optional | Photo size |
photo_width | Integer | Optional | Photo width |
photo_height | Integer | Optional | Photo height |
need_name | Boolean | Optional | Request user name |
need_phone_number | Boolean | Optional | Request phone number |
need_email | Boolean | Optional | Request email |
need_shipping_address | Boolean | Optional | Request shipping address |
send_phone_number_to_provider | Boolean | Optional | Send phone to provider |
send_email_to_provider | Boolean | Optional | Send email to provider |
is_flexible | Boolean | Optional | Flexible shipping price |
disable_notification | Boolean | Optional | Send silently |
protect_content | Boolean | Optional | Protect content |
allow_paid_broadcast | Boolean | Optional | Allow paid broadcast |
message_effect_id | String | Optional | Message effect ID |
suggested_post_parameters | SuggestedPostParameters | Optional | JSON SuggestedPostParameters object (for channels) |
reply_parameters | ReplyParameters | Optional | JSON ReplyParameters object |
reply_markup | InlineKeyboardMarkup | Optional | JSON: InlineKeyboardMarkup |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendInvoice" \
-H "Content-Type: application/json" \
-d '{
"chat_id": 123456789,
"title": "Example",
"description": "Example item",
"payload": "order-1",
"currency": "XTR",
"prices": [
{
"label": "Item",
"amount": 100
}
]
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/sendInvoice",
json={
"chat_id": 123456789,
"title": "Example",
"description": "Example item",
"payload": "order-1",
"currency": "XTR",
"prices": [
{
"label": "Item",
"amount": 100
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendInvoice`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"title": "Example",
"description": "Example item",
"payload": "order-1",
"currency": "XTR",
"prices": [
{
"label": "Item",
"amount": 100
}
]
}),
});
console.log(await res.json());
Step-by-step guide: How to Create a Telegram Bot: Step by Step with BotFather and Python
Related methods
createInvoiceLinkCreates a payment link.refundStarPaymentRefunds a Telegram Stars payment.sendGiftSends a gift to a user or chat.getMyStarBalanceReturns the bot's Telegram Stars balance.getStarTransactionsReturns bot's Telegram Stars transactions.editUserStarSubscriptionCancels or renews a Telegram Stars subscription.giftPremiumSubscriptionGifts a Telegram Premium subscription.answerShippingQueryAnswers a shipping query.answerPreCheckoutQueryAnswers a pre-checkout query.getAvailableGiftsReturns available gifts the bot can send.getUserGiftsReturns user's gifts.getChatGiftsReturns chat's gifts.