Managing Users with the PubSub+ Cloud REST API

With the PubSub+ Cloud REST API and API token support for user management, you can create, update, and delete users programmatically.

This tutorial shows you how to:

Before you Begin

Before you can start this tutorial, you'll require the following:

  • A PubSub+ Cloud Enterprise Account. Only Enterprise Accounts support multiple users; REST endpoints in this example cannot be used otherwise.
  • Your account must be assigned the Administrator role.
  • An API token with at least the following permissions under Account Management:
    • Get Users
    • Get Roles
    • Create Users
    • Delete Users
    • Set Roles

    For more information, see Creating an API Token.

  • A way to send REST messages from your development environment. We use Postman in this tutorial. You can use the Solace Blogs – Solace Cloud User Management Postman collection and click the Run in Postman button to import the collection to Postman, which permits you to easily work through the steps in this tutorial. Alternatively, you can simply make each call by specifying it REST API in Postman after you've set up the environment in Postman to use your API token. For more information about setting up Postman, see Managing API Tokens.

    At this time, the documentation on the Solace Blogs about the PubSub+ Cloud REST API may be out of date. Refer to the documentation on this website for instructions about using the PubSub+ Cloud REST API.

    After you've set up the environment in Postman to use your API token, you can simply make each call by specifying the REST API. To check that API token is set up correctly to use Bearer authorization in Postman, select the Headers tab to validate that it is using Bearer Authorization and set it to use the apiToken environment variable that you had set up earlier. For example, you can see that Authorization is set up to use Bearer and the apiToken in the following illustration:

Creating a User

You can use the PubSub+ Cloud REST API to create a user. To create a user, follow these steps:

  1. In the Postman Collection Solace Blogs – Solace Cloud User Management, select the request POST Invite User
  2. In the Body, modify theemail object's value to the email address of the user you wish to invite, then click the Send button.

    You should see a JSON response confirming that the specified user was invited.

  3. Go to the PubSub+ Cloud Console, click User & Account on the navigation bar, select Account Details, and then select the User Management tab. On the page, you should see the invited user.

You have just successfully invited another user. The user for the email address you specified should receive an invitation email that guides the them through the rest of the activation process.

Getting All Users from Your Account

You can get a list of all the users for an account for which the API token was created. To find all the users in an account, follow these steps:

  1. In the Postman Collection Solace Blogs – Solace Cloud User Management, select the request Get Users in My Account.
  2. Click Send.

    You should see the details for all user in the response. An important part of the information is the userId, which is used for the other commands.

Getting the Details of a User

Once you know the user, you can retrieve details about the user based on the userId value. You can use the Get Users in My Account command to find that information. To get the details of a user, follow these steps:

  1. In the Postman Collection Solace Blogs – Solace Cloud User Management, select the request Get User in Account.
  2. Modify Get request URL and replace the {{userId}} with the userID value you want. In this case, we put 16kpvpyui5vp.
  3. Click Send.

    You should see the details of the specified user in the response.

Assigning Roles to a User

One you've created and retrieved the details of your user, you can try change the roles assigned to a user. First, we'll want to determine the roles that are available for assigning. To determine the roles available that you can assign, use these steps:

  1. In the Solace Blogs – Solace Cloud User Management Postman Collection, select the Get Roles in Account request.
  2. Click Send.

    You should be see a list of available roles, each with a list of permissions they contain.

Now, use the following steps to set the roles for a user:

  1. In the Solace Blogs – Solace Cloud User Management Postman Collection, select the PUT Set Roles for User request.

  2. Modify PUT request URL and replace the {{userId}} with value of the user you want to assign roles to. In the body of the request, set the see the value messaging-service-editor and billing-administrator for the id field. Multiple roles are simply specified as an additional id. This ID corresponds to one of the roles returned from the previous Get Roles in Account request. When you send the request, the user's existing roles are replaced with the ones you've specified.

  3. Click Send.

    You should receive a 200 OK response that confirms roles were successfully assigned to the user.

Deleting a User

You can delete a user. It's typical to use delete users that you've used for testing and that you may want to remove as part of clean-up. To delete a user, follow these steps:

  1. In the Solace Blogs – Solace Cloud User Management Postman Collection, select the Delete User request.
  2. Modify Delete request URL and replace the {{userId}} with the identifer of the user that you want to delete.
  3. Click Send.

    You should receive a 200 OK response that confirms deletion of the user was successful.