Search code examples
thingsboard

Is there an HTTP API to create Users in Thingsboard?


Here is my project details, We have a Mobile App that should send device's data to Thingsboard server. For this, we need to have a user accounts in Thingboard, so that they can JWT token on sign-in in the Mobile App. And this JWT token is user for the data upload & retrieve.

So, for the new users, we have developed a form page to register in the APP. When user fill-up the form and submit, what api shall be used here that will create a new User entity in Thingboard and send an account activation link to provided email?

Your help would be appreciated.

Thank you.


Solution

  • The Thingsboard REST API has proper 'saveUser' method that can be used to create user accounts, however this endpoint requires a JWT Token with proper authorization to Create Users.

    We had a similar problem and ended up creating a custom REST api service to wrap the Thingsboard Native REST and user a hardcoded username and password in order to auth the account creations. We did this to avoid having the username and password hardcoded in our Mobile App. We later switched to adding the users directly in database with an ORM.

    We had to use this approach because we user Thingsboard PE, if you use TB CE you can try to modify the REST Api in order to allow this endpoint to be used without JWT.

    The swagger UI can be checked at:

     {base_url}/swagger-ui.html
    

    and the crate user endpoint is:

     {base_url}/api/user?sendActivationMail=true