deleteStory
Returns: TrueOfficial docs ↗
Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success.
Parameters
business_connection_idStringRequiredUnique identifier of the business connection
story_idIntegerRequiredUnique identifier of the story to delete
Returns
On success, True is returned.
GramIO Usage
ts
// Delete a story by business connection ID and story ID
await bot.api.deleteStory({
business_connection_id: "abc123businessconnectionid",
story_id: 42,
});ts
// Delete a story using IDs stored from a previous postStory response
const businessConnectionId = "abc123businessconnectionid";
const postedStoryId = 7; // story_id returned by postStory
await bot.api.deleteStory({
business_connection_id: businessConnectionId,
story_id: postedStoryId,
});ts
// Delete multiple stories for a business account
const businessConnectionId = "abc123businessconnectionid";
const storyIdsToDelete = [10, 11, 12];
for (const storyId of storyIdsToDelete) {
await bot.api.deleteStory({
business_connection_id: businessConnectionId,
story_id: storyId,
});
}Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: business connection not found | business_connection_id is invalid or the business connection no longer exists |
| 400 | Bad Request: STORY_NOT_FOUND | The story_id doesn't exist for this business account, or was already deleted |
| 403 | Forbidden: not enough rights | Bot lacks the can_manage_stories right for this business connection |
| 403 | Forbidden: business connection revoked | The business account has revoked the bot's access — handle with re-auth flow |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use auto-retry plugin |
TIP
Use GramIO's auto-retry plugin to handle 429 errors automatically.
Tips & Gotchas
- Requires
can_manage_storiesbusiness right. This specific permission must be granted by the business account owner. General business bot access is not sufficient — verify your business bot rights if you get a 403 error. business_connection_idis account-specific, not global. Each connected business account has its own connection ID. Store it when you receive business connection updates and use it consistently.- Only stories posted by the bot can be deleted. You can only delete stories that were originally posted by your bot on behalf of this business account — not stories posted by the business owner directly.
story_idis an integer, not a file_id. Story IDs are simple sequential integers scoped to the business account, distinct from file identifiers.- Handle revoked connections gracefully. Business accounts can disconnect bots at any time. Wrap calls in try/catch and remove the connection from your database on 403 errors.
See Also
- postStory — post a story on behalf of a business account
- editStory — edit an existing story
- repostStory — repost a story to the bot's own stories
- Story — story object reference