Skip to main content

Get User Roles

This guide walks you through retrieving the roles assigned to a specific user in your organization using the eSign360 API.

When to Use​

Retrieving user roles is useful when you need to:

  • Verify a user's permissions before performing actions
  • Build role-based access control (RBAC) in your integration
  • Audit user access levels within your organization

Requirements​

  1. You need to have Node.js installed on your system.
  2. You'll also need the axios library. You can install it using the following command:
npm install axios
  1. A valid Bearer token (JWT) for authentication.
  2. The user ID of the user whose roles you want to retrieve.

Endpoint​

GET /user/{id}/roles

ParameterTypeRequiredDescription
idstringYesThe unique ID of the user whose roles to retrieve.

Code Snippet​

Use the following code snippet to retrieve a user's roles. Replace <userId> with the actual user ID, and <accessToken> with your API access token.

const axios = require("axios");

const userId = "<userId>";

const config = {
method: "get",
url: `https://public-api.esign360.io/user/${userId}/roles`,
headers: {
Authorization: "Bearer <accessToken>",
},
};

axios(config)
.then(function (response) {
console.log("User roles retrieved successfully:", response.data);
})
.catch(function (error) {
console.log(error.response?.data || error.message);
});

Successful Response​

On success, the API returns an array of role objects assigned to the user:

[
{
"id": "rol_abc123",
"name": "Admin",
"description": "Full administrative access"
},
{
"id": "rol_def456",
"name": "Notary",
"description": "Can perform notarizations"
}
]

Error Responses​

StatusReason
401 UnauthorizedInvalid or expired Bearer token
404 Not FoundOrganization or user not found

Steps to Execute the Code Snippet​

  1. Create a new file named get_user_roles.js.
  2. Copy and paste the code snippet provided above into the new file.
  3. Replace <userId> and <accessToken> with the appropriate values.
  4. Save the file and open a terminal or command prompt.
  5. Navigate to the folder where you saved the get_user_roles.js file.
  6. Run the following command to execute the script:
node get_user_roles.js

If the request is successful, you'll see the user's roles displayed in the console. In case of an error, the error details will be displayed instead.

Additional Resources​

For more information about the eSign360 API, visit the official documentation.

If you need further assistance or have questions, feel free to reach out to our support team.