Send Recovery Codes via the User API

Explore how to bulk manage sending user account recovery codes via the User API.

Employee App
Front Door Intranet

In this article, you will learn how to manage user access by sending recovery codes via the User API.

Staffbase offers many ways to manage user access. In some use cases, it is not possible to perform triggers to send recovery codes via CSV import or SCIM. 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 recovery email for.

  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 recovery email for.

You can trigger recovery codes to allow one or more users to recover access to their accounts in case they forget their passwords. Learn more about different recovery methods.

The recovery code is not applicable if you have implemented Single Sign-On (SSO) or System for Cross-domain Identity Management (SCIM) in combination with SSO for your Staffbase platform.

On triggering the recovery code, the user receives an email with the recovery code. If the user has no registered email address, you have to communicate the recovery code directly to the user.

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

You have triggered the recovery code for a single user. To bulk trigger the recovery code for multiple users, add a function to loop through multiple users to perform your requests.