sendLocation
Use this method to send point on the map. On success, the sent Message is returned.
Parameters
business_connection_idStringOptionalUnique identifier of the business connection on behalf of which the message will be sent
chat_idIntegerStringRequiredUnique identifier for the target chat or username of the target channel (in the format
@channelusername)message_thread_idIntegerOptionalUnique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only
direct_messages_topic_idIntegerOptionalIdentifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat
latitudeFloatRequiredLatitude of the location
longitudeFloatRequiredLongitude of the location
horizontal_accuracyFloatOptionalThe radius of uncertainty for the location, measured in meters; 0-1500
live_periodIntegerOptionalPeriod in seconds during which the location will be updated (see Live Locations, should be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely.
headingIntegerOptionalFor live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.
proximity_alert_radiusIntegerOptionalFor live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.
disable_notificationBooleanOptionalSends the message silently. Users will receive a notification with no sound.
protect_contentBooleanOptionalProtects the contents of the sent message from forwarding and saving
allow_paid_broadcastBooleanOptionalPass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot's balance
message_effect_idStringOptionalUnique identifier of the message effect to be added to the message; for private chats only
A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.
Description of the message to reply to
reply_markupInlineKeyboardMarkupReplyKeyboardMarkupReplyKeyboardRemoveForceReplyOptional⌨️ KeyboardsAdditional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user
Returns
On success, the Message object is returned.
GramIO Usage
ts
// Send a static location (office address)
bot.command("office", (ctx) =>
ctx.sendLocation(48.8584, 2.2945)
);ts
// Reply with a location with accuracy radius
bot.command("meethere", (ctx) =>
ctx.replyWithLocation(37.7749, -122.4194, {
horizontal_accuracy: 50,
})
);ts
// Start a live location that updates for 1 hour
bot.command("track", async (ctx) => {
const msg = await ctx.sendLocation(55.7558, 37.6173, {
live_period: 3600, // 1 hour in seconds
heading: 90, // facing East
});
// Save msg.messageId to update it later via editMessageLiveLocation
});ts
// Update a live location with new coordinates
await bot.api.editMessageLiveLocation({
chat_id: 123456789,
message_id: 42,
latitude: 55.7600,
longitude: 37.6200,
heading: 180,
});ts
// Stop a live location early
await bot.api.stopMessageLiveLocation({
chat_id: 123456789,
message_id: 42,
});ts
// Direct API call — send a static location with proximity alerts enabled
await bot.api.sendLocation({
chat_id: 123456789,
latitude: 51.5074,
longitude: -0.1278,
live_period: 86400,
proximity_alert_radius: 500, // alert when within 500 m
});Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: chat not found | chat_id is invalid or the bot has no access |
| 400 | Bad Request: LOCATION_INVALID | latitude or longitude is out of valid range (±90 / ±180) |
| 400 | Bad Request: wrong live_period | live_period is not between 60 and 86400 (or the special 0x7FFFFFFF) |
| 400 | Bad Request: wrong heading | heading is outside the 1–360 degree range |
| 400 | Bad Request: wrong proximity_alert_radius | proximity_alert_radius is outside the 1–100000 meter range |
| 403 | Forbidden: bot was blocked by the user | User blocked the bot — catch and mark as inactive |
| 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
headingandproximity_alert_radiusonly apply to live locations. If you set them withoutlive_period, they are ignored silently. Only include them whenlive_periodis set.live_periodof0x7FFFFFFF(2147483647) creates an indefinitely-updatable live location. It won't expire automatically — you must callstopMessageLiveLocationto end it.- Save the returned
message_idto update live locations. You'll need bothchat_idandmessage_idwhen callingeditMessageLiveLocationorstopMessageLiveLocation. ctx.sendLocation(lat, lon, params?)— note the argument order. Latitude comes first, longitude second. This matches GramIO's method signature and differs from how some map libraries order coordinates.horizontal_accuracyrange is 0–1500 meters. Values outside this range cause a400error. Use0or omit the field if you don't have an accuracy value.- Venue vs. Location. If you're sharing a named place (business, landmark), prefer
sendVenue— it shows a name and address alongside the map pin.
See Also
- editMessageLiveLocation — update coordinates of a live location
- stopMessageLiveLocation — stop a live location before it expires
- sendVenue — send a named location (address + title)
- Location — the Location type object
- Keyboards overview — how to add inline keyboards to location messages
- auto-retry plugin — automatic
429handling