Learn how to update user profile fields using the User API.
A user profile has many fields that store information about the user.
In this article, you will learn how to update the following user profile fields using the User API:
-
Header image:
A header image is an image that you can add to a user profile. It appears on the top of the user profile and visually personalizes the user's profile. You can use the usual web formats for the header image, such as jpg and png. The image has no fixed resolution, as it has a flexible width. But the fixed height is 390px on desktop and 268px on mobile. How the header image looks varies depending on browser window size and/or display size. Learn more -
Pronoun:
A pronoun field on a user profile allows users to set which pronouns they use. This shows how they want to be referred to when describing their gender identity. This helps to create a respectful and inclusive environment for your users. -
Profile headline:
A profile headline is a short phrase or title that appears at the top of a user's profile. It can be used to reflect their personality, interests, or goals. -
Manager:
A manager field in the user profile is filled with the manager of the user. This is also helpful for setting up the Org Chart. -
System & custom fields:
System fields are predefined profile fields in Staffbase. Custom fields can be added and maintained by administrators. Overview of Profile Fields.
You can also use this method to update other custom profile fields. If you want to update the avatar image, see Update the Avatar Using the User API.
- You have the redesigned user profile activated for your organization. This is needed for the
header image
,pronoun
andprofile headline
. - You have the header image stored in your media server, and the domain of the media server is allow listed for your app.
For example, if your app URL isexampleapp.domain.com
and the media server iscdn-de1.staffbase.com
, then you need to allow listcdn-de1.staffbase.com
for your app.
If you are hosting media files on Staffbase media servers, our domain names can be found here. - You have already created an API token with administrative access via the Staffbase Studio. Learn more.
- You have either the
externalID
orid
of the users' profiles you want to update.
To upload a header image, do the following:
Step 1: Get the URL to the header image.
Step 2: Update the header image of a user.
You can skip this step if you already have the URL to the header image.
- Create an image file for the header image.
- Make a
POST
request to the endpoint/media
to upload the file.
1export AUTH="Basic TOKEN"2 export FILEPATH="C:/Users/Pictures/ProfileHeaderImage.png"34 curl "https://exampleapp.staffbase.com/api/media" \5 -X POST \6 -H "Authorization: $AUTH" \7 -H "Content-Type: multipart/form-data" \8 -F 'file=@$FILEPATH'9 --compressed | json_pp
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 header image.
Make a POST
request to the endpoint /users/{userID}
. In the request body schema, create an object profileHeaderImage
as shown in the example, and set the value for the url
property with the header image URL.
1export USERID="5db0221d0a09a219c4ce9218"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/users/$USERID" \5-X POST \6-H "Authorization: $AUTH" \7-H "Content-Type: application/json" \8--data-raw '{9 "profile": {10 "profileHeaderImage": {11 "original": {12 "url": "https://cdn-de1.staffbase.com/t1-backend/image/upload/c_crop,w_1024,h_445,y_323/v1706890578/w9b5tjlry1ys0OU11E4ll4c57xt5hmw6gEazreamCp7j9ISt1uuJ0gTor0k4rd1YKB4QhGmRPvhHR3wup8EEMmKj0aSqumGSAnCzm1v3WHJRgGtyo0MyNTFiCx4wsZ2Et7nymo2aVNwtzBWsvYc3jcLjkZc9uvVBeRqTwtmqfjjrO5QWeKpidQfyIoY6Jh6v/caesar.jpg",13 "size": 24293,14 "width": 1024,15 "height": 768,16 "created": "1706890578795",17 "format": "jpg",18 "mimeType": "image/jpeg"19 },20 "icon": {21 "url": "https://cdn-de1.staffbase.com/t1-backend/image/upload/c_crop,w_1024,h_445,y_323/c_fill,w_200,h_200/w_70,h_70/v1706890578/w9b5tjlry1ys0OU11E4ll4c57xt5hmw6gEazreamCp7j9ISt1uuJ0gTor0k4rd1YKB4QhGmRPvhHR3wup8EEMmKj0aSqumGSAnCzm1v3WHJRgGtyo0MyNTFiCx4wsZ2Et7nymo2aVNwtzBWsvYc3jcLjkZc9uvVBeRqTwtmqfjjrO5QWeKpidQfyIoY6Jh6v/caesar.jpg",22 "format": "jpg",23 "mimeType": "image/jpeg"24 },25 "thumb": {26 "url": "https://cdn-de1.staffbase.com/t1-backend/image/upload/c_crop,w_1024,h_445,y_323/c_fill,w_200,h_200/v1706890578/w9b5tjlry1ys0OU11E4ll4c57xt5hmw6gEazreamCp7j9ISt1uuJ0gTor0k4rd1YKB4QhGmRPvhHR3wup8EEMmKj0aSqumGSAnCzm1v3WHJRgGtyo0MyNTFiCx4wsZ2Et7nymo2aVNwtzBWsvYc3jcLjkZc9uvVBeRqTwtmqfjjrO5QWeKpidQfyIoY6Jh6v/caesar.jpg",27 "format": "jpg",28 "mimeType": "image/jpeg"29 }30 }31 }32}'
You have updated the header image of a user. To bulk update header images, add a function to loop through all users to perform your requests.
Make a POST
request to the endpoint /users/{userID}
. In the request body schema, create an object pronouns
as shown in the example, and set it with the user's preferred gender pronoun.
1export USERID="5db0221d0a09a219c4ce9218"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/users/$USERID" \5-X POST \6-H "Authorization: $AUTH" \7-H "Content-Type: application/json" \8--data-raw '{9 "profile": {10 "pronouns": "She/her"11 }12}'
You have updated the pronoun of a user. To bulk update pronouns, add a function to loop through all users to perform your requests.
Make a POST
request to the endpoint /users/{userID}
. In the request body schema, create an object profileHeadline
as shown in the example, and set it with a profile headline for the user.
1export USERID="5db0221d0a09a219c4ce9218"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/users/$USERID" \5-X POST \6-H "Authorization: $AUTH" \7-H "Content-Type: application/json" \8--data-raw '{9 "profile": {10 profileHeadline": "Software engineer | Photography enthusiast"11 }12}'
You have updated the profile headline of a user. To bulk update profile headlines, add a function to loop through all users to perform your requests.
Make a POST
request to the endpoint /users/{userID}
. In the request body schema, create an object system_manager
as shown in the example, and set it with the userID of the user's manager.
1export USERID="5db0221d0a09a219c4ce9218"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/users/$USERID" \5-X POST \6-H "Authorization: $AUTH" \7-H "Content-Type: application/json" \8--data-raw '{9 "profile": {10 system_manager": "5d1374030a09a29cde85b581"11 }12}'
You have updated a user profile with the manager's details. To bulk update manager fields for several users, add a function to loop through all users to perform your requests.
Note: This example assumes you have a custom profile field created in Staffbase with the profile field ID businessunit
.
Make a POST
request to the endpoint /users/{userID}
. In the request body schema, create an object businessunit
as shown in the example, and set it with the business unit of the user.
In addition, you can also update the department
and location
system fields as shown in the example.
1export USERID="5db0221d0a09a219c4ce9218"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/users/$USERID" \5-X POST \6-H "Authorization: $AUTH" \7-H "Content-Type: application/json" \8--data-raw '{9 "profile": {10 "businessunit": "{{valueXY}}"11 },12 "department": "Sales",13 "location": "New York",14}'
You have updated a user profile with business unit, department and location details. To bulk update fields for several users, add a function to loop through all users to perform your requests.