Skip to content

deleteStickerFromSet

Returns: TrueOfficial docs ↗

Use this method to delete a sticker from a set created by the bot. Returns True on success.

Parameters

stickerStringRequired
File identifier of the sticker

Returns

On success, True is returned.

GramIO Usage

ts
// Delete a sticker from a bot-owned set by file_id
await 
bot
.
api
.
deleteStickerFromSet
({
sticker
: "CAACAgIAAxkBAAIBZWXk8s...",
});
ts
// Get the sticker set, then delete the first sticker
const 
stickerSet
= await
bot
.
api
.
getStickerSet
({
name
: "my_pack_by_mybot" });
if (
stickerSet
.
stickers
.
length
> 0) {
await
bot
.
api
.
deleteStickerFromSet
({
sticker
:
stickerSet
.
stickers
[0].
file_id
,
}); }
ts
// Handle a sticker message and remove it from its set
bot
.
on
("message", async (
ctx
) => {
if (
ctx
.
sticker
&&
ctx
.
sticker
.
setName
) {
await
bot
.
api
.
deleteStickerFromSet
({
sticker
:
ctx
.
sticker
.
fileId
,
}); await
ctx
.
send
("Sticker removed from its set.");
} });

Errors

CodeErrorCause
400Bad Request: STICKER_ID_INVALIDThe sticker file_id is malformed, expired, or belongs to a different bot's context
400Bad Request: STICKERSET_INVALIDThe sticker set the sticker belongs to was not created by this bot
400Bad Request: not enough rightsThe bot does not own the sticker set that contains this sticker
429Too Many Requests: retry after NRate limit hit — check retry_after, use auto-retry plugin

TIP

Use GramIO's auto-retry plugin to handle 429 errors automatically.

Tips & Gotchas

  • Only works on bot-owned sticker sets. You can only delete stickers from sets that were created by your bot. Attempting to delete stickers from any other set returns an error.
  • Use file_id not file_unique_id. The sticker parameter requires the file_id string (context-specific), not file_unique_id (which is stable but not accepted here).
  • Deleting the last sticker doesn't delete the set. An empty sticker set still exists — use deleteStickerSet to remove it entirely.
  • Get sticker file_id via getStickerSet. If you don't have the file_id at hand, use getStickerSet to retrieve the full sticker list and extract file_id from each sticker.
  • Sticker type must be consistent within a set. If the set was created as animated or video stickers, ensure remaining stickers stay consistent — mixing types is not allowed.

See Also