Set User Avatar

HTTP MethodURLRequires Auth

POST

/api/v1/users.setAvatar

Permission required: edit-other-user-avatar, if the setting AllowUserAvatarChange is enabled.

Body Parameters

KeyExample ValueDescription

image* or avatarUrl*

Any image file or a URL http://domain.tld/to/my/own/avatar.jpg

You have 2 options to set the user avatar:

  • Upload the image file to use as the new avatar, as form data.

  • Enter the image URL you want to set as the user avatar.

userId or username

BsNr28znDkG8aeo7W or bobsmith

The ID or username of the user. If not provided, the avatar of the user who is sending the request is updated.

Example Call

With an image as form data:

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
     -H "X-User-Id: aobEdbYhXfu5hkeqG" \
     -F "image=@my-own-avatar.png" \
     http://localhost:3000/api/v1/users.setAvatar

With URL:

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
     -H "X-User-Id: aobEdbYhXfu5hkeqG" \
     -H "Content-type:application/json" \
     -d '{
          "avatarUrl": "http://domain.tld/to/my/own/avatar.jpg"}' \
     http://localhost:3000/api/v1/users.setAvatar

Example Response

{
    "success": true
}

Change Log

VersionDescription

0.56.0

Add support for username argument.

0.48.0

Set other users avatars if the callee has permission.

0.46.0

Added

Last updated

Rocket.Chat versions receive support for six months after release.