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_idStringOptionalUnique identifier of the business connection on behalf of which the message to be edited was sent
chat_idIntegerStringOptionalRequired if inline\message\id is not specified. Unique identifier for the target chat or username of the target channel (in the format
@channelusername)message_idIntegerOptionalRequired if inline\message\id is not specified. Identifier of the message to edit
inline_message_idStringOptionalRequired if chat\id and message\id are not specified. Identifier of the inline message
latitudeFloatRequiredLatitude of new location
longitudeFloatRequiredLongitude of new location
live_periodIntegerOptionalNew 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_accuracyFloatOptionalThe radius of uncertainty for the location, measured in meters; 0-1500
headingIntegerOptionalDirection in which the user is moving, in degrees. Must be between 1 and 360 if specified.
proximity_alert_radiusIntegerOptionalThe 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
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: message is not modified | Coordinates and metadata are identical to the current location |
| 400 | Bad Request: message can't be edited | Live location live_period has expired — start a new sendLocation with a fresh live_period |
| 400 | Bad Request: LOCATION_INVALID | Coordinates out of valid range (latitude must be –90 to 90, longitude –180 to 180) |
| 400 | Bad Request: chat not found | Invalid or inaccessible chat_id |
| 400 | Bad Request: message not found | message_id doesn't exist in the chat |
| 403 | Forbidden: bot was blocked by the user | User blocked the bot — stop sending location updates |
| 429 | Too Many Requests: retry after N | Flood 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 ownlive_period. live_periodcan 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, pass0x7FFFFFFF(2147483647) aslive_period.headingmust be 1–360, not 0. A value of 0 is invalid and will be rejected. Omit the field entirely if direction is unknown.horizontal_accuracyis 0–1500 metres. This is the GPS uncertainty radius — pass0to omit it rather than omitting the field.- Stop the location sharing early with
stopMessageLiveLocation— if the user's journey ends beforelive_periodexpires, callstopMessageLiveLocationto remove the live indicator from the message immediately. - Inline messages return
true, notMessage. When editing viainline_message_id, the method returnstrueon success instead of the updatedMessageobject.
See Also
- stopMessageLiveLocation — explicitly end live location sharing
- sendLocation — send a new location (static or live) to start sharing
- editMessageReplyMarkup — update only the keyboard without changing coordinates
- Keyboards overview — building inline keyboards with
InlineKeyboard - Message — the type returned on success for non-inline messages
- auto-retry plugin — automatic
429retry handling