Update User Profile Fields Using the User API

Learn how to update user profile fields using the User API.

Employee App
Front Door Intranet

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 and profile 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 is exampleapp.domain.com and the media server is cdn-de1.staffbase.com, then you need to allow list cdn-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 or id 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.

  1. Create an image file for the header image.
  2. Make a POST request to the endpoint /media to upload the file.
Terminal window
export AUTH="Basic TOKEN"
export FILEPATH="C:/Users/Pictures/ProfileHeaderImage.png"
curl "https://exampleapp.staffbase.com/api/media" \
-X POST \
-H "Authorization: $AUTH" \
-H "Content-Type: multipart/form-data" \
-F 'file=@$FILEPATH'
--compressed | json_pp

Learn more about our Media API.

  1. 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.

Terminal window
export USERID="5db0221d0a09a219c4ce9218"
export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$USERID" \
-X POST \
-H "Authorization: $AUTH" \
-H "Content-Type: application/json" \
--data-raw '{
"profile": {
"profileHeaderImage": {
"original": {
"url": "https://cdn-de1.staffbase.com/t1-backend/image/upload/c_crop,w_1024,h_445,y_323/v1706890578/w9b5tjlry1ys0OU11E4ll4c57xt5hmw6gEazreamCp7j9ISt1uuJ0gTor0k4rd1YKB4QhGmRPvhHR3wup8EEMmKj0aSqumGSAnCzm1v3WHJRgGtyo0MyNTFiCx4wsZ2Et7nymo2aVNwtzBWsvYc3jcLjkZc9uvVBeRqTwtmqfjjrO5QWeKpidQfyIoY6Jh6v/caesar.jpg",
"size": 24293,
"width": 1024,
"height": 768,
"created": "1706890578795",
"format": "jpg",
"mimeType": "image/jpeg"
},
"icon": {
"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",
"format": "jpg",
"mimeType": "image/jpeg"
},
"thumb": {
"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",
"format": "jpg",
"mimeType": "image/jpeg"
}
}
}
}'

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.

Terminal window
export USERID="5db0221d0a09a219c4ce9218"
export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$USERID" \
-X POST \
-H "Authorization: $AUTH" \
-H "Content-Type: application/json" \
--data-raw '{
"profile": {
"pronouns": "She/her"
}
}'

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.

Terminal window
export USERID="5db0221d0a09a219c4ce9218"
export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$USERID" \
-X POST \
-H "Authorization: $AUTH" \
-H "Content-Type: application/json" \
--data-raw '{
"profile": {
profileHeadline": "Software engineer | Photography enthusiast"
}
}'

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.

Terminal window
export USERID="5db0221d0a09a219c4ce9218"
export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$USERID" \
-X POST \
-H "Authorization: $AUTH" \
-H "Content-Type: application/json" \
--data-raw '{
"profile": {
system_manager": "5d1374030a09a29cde85b581"
}
}'

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.

Terminal window
export USERID="5db0221d0a09a219c4ce9218"
export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$USERID" \
-X POST \
-H "Authorization: $AUTH" \
-H "Content-Type: application/json" \
--data-raw '{
"profile": {
"businessunit": "{{valueXY}}"
},
"department": "Sales",
"location": "New York",
}'

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.