Getting STICKER_DOCUMENT_INVALID error when responding to inline queries in Telegram bot

I’m working on a Telegram bot and running into an issue when I try to respond to inline queries with sticker content. Every time I attempt this, I get a 400 error with the message Bad Request: STICKER_DOCUMENT_INVALID.

Here’s the code I’m using to handle the inline query response:

const stickerResult = {
  type: 'sticker',
  id: '1',
  sticker_file_id: 'document_id_from_sticker_upload'
};

bot.telegram.answerInlineQuery(inlineQuery.id, [stickerResult]);

The error details show:

{
  code: 400,
  response: {
    ok: false,
    error_code: 400,
    description: 'Bad Request: STICKER_DOCUMENT_INVALID'
  },
  description: 'Bad Request: STICKER_DOCUMENT_INVALID',
  parameters: {},
  on: {
    method: 'answerInlineQuery',
    payload: { inline_query_id: '4128765432109876543', results: [Array] }
  }
}

I’ve checked the Telegram API docs and everything looks correct in my implementation. The sticker file was uploaded successfully using the uploadStickerFile method with an image URL. Has anyone encountered this problem before? What could be causing the sticker document to be considered invalid?

Had this exact problem a few months ago - it’s a timing issue. The sticker file_id expires if you don’t add it to an actual sticker set fast enough. When you use uploadStickerFile, that file’s only stored temporarily and needs to be used right away. Upload the sticker file and immediately use it in your inline query response - don’t wait. If you’re saving the file_id for later, that’s why it’s going invalid. My workaround: either use existing sticker file_ids from messages users sent your bot, or create a proper sticker set and use those file_ids instead.

yep, that could be it! the sticker_file_id needs to be valid and not expired. try testing with a sticker you know works first, then check your upload process again. hope that helps!

This happens when the sticker file ID you’re using doesn’t actually exist in Telegram’s system. When you uploaded the sticker with uploadStickerFile, did you check that you’re using the exact file_id it returned in your inline query response? Also make sure your file meets Telegram’s requirements: WebP format, exactly 512x512 pixels, under 500KB. I ran into the same issue because I was accidentally using a regular document file_id instead of the sticker file_id. Log the file_id from your upload response and double-check that’s what you’re passing to the inline query.