NextGram/plugins Build a plugin Capabilities

Capabilities: messages, chats, admin, HTTP, media and notifications

Messages, chats, admin, HTTP, media, notifications and their permissions.

The v1 API grows additively. Existing methods keep their signatures; new methods are available in Java and, through the bridge, in TypeScript.

1. Permission matrix#

APIPermission
Messages.getMessage/getMessages/searchMessagesmessages.read
Messages.sendText/sendMedia/sendTyping/saveDraftmessages.send
Messages.editText/forwardMessagesmessages.send + messages.modify
Messages.deleteMessages(FOR_ME)messages.modify
Messages.deleteMessages(FOR_ALL) on own messagemessages.modify
Messages.deleteMessages(FOR_ALL) on another sendermessages.modify + chats.admin
Messages.sendReactionmessages.react
Messages.markAsReadtelegram.actions
Chats.getDialog/getDialogs/permissionschats.read
Chats.getMemberschats.members.read
Chats.join/leavechats.join
Chats.createGroup/createChannelchats.create
ChatAdmin.*chats.admin
Automation.*messages.automation plus each action's permission
Events.*matching read permission
Interceptors.outgoingmessages.send
Interceptors.notificationnotifications.manage
Http.requestnetwork
Media.pickFile/readAssetmedia.read
Media.sendPhoto/sendDocument/sendVoice/sendStickermedia.write + messages.send
Notifications.listnotifications.read
Notifications.cancel/updatenotifications.manage
ResourcesHost.applyui.resources; strings also ui.strings
Screens.replace/addSlotui.screens plus the screen content permissions
InternalHostinternal.access and kind java/hybrid

messages.background remains known for old packages but is inert. It never grants automation. ChatAdmin.pinMessage is the only pin path; Messages does not expose a second pin method.

Every mutating call rejects secret chats and protected surfaces. Pinning, deleting for all and admin actions check the signed-in account's ChatObject rights before the upstream call; the server remains authoritative.

2. Sending and editing#

java
SendTextRequest request = SendTextRequest.builder()
        .account(account)
        .dialogId(dialogId)
        .text("Hello")
        .replyToMessageId(0)
        .silent(false)
        .origin(Origin.PLUGIN_UI)
        .build();
context.messages().sendText(request);

SendTextRequest accepts 1–4,096 UTF-16 units. SendMediaRequest accepts a photo, document, voice or sticker with a caption of 0–1,024 units. Entity offsets must be inside the text and must not overlap. Violations return E_INVALID_ARGUMENT.

Origin.EVENT and Origin.SCHEDULE require messages.automation. Rate limits per plugin and account: sends 20/min and 500/day; edits 30/min; deletes 60/min and 2,000/day; reactions 30/min; forwards 20/min.

Pinning is an admin action:

java
context.chatAdmin().pinMessage(account, dialogId, messageId, true);

3. Deleting#

DeleteRequest.mode is FOR_ME or FOR_ALL. The host never silently changes the mode. Deleting another user's message for everyone requires messages.modify, chats.admin and a current admin right. A denial returns a clear error and changes nothing.

ChatAdmin.deleteMessagesForAll and Messages.deleteMessages(FOR_ALL) share the same rights check, confirmation and audit path.

4. Chats and members#

java
List<ChatMemberSnapshot> members =
        context.chats().getMembers(account, dialogId, 50, 0);
ChatPermissionsSnapshot rights =
        context.chats().permissions(account, dialogId);

Member lists are bounded and paginated. join/leave cover public groups and channels. createGroup and createChannel require chats.create. The host never bypasses a server restriction; a rejected request completes with E_TELEGRAM and the Telegram error text and code.

5. Chat administration#

ChatAdmin covers delete-for-all, ban, unban, kick, mute, unmute, promote, demote, restrict, pin, unpin, title, description, photo, invite links, clear history, delete chat and slow mode. Destructive actions require a one-time per-plugin confirmation when automation is enabled; manual calls may show a host confirmation sheet. The manager can revoke the confirmation.

ChatAdmin actions are audited with action, account, dialog id, target id, message ids and result. Message text is never recorded.

6. HTTP#

Http.request accepts HTTPS only. Request bodies are capped at 1 MB, responses at 5 MB, headers at 50 entries and 4 KB per value. Timeouts are 10 s connect, 30 s read, 60 s total. Redirects default to on with a maximum of 5; every redirect is re-validated and a redirect to a private address is rejected. Loopback, link-local, private, multicast and unspecified addresses are rejected before the connection.

Each plugin has an isolated client with no cookies, no shared cache and no automatic authorization headers. The per-plugin limit is 60 requests/min and 1,000/day. Failures use E_NETWORK_POLICY (policy) or E_RATE_LIMIT.

7. Media#

Media.pickFile opens the host picker; Media.readAsset reads a packaged asset from assets/ with traversal protection. Sending supports photo, document, voice and sticker with caption, reply, silent and schedule options. Calls, payments and media streaming are out of scope.

java
context.media().sendPhoto(SendMediaRequest.builder()
        .account(account)
        .dialogId(dialogId)
        .kind(MediaKind.PHOTO)
        .source(MediaSource.asset("assets/photo.webp"))
        .caption("From a plugin")
        .build());

8. Notifications#

Notifications.list returns bounded snapshots with account, dialog id, title, text, channel id and timestamp. cancel and update require notifications.manage. The notification interceptor can change title, text and channel id or cancel a per-chat notification; secret-chat notifications are never delivered to plugins.

9. Errors#

CodeMeaning
E_PERMISSIONPermission missing, revoked, or internal access not granted
E_INVALID_ARGUMENTValidation failed; no state changed
E_RATE_LIMITPer-plugin rate limit reached
E_TELEGRAMTelegram server rejected the operation; text and code are preserved
E_NETWORK_POLICYURL, address, redirect or size violated the HTTP policy
E_CONFIRMATION_REQUIREDDestructive action needs the one-time confirmation
E_AUTOMATION_DISABLEDGlobal automation switch is off
E_UNSUPPORTEDThe host build lacks the capability