Skip to content

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_idStringRequired
Unique identifier of the business connection
story_idIntegerRequired
Unique 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

CodeErrorCause
400Bad Request: business connection not foundbusiness_connection_id is invalid or the business connection no longer exists
400Bad Request: STORY_NOT_FOUNDThe story_id doesn't exist for this business account, or was already deleted
403Forbidden: not enough rightsBot lacks the can_manage_stories right for this business connection
403Forbidden: business connection revokedThe business account has revoked the bot's access — handle with re-auth flow
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

  • Requires can_manage_stories business 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_id is 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_id is 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