createInvoiceLink
Creates a payment link.
Returns: On success, returns String.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
business_connection_id | String | Optional | Business connection ID |
title | String | Yes | Product title |
description | String | Yes | Product description |
payload | String | Yes | Payload |
provider_token | String | Optional | Payment provider token |
currency | String | Yes | Currency |
prices | Array of LabeledPrice | Yes | JSON LabeledPrice array |
subscription_period | Integer | Optional | Subscription period in seconds |
max_tip_amount | Integer | Optional | Maximum tip amount |
suggested_tip_amounts | Array of Integer | Optional | JSON array of suggested tip amounts |
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 name |
need_phone_number | Boolean | Optional | Request phone |
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 price |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/createInvoiceLink" \
-H "Content-Type: application/json" \
-d '{
"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}/createInvoiceLink",
json={
"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}/createInvoiceLink`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"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
sendInvoiceSends an invoice for payment.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.