Skip to content

stopMessageLiveLocation

Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters

business_connection_idStringOptional
Unique identifier of the business connection on behalf of which the message to be edited was sent
chat_idIntegerStringOptional
Required if inline\message\id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
message_idIntegerOptional
Required if inline\message\id is not specified. Identifier of the message with live location to stop
inline_message_idStringOptional
Required if chat\id and message\id are not specified. Identifier of the inline message
A JSON-serialized object for a new inline keyboard.

Returns

On success, Message | True is returned.

GramIO Usage

ts
// Stop a live location in a regular chat message
await 
bot
.
api
.
stopMessageLiveLocation
({
chat_id
: 123456789,
message_id
: 42,
});
ts
// Stop and replace the keyboard with a "Location ended" button
await 
bot
.
api
.
stopMessageLiveLocation
({
chat_id
: 123456789,
message_id
: 42,
reply_markup
: new
InlineKeyboard
().
text
("Location ended", "location_ended"),
});
ts
// Stop a live location sent via inline query (no chat_id needed)
await 
bot
.
api
.
stopMessageLiveLocation
({
inline_message_id
: "AAABB-xyz...",
});
ts
// Typical pattern: track the message_id when sending, stop it later
const 
locationMsg
= await
bot
.
api
.
sendLocation
({
chat_id
: 123456789,
latitude
: 48.8566,
longitude
: 2.3522,
live_period
: 300, // 5 minutes
}); // ... time passes or user stops sharing ... await
bot
.
api
.
stopMessageLiveLocation
({
chat_id
:
locationMsg
.
chat
.
id
,
message_id
:
locationMsg
.
message_id
,
});

Errors

CodeErrorCause
400Bad Request: chat not foundInvalid or inaccessible chat_id
400Bad Request: message not foundThe message_id doesn't exist in the chat
400Bad Request: message can't be editedThe message is not a live location, or the live period has already expired — the location stopped automatically
400Bad Request: message is not modifiedThe live location is already stopped and reply_markup is identical to the current one
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

  • chat_id + message_id OR inline_message_id — not both. For regular messages use chat_id + message_id; for messages sent via inline query use inline_message_id only.
  • Returns Message for regular messages, true for inline. The return value differs based on which identifier pair you use. Narrowing the type in TypeScript requires checking typeof result === "boolean".
  • You can update reply_markup on stop. This is useful for replacing location-specific buttons (like "Stop sharing") with a static button (like "Location ended") in one atomic call.
  • Calling on an already-stopped location returns an error. If the live_period has expired or the location was already stopped, Telegram returns message can't be edited. Catch this error gracefully.
  • Store the message ID when sending. You need the original message_id to stop the live location later — save it in your session or database when the location message is first sent.

See Also