Learn how to update the avatar using the User API.
An avatar is an image to visually distinguish a user’s profile. In this article, you will learn how to update the avatars for a large number of users using the User API.
An avatar image consists of three different image types. There are image specifications for each image type. You need to provide a separate image URL for each image type in order to update the avatar image.
The image types are:
For optimal results, Staffbase recommends providing three different image URLs for the original, thumb, and icon images when uploading an avatar image via User API. If you do not provide different URLs, the original image is used for both the icon and thumb images.
externalID
or id
of the users’ profiles you want to update.Get familiar with the avatar data model. Understanding the data model helps you update avatar images optimally.
To upload a user avatar, do the following:
Step 1: Get the URL to the avatar.
Step 2: Update the avatar of the user.
You can skip this step if you already have the URL to the avatar.
original
.POST
request to the endpoint /media
to upload the file.Learn more about our Media API.
Get the URL of the uploaded file from the request response.
You can now use this URL to update the original image.
Repeat the above steps to upload thumb
and icon
images to the Media API.
Make a POST
request to the endpoint /users/{userID}
. In the request body schema, under the object avatar
, you need to set the url
parameter for the following nested objects:
original
icon
thumb
You have updated the avatar of a user. To bulk update user avatars, add a function to loop through all users to perform your requests.