Learn how to offboard users via the User API.
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.
- 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.
-
If you do not already have the
id
orexternalID
of the user, do the following:- Make a
GET
request to the endpoint/users
to list all users.
1 export AUTH="Basic TOKEN"23 curl -X GET 'https://exampleapp.staffbase.com/api/users' \4 -H 'Authorization: $AUTH' \5 --compressed | json_pp- Filter the response for the
userID
of the user.
Learn more about it here.
- Make a
-
Make a
PUT
request to the endpoint/users/{userID}
and in the request body schema, set thestatus
parameter todeactivated
.
1 export USERID="5db0221d0a09a219c4ce9218"2 export AUTH="Basic TOKEN"34 curl "https://exampleapp.staffbase.com/api/users/$userID" \5 -X PUT \6 -H "Authorization: $AUTH" \7 -H "Content-Type: application/json" \8 --data-raw '{9 "status": "deactivated"10 }' \11 --compressed | json_pp
If you want to activate a deactivated user account, set the status parameter to activated.
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
GET
request to the endpoint/users
to list all users with the filterstaffbase.status
set todeactivated
.
1 export AUTH="Basic TOKEN"23 # URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "deactivated"4 curl -X GET 'https://exampleapp.staffbase.com/api/users?filter=staffbase.status%20eq%20%22deactivated%22' \5 -H 'Authorization: $AUTH' \6 --compressed | json_pp
Learn more about user account filters here.
- From the list of users in the response, gather the userIDs of deactivated user accounts.
- Make a
DELETE
request to endpoint/users/{userID}
for each user.
1 export USERID="5db0221d0a09a219c4ce9218"2 export AUTH="Basic TOKEN"34 curl "https://exampleapp.staffbase.com/api/users/$userID" \5 -X DELETE \6 -H "Authorization: $AUTH" \7 --compressed | json_pp
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
GET
request to the endpoint/users
to list all users with the following parameters:
staffbase.status
set todeactivated
- updated set to the desired time frame using the common operators, such as
gt
,ge
,le
,lt
,eq
,n
1 export AUTH="Basic TOKEN"23 # Gathering deactivated users which were updated since 2021-07-07T10:004 # URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "deactivated" and updated gt "2021-07-07T10:00"5 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' \6 -H 'Authorization: $AUTH' \7 --compressed | json_pp
Learn more about user account filters here.
- From the list of users in the response, gather the
userID
s of deactivated user accounts. - Make a
DELETE
request to endpoint/users/{userID}
.
1 export USERID="5db0221d0a09a219c4ce9218"2 export AUTH="Basic TOKEN"34 curl "https://exampleapp.staffbase.com/api/users/$userID" \5 -X DELETE \6 -H "Authorization: $AUTH" \7 --compressed | json_pp
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
GET
request to the endpoint/users
to list all users with the filterstaffbase.status
set topending
.
1 export AUTH="Basic TOKEN"23 # URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "pending"4 curl -X GET 'https://exampleapp.staffbase.com/api/users?filter=staffbase.status%20eq%20%22pending%22' \5 -H 'Authorization: $AUTH' \6 --compressed | json_pp
Learn more about user account filters here.
- From the list of users in the response, gather the
userID
s of pending user accounts. - Make a
DELETE
request to the endpoint/users/{userID}
for each user.
1 export USERID="5db0221d0a09a219c4ce9218"2 export AUTH="Basic TOKEN"34 curl "https://exampleapp.staffbase.com/api/users/$userID" \5 -X DELETE \6 -H "Authorization: $AUTH" \7 --compressed | json_pp
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
GET
request to the endpoint/users
to list all users and filter for:
-
user accounts with
staffbase.status
set to one of following:pending
activated
deactivated
1 export AUTH="Basic TOKEN"23 # URL Decoded: https://exampleapp.staffbase.com/api/users?filter=staffbase.status eq "deactivated" or staffbase.status eq "activated" or staffbase.status eq "pending"4 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' \5 -H 'Authorization: $AUTH' \6 --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
userID
s of those accounts. -
Make a
DELETE
request to the endpoint/users/{userID}
for each user.
1 export USERID="5db0221d0a09a219c4ce9218"2 export AUTH="Basic TOKEN"34 curl "https://exampleapp.staffbase.com/api/users/$userID" \5 -X DELETE \6 -H "Authorization: $AUTH" \7 --compressed | json_pp