When users leave the organization or do not need access to the Staffbase platform, you can offboard them from the platform.
Although Staffbase offers different methods to offboard users, we recommend using the User API when you need to offboard a large number of users.
In this article, we’ll look at how to offboard users via the User API for different use cases.
Prerequisite
- You have already generated an API token with administrative access via the Staffbase Studio.
If your application is hosted on the German Hosting Infrastructure, you will need to adjust the base URL used in the request examples. Learn more about it here.
Deactivate user accounts
-
If you do not already have the
idorexternalIDof the user, do the following:- Make a
GETrequest to the endpoint/usersto list all users.
Terminal window export AUTH="Basic TOKEN"curl -X GET 'https://exampleapp.staffbase.com/api/users' \-H 'Authorization: $AUTH' \--compressed | json_pp- Filter the response for the
userIDof the user.
Learn more about it here.
- Make a
-
Make a
PUTrequest to the endpoint/users/{userID}and in the request body schema, set thestatusparameter todeactivated.
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 '{ "status": "deactivated" }' \ --compressed | json_ppIf you want to activate a deactivated user account, set the status parameter to activated.
Delete all deactivated user accounts
Once a user account is deleted, it cannot be restored by either the administrators or Staffbase. A new user account must be created.
- Make a
GETrequest to the endpoint/usersto list all users with the filterstaffbase.statusset todeactivated.
export AUTH="Basic TOKEN"
# URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "deactivated" curl -X GET 'https://exampleapp.staffbase.com/api/users?filter=staffbase.status%20eq%20%22deactivated%22' \ -H 'Authorization: $AUTH' \ --compressed | json_ppLearn more about user account filters here.
- From the list of users in the response, gather the userIDs of deactivated user accounts.
- Make a
DELETErequest to endpoint/users/{userID}for each user.
export USERID="5db0221d0a09a219c4ce9218" export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$userID" \ -X DELETE \ -H "Authorization: $AUTH" \ --compressed | json_ppDelete all deactivated user accounts within a specific time frame
Once a user account is deleted, it cannot be restored by either the administrators or Staffbase. A new user account must be created.
You can delete user accounts that were deactivated within a specific time period.
- Make a
GETrequest to the endpoint/usersto list all users with the following parameters:
staffbase.statusset todeactivated- updated set to the desired time frame using the common operators, such as
gt,ge,le,lt,eq,n
export AUTH="Basic TOKEN"
# Gathering deactivated users which were updated since 2021-07-07T10:00 # URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "deactivated" and updated gt "2021-07-07T10:00" curl -X GET 'https://exampleapp.staffbase.com/api/users?filter=staffbase.status%20eq%20%22deactivated%22%20and%20updated%20gt%20%222021-07-07T10%3A00%22' \ -H 'Authorization: $AUTH' \ --compressed | json_ppLearn more about user account filters here.
- From the list of users in the response, gather the
userIDs of deactivated user accounts. - Make a
DELETErequest to endpoint/users/{userID}.
export USERID="5db0221d0a09a219c4ce9218" export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$userID" \ -X DELETE \ -H "Authorization: $AUTH" \ --compressed | json_ppDelete pending user accounts
Once a user account is deleted, it cannot be restored by either the administrators or Staffbase. A new user account must be created.
Pending user accounts belong to those users who have been invited to the Staffbase platform but yet to register in the platform. You can clean up the pending user accounts by deleting them from the platform.
- Make a
GETrequest to the endpoint/usersto list all users with the filterstaffbase.statusset topending.
export AUTH="Basic TOKEN"
# URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "pending" curl -X GET 'https://exampleapp.staffbase.com/api/users?filter=staffbase.status%20eq%20%22pending%22' \ -H 'Authorization: $AUTH' \ --compressed | json_ppLearn more about user account filters here.
- From the list of users in the response, gather the
userIDs of pending user accounts. - Make a
DELETErequest to the endpoint/users/{userID}for each user.
export USERID="5db0221d0a09a219c4ce9218" export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$userID" \ -X DELETE \ -H "Authorization: $AUTH" \ --compressed | json_ppDeleting all user accounts with a certain tag
Once a user account is deleted, it cannot be restored by either the administrators or Staffbase. A new user account must be created.
Your users can have tags on their profiles. These tags are custom-defined attributes. They can be created based on departments, interest groups, or locations. Learn more here.
- Make a
GETrequest to the endpoint/usersto list all users and filter for:
-
user accounts with
staffbase.statusset to one of following:pendingactivateddeactivated
Terminal window export AUTH="Basic TOKEN"# URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "deactivated" or staffbase.status eq "activated" or staffbase.status eq "pending"curl -X GET 'https://exampleapp.staffbase.com/api/users?filter=staffbase.status%20eq%20%22deactivated%22%20or%20staffbase.status%20eq%20%22activated%22%20or%20staffbase.status%20eq%20%22pending%22' \-H 'Authorization: $AUTH' \--compressed | json_pp
To get all the tags used in the platform, make a GET request to the endpoint /tags.
-
Filter the list of users in the response for the desired tag and gather the
userIDs of those accounts. -
Make a
DELETErequest to the endpoint/users/{userID}for each user.
export USERID="5db0221d0a09a219c4ce9218" export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/$userID" \ -X DELETE \ -H "Authorization: $AUTH" \ --compressed | json_pp