editChatInviteLink
Returns: ChatInviteLinkOfficial docs ↗
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
Parameters
chat_idIntegerStringRequiredUnique identifier for the target chat or username of the target channel (in the format
@channelusername)invite_linkStringRequiredThe invite link to edit
nameStringOptionalminLen 0maxLen 32Invite link name; 0-32 characters
expire_dateIntegerOptionalPoint in time (Unix timestamp) when the link will expire
member_limitIntegerOptionalThe maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
creates_join_requestBooleanOptionalTrue, if users joining the chat via the link need to be approved by chat administrators. If True, member\_limit can't be specified
Returns
On success, the ChatInviteLink object is returned.
GramIO Usage
ts
// Rename a link and set a new expiry date
const expiresAt = Math.floor(Date.now() / 1000) + 86400; // 24 hours from now
const updated = await bot.api.editChatInviteLink({
chat_id: "@mychannel",
invite_link: "https://t.me/+abc123",
name: "Summer Campaign",
expire_date: expiresAt,
member_limit: 100,
});
console.log(updated.invite_link); // same URL, updated settingsts
// Switch a link to require admin approval (drop the member_limit)
const updated = await bot.api.editChatInviteLink({
chat_id: -1001234567890,
invite_link: "https://t.me/+abc123",
creates_join_request: true,
});
console.log(updated.creates_join_request); // truets
// Just rename an existing link without touching other settings
const updated = await bot.api.editChatInviteLink({
chat_id: -1001234567890,
invite_link: "https://t.me/+abc123",
name: "Open Enrollment",
});
console.log(updated.name); // "Open Enrollment"Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: chat not found | Invalid or inaccessible chat_id — verify the bot is still a member of the chat |
| 400 | Bad Request: INVITE_HASH_EXPIRED | The invite link is revoked or has already expired — use createChatInviteLink to issue a fresh one |
| 400 | Bad Request: can't combine member limit with join request approval | member_limit and creates_join_request: true are mutually exclusive — pick one |
| 400 | Bad Request: INVITE_LINK_NAME_INVALID | name exceeds 32 characters |
| 400 | Bad Request: EXPIRE_DATE_INVALID | expire_date is in the past or otherwise invalid |
| 400 | Bad Request: MEMBER_LIMIT_INVALID | member_limit is outside the 1–99999 range |
| 403 | Forbidden: not enough rights | Bot lacks the can_invite_users administrator right |
| 403 | Forbidden: bot is not a member of the channel chat | Bot was removed from the chat |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use auto-retry plugin |
TIP
Use GramIO's auto-retry plugin to handle 429 errors automatically.
Tips & Gotchas
- Only bot-created, non-primary links can be edited. The chat's primary invite link (managed by the owner) cannot be modified this way — use
exportChatInviteLinkto reset it. member_limitandcreates_join_requestare mutually exclusive. Passing both in the same call raises a 400 error. When switching a link tocreates_join_request: true, omitmember_limit— any existing limit will be cleared.expire_dateis a Unix timestamp in seconds, not milliseconds. Compute future times withMath.floor(Date.now() / 1000) + seconds.- Omitting optional fields keeps the current value. You can update just
namewithout touchingexpire_dateormember_limit. chat_idaccepts@usernamestrings for public channels and groups. Private chats require the numeric ID.- Editing does not change the link URL. The same link string continues to work with its updated constraints — existing users who saved the link are unaffected.
See Also
createChatInviteLink— Create a new additional invite linkrevokeChatInviteLink— Revoke a bot-created invite linkexportChatInviteLink— Reset and retrieve the primary invite linkcreateChatSubscriptionInviteLink— Create a subscription invite linkeditChatSubscriptionInviteLink— Edit a subscription invite linkapproveChatJoinRequest— Approve a pending join request when usingcreates_join_requestChatInviteLink— The return type of this method