exportChatInviteLink
Exports the main chat invite link.
Returns: On success, returns String.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | Integer or String | Yes | Chat ID |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/exportChatInviteLink" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/exportChatInviteLink",
json={
"chat_id": 123456789
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/exportChatInviteLink`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789
}),
});
console.log(await res.json());
Step-by-step guide: How to Create a Telegram Bot: Step by Step with BotFather and Python
Related methods
getChatGets chat information.getChatMemberGets chat member information.getChatMemberCountReturns the number of chat members.getChatAdministratorsReturns a list of chat administrators.setChatTitleSets chat title.setChatDescriptionSets chat description.setChatPhotoSets chat photo.deleteChatPhotoDeletes chat photo.setChatPermissionsSets chat permissions.leaveChatLeaves a chat.createChatInviteLinkCreates an invite link.editChatInviteLinkEdits an invite link.