Manage User Logout via the User API

Explore how to bulk manage user logout via the User API.

Employee App
Front Door Intranet

In this article, you will learn how to manage user access by logging users out via the User API. In case of a security breach or to prevent a security breach, you can trigger one or more users to be logged out of all their active sessions on all devices.

Staffbase offers many ways to manage user access. In the case of CSV import or SCIM, it is not possible to trigger user log out unless the user account is deactivated. In such cases, use the User API to simplify your business processes.

  • You have already created an API token with administrative access via the Staffbase Studio. Learn more.
Copy the base URL from the API token page in the Staffbase Studio before you begin.

You need to first retrieve the user ID or the identifier of the user you want to trigger a user logout.

  1. Make a GET request to the endpoint /users to list all users.
Terminal window
export AUTH="Basic {{Token}}"
curl -X GET 'https://exampleapp.staffbase.com/api/users' \
-H 'Authorization: $AUTH' \
--compressed | json_pp
  1. Filter the response for the id or externalID of the user.

You have the user ID or the identifier of the user you want to trigger a user log out.

Terminal window
export USERID="5db0221d0a09a219c4ce9218"
export AUTH="Basic TOKEN"
curl "https://exampleapp.staffbase.com/api/users/{userID}/sessions" \
-X DELETE \
-H "Authorization: $AUTH" \
--compressed | json_pp

You have triggered a single user to be logged out of all active sessions on all devices. To bulk trigger user logout for multiple users, add a function to loop through multiple users to perform your requests.