Skip to content

editMessageLiveLocation

Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited 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 to edit
inline_message_idStringOptional
Required if chat\id and message\id are not specified. Identifier of the inline message
latitudeFloatRequired
Latitude of new location
longitudeFloatRequired
Longitude of new location
live_periodIntegerOptional
New period in seconds during which the location can be updated, starting from the message send date. If 0x7FFFFFFF is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current live\period by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then live\period remains unchanged
horizontal_accuracyFloatOptional
The radius of uncertainty for the location, measured in meters; 0-1500
headingIntegerOptional
Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
proximity_alert_radiusIntegerOptional
The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
A JSON-serialized object for a new inline keyboard.

Returns

On success, Message | True is returned.

GramIO Usage

ts
// Update live location coordinates via direct API call
await 
bot
.
api
.
editMessageLiveLocation
({
chat_id
: 123456789,
message_id
: 42,
latitude
: 51.509865,
longitude
: -0.118092,
});
ts
// Update with full precision metadata — heading and accuracy
await 
bot
.
api
.
editMessageLiveLocation
({
chat_id
: 123456789,
message_id
: 42,
latitude
: 40.712776,
longitude
: -74.005974,
heading
: 90, // Moving east
horizontal_accuracy
: 25, // ±25 meters
proximity_alert_radius
: 500, // Alert when within 500m
});
ts
// Stop live location sharing early
await 
bot
.
api
.
stopMessageLiveLocation
({
chat_id
: 123456789,
message_id
: 42,
});
ts
// Use ctx shorthand — context fills in chat_id and message_id automatically
bot
.
on
("callback_query", async (
ctx
) => {
await
ctx
.
editLiveLocation
({
latitude
: 48.858844,
longitude
: 2.294351,
}); await
ctx
.
answer
("Location updated!");
});

Errors

CodeErrorCause
400Bad Request: message is not modifiedCoordinates and metadata are identical to the current location
400Bad Request: message can't be editedLive location live_period has expired — start a new sendLocation with a fresh live_period
400Bad Request: LOCATION_INVALIDCoordinates out of valid range (latitude must be –90 to 90, longitude –180 to 180)
400Bad Request: chat not foundInvalid or inaccessible chat_id
400Bad Request: message not foundmessage_id doesn't exist in the chat
403Forbidden: bot was blocked by the userUser blocked the bot — stop sending location updates
429Too Many Requests: retry after NFlood control — check retry_after, use auto-retry plugin

TIP

Use GramIO's auto-retry plugin to handle 429 errors automatically.

Tips & Gotchas

  • No 48-hour business message restriction — unlike other editMessage* methods, live location has no special business-message time limit. Instead, it is governed solely by the message's own live_period.
  • live_period can be extended but not by more than 86400 seconds (one day) per call. The resulting expiration date must also remain within the next 90 days. To create a permanent live location, pass 0x7FFFFFFF (2147483647) as live_period.
  • heading must be 1–360, not 0. A value of 0 is invalid and will be rejected. Omit the field entirely if direction is unknown.
  • horizontal_accuracy is 0–1500 metres. This is the GPS uncertainty radius — pass 0 to omit it rather than omitting the field.
  • Stop the location sharing early with stopMessageLiveLocation — if the user's journey ends before live_period expires, call stopMessageLiveLocation to remove the live indicator from the message immediately.
  • Inline messages return true, not Message. When editing via inline_message_id, the method returns true on success instead of the updated Message object.

See Also