Skip to content

addStickerToSet

Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success.

Parameters

user_idIntegerRequired
User identifier of sticker set owner
nameStringRequired
Sticker set name
stickerInputStickerRequired
A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn't changed.

Returns

On success, True is returned.

GramIO Usage

typescript
import { Bot, MediaUpload } from "gramio";

const bot = new Bot(process.env.BOT_TOKEN as string);

// Add a static sticker from a local file
await bot.api.addStickerToSet({
  user_id: 123456789,
  name: "my_sticker_set_by_mybot",
  sticker: {
    sticker: await MediaUpload.path("./sticker.webp"),
    format: "static",
    emoji_list: ["🎉"],
  },
});

// Add an animated sticker from a file_id already on Telegram servers
await bot.api.addStickerToSet({
  user_id: 123456789,
  name: "my_animated_set_by_mybot",
  sticker: {
    sticker: "file_id_here",
    format: "animated",
    emoji_list: ["😀", "😂"],
    keywords: ["happy", "laugh"],
  },
});

// Add a video sticker from URL
await bot.api.addStickerToSet({
  user_id: 123456789,
  name: "my_video_set_by_mybot",
  sticker: {
    sticker: await MediaUpload.url("https://example.com/sticker.webm"),
    format: "video",
    emoji_list: ["🔥"],
  },
});

Errors

CodeErrorCause
400Bad Request: STICKERSET_INVALIDSticker set doesn't exist or wasn't created by this bot — verify name ends with _by_<botusername>
400Bad Request: STICKER_EMOJI_INVALIDemoji_list contains an invalid or non-emoji character — must be actual emoji codepoints
400Bad Request: STICKER_PNG_DIMENSIONSStatic sticker image dimensions are wrong — must be exactly 512×512 px
400Bad Request: STICKERS_TOO_MUCHSticker set is at capacity (120 for regular, 200 for emoji sets) — remove old stickers first
400Bad Request: USER_NOT_FOUNDuser_id doesn't correspond to a known Telegram user — must be a real user who has interacted with Telegram
400Bad Request: STICKER_FILE_INVALIDThe uploaded file is corrupt, wrong format, or exceeds size limits
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

  • The sticker set must be owned by the bot. The user_id is the owner of the set (typically the admin who requested it), but the bot must have created the set via createNewStickerSet. You cannot add stickers to sets created by other bots.
  • Format must match the set type. You cannot mix static, animated, and video stickers in the same set. The format in InputSticker must match the set's type, which was fixed at creation time.
  • Duplicate stickers are silently ignored. If the exact same sticker file is already in the set, the method returns True without error — the set simply isn't changed.
  • emoji_list accepts 1–20 emojis. Each emoji serves as a search keyword inside Telegram. Add related emojis to improve discoverability.
  • Static stickers must be 512×512 WebP. Animated stickers must be TGS (Lottie), and video stickers must be WebM (VP9). Using the wrong format yields a file-invalid error.
  • keywords improve search for custom emoji stickers. Supply relevant text keywords (not emoji) to help users find stickers via Telegram's sticker search.
  • Use MediaUpload for local files and URLs. GramIO's MediaUpload guide covers MediaUpload.path(), MediaUpload.url(), and MediaUpload.buffer() — all of which work in the sticker field of InputSticker.

See Also