Skip to content

setMyProfilePhoto ​

Changes the profile photo of the bot. Returns True on success.

Parameters ​

photoInputProfilePhotoRequired
The new profile photo to set

Returns ​

On success, True is returned.

GramIO Usage ​

ts
// Set a static profile photo from a local file
await 
bot
.
api
.
setMyProfilePhoto
({
photo
: {
type
: "static",
photo
: await
MediaUpload
.
path
("./avatar.jpg"),
}, });
ts
// Set an animated profile photo (MPEG4, up to 5s, 640×640)
await 
bot
.
api
.
setMyProfilePhoto
({
photo
: {
type
: "animated",
animation
: await
MediaUpload
.
path
("./avatar.mp4"),
main_frame_timestamp
: 0,
}, });
ts
// Set a static photo from a URL
await 
bot
.
api
.
setMyProfilePhoto
({
photo
: {
type
: "static",
photo
: await
MediaUpload
.
url
("https://example.com/avatar.jpg"),
}, });

Errors ​

CodeErrorCause
400Bad Request: PHOTO_INVALID_DIMENSIONSImage dimensions are too large or the aspect ratio is not supported
400Bad Request: wrong file identifier/HTTP URL specifiedThe URL is not accessible by Telegram's servers, or the file_id is invalid
400Bad Request: failed to get HTTP URL contentTelegram could not download the file from the provided URL — check the URL is publicly accessible
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 ​

  • Profile photos cannot be reused by file_id. Unlike regular media, profile photos must always be uploaded as new files — you cannot pass an existing file_id. Use MediaUpload.path() or MediaUpload.url().
  • Two types: static and animated. static accepts a .jpg image; animated accepts an MPEG4 video (up to 5 seconds, 640×640 pixels, 30fps recommended). Set the type field accordingly.
  • main_frame_timestamp for animated photos. When uploading an animated photo, set main_frame_timestamp to the second (as a float) that should be used as the static thumbnail. Defaults to 0.
  • Use removeMyProfilePhoto to delete the current photo. To revert to the default Telegram avatar, call removeMyProfilePhoto instead.
  • File uploads are async. MediaUpload.path() and MediaUpload.url() return Promises — always await them before passing to the API call.

See Also ​