repostStory
Returns: StoryOfficial docs ↗
Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success.
Parameters
business_connection_idStringRequiredUnique identifier of the business connection
from_chat_idIntegerRequiredUnique identifier of the chat which posted the story that should be reposted
from_story_idIntegerRequiredUnique identifier of the story that should be reposted
active_periodIntegerRequiredValues:
216004320086400172800Period after which the story is moved to the archive, in seconds; must be one of
6 3600, 12 3600, 86400, or 2 * 86400post_to_chat_pageBooleanOptionalPass True to keep the story accessible after it expires
protect_contentBooleanOptionalPass True if the content of the story must be protected from forwarding and screenshotting
Returns
On success, the Story object is returned.
GramIO Usage
Repost a story from one managed business account to another (24-hour duration):
ts
const story = await bot.api.repostStory({
business_connection_id: "connection_target_account",
from_chat_id: 987654321,
from_story_id: 42,
active_period: 86400, // 24 hours
});
console.log("Reposted story ID:", story.id);Repost with content protection and permanent visibility:
ts
const story = await bot.api.repostStory({
business_connection_id: "connection_target_account",
from_chat_id: 987654321,
from_story_id: 42,
active_period: 43200, // 12 hours
post_to_chat_page: true, // Keep visible after expiry
protect_content: true, // Prevent forwarding and screenshots
});Handle a business message and repost its referenced story:
ts
bot.on("business_message", async (ctx) => {
// ctx.payload contains the raw message with business_connection_id
const businessConnectionId = ctx.payload.business_connection_id;
if (!businessConnectionId) return;
// If the message references a story, repost it
const story = ctx.payload.story;
if (!story) return;
await bot.api.repostStory({
business_connection_id: businessConnectionId,
from_chat_id: story.chat.id,
from_story_id: story.id,
active_period: 86400,
});
});Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: business connection not found | business_connection_id is invalid or the business account is no longer connected |
| 400 | Bad Request: story not found | from_story_id or from_chat_id is invalid, or the story was deleted |
| 400 | Bad Request: not enough rights | The bot lacks can_manage_stories for either the source or target business account |
| 400 | Bad Request: STORY_NOT_POSTED_BY_BOT | The source story was not originally posted or reposted by this bot — only bot-managed stories can be reposted |
| 400 | Bad Request: active_period_invalid | active_period is not one of the four allowed values (21600, 43200, 86400, 172800) |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use auto-retry plugin |
Tips & Gotchas
- Both business accounts must be managed by the same bot. You cannot repost from an account you don't manage — use
from_chat_idof an account linked to your bot. - The source story must have been posted by your bot. Stories created by the business account owner manually (not via the bot) cannot be reposted via this method.
active_periodaccepts only four values. Pass exactly21600(6h),43200(12h),86400(24h), or172800(48h). Any other value returns an error.post_to_chat_page: truekeeps the story permanently. Without it, the story moves to the archive afteractive_periodexpires. Use this for evergreen content.protect_contentprevents screenshots and forwards. Useful for promotional content you don't want redistributed outside the business account's audience.business_connection_ididentifies the target account. Use the connection ID of the business account receiving the repost, not the source account.
See Also
postStory— Post a new story (not a repost) on behalf of a business accounteditStory— Edit a story that was already posteddeleteStory— Delete a story from a business accountStory— The Story object returned on success