In this article, you will learn how to update the user reference field of a large number of users. For example, their manager field. In that case, you can bulk update the manager profile field for these users using the User API.
Prerequisite
- You have already created an API token with administrative access via the Staffbase Studio.
Copy the base URL from the API token page in the Staffbase Studio before you begin.
Get the id
or externalID
of the user
You need to first retrieve the user ID or the identifier of the user’s profile field you want to update.
- Make a
GET
request to the endpoint/users
to list all users.
export AUTH="Basic {{Token}}"
curl -X GET 'https://exampleapp.staffbase.com/api/users' \ -H 'Authorization: $AUTH' \ --compressed | json_pp
- Filter the response for the
id
orexternalID
of the user.
You have the user ID or the identifier of the user’s profile field you want to update.
Update profile field with user reference input type using the User API
Make a PUT
request to the endpoint /users/{userID}
and in the request body schema, set the manager parameter with an identifier or the User ID of the user.
export USERID="5db0221d0a09a219c4ce9218" export AUTH="Basic TOKEN" curl "https://exampleapp.staffbase.com/api/users/$userID" \ -X PUT \ -H "Authorization: $AUTH" \ -H "Content-Type: application/json" \ --data-raw '{ "profile": { "system_manager": "5db0221d0a09a219c4ce9218" }, }' \ --compressed | json_pp
You have updated the user reference input type profile field of a user. To bulk update this profile field, add a function to loop through all users to perform your requests.