# Users
Multiple users may belong to an account. Users in parent accounts can view child accounts. User's have differing permissions depending on their role. Some users might only be able to view and access devices, but not add and delete child accounts and other users, etc.
# get users
# GET /v1/accounts/{AccountId}/users
Gets a list of all users in the account with AccountId and all users in the child accounts. Must have "Edit Users" permission.
# Parameters
Name | Type | Description |
---|---|---|
AccountId | int | id of account from which to get users |
# Example
curl -X GET "https://api.controlbyweb.cloud/api/v1/accounts/{AccountId}/users" \
-H "Authorization: Bearer {authToken}"
# Response
[{
"id": 27,
"account_id": 7852,
"username": "fooBar",
"first_name": "Foo",
"last_name": "Bar",
"email": "fooBar@controlbyweb.com",
"email_verified_at": "2020-12-19T19:29:18.000000Z",
"account_name": "fooBar",
"account_admin": 1,
"terms_agreed": 1
},
{
"id": 27,
"account_id": 5827,
"username": "fooBarbaz",
"first_name": "Foo",
"last_name": "Bar",
"email": "fooBarbaz@controlbyweb.com",
"email_verified_at": "2020-12-19T19:29:18.000000Z",
"account_name": "fooBarBaz",
"account_admin": 0,
"terms_agreed": 1
}]
# get user
# GET /v1/accounts/{AccountId}/users/{UserId}
Gets a specifec user with the given UserId, must belong to the account with AccountId. Must have "Edit Users" permission.
# Parameters
Name | Type | Description |
---|---|---|
AccountId | int | id of account associated with the user |
UserId | int | id of the user to be requested |
# Example
curl -X GET "https://api.controlbyweb.cloud/api/v1/accounts/{AccountId}/users/{UserId}" \
-H "Authorization: Bearer {authToken}"
# Response
[{
"id": 27,
"account_id": 7852,
"username": "fooBar",
"first_name": "Foo",
"last_name": "Bar",
"email": "fooBar@controlbyweb.com",
"email_verified_at": "2020-12-19T19:29:18.000000Z",
"account_admin": 1,
"terms_agreed": 1
}]
# new user
# POST /v1/accounts/{AccountId}/users
Creates a new user under the account with the AccountId. Must have "Add Users" permission.
# Parameters
Name | Type | Description |
---|---|---|
AccountId | int | id of account where new user will be created |
string | email of new user, must be unique | |
first_name | string | first name of new user |
last_name | string | last name of new user |
password | string | password of new user, can be changed by the new user later |
roles_permissions | array | roles and permissions for new user |
username | string | username of new user |
# Example
curl -X POST "https://api.controlbyweb.cloud/api/v1/accounts/{AccountId}/users" \
-H "Authorization: Bearer {authToken}" \
-d "email={email}" \
-d "first_name={first_name}" \
-d "last_name={last_name}" \
-d "password={password}" \
-d "roles_permissions={roles_permissions}" \
-d "username={username}" \
# Response
{
"message": "success"
}
# update user
# POST /v1/accounts/{AccountId}/users/{UserId}
Updates a user with UserId. User must belong to the account with AccountId, or to a descendant account. The "Edit Users" permission is required.
# Parameters
Name | Type | Description |
---|---|---|
authToken | string | Bearer auth Token recieved from call to get Token |
AccountId | int | id of account associated with the user |
UserId | int | id of the user to be requested, appended to the URL |
string | email to be set to the user | |
first_name | string | first name to be set to the user |
last_name | string | last name to be set to the user |
password | string | password to be set to the user |
roles_permissions | array | roles and permissions to be set to the user |
username | string | username to be set to the user |
# Example
curl -X POST "https://api.controlbyweb.cloud/api/v1/accounts/{AccountId}/users/{UserId}" \
-H "Authorization: Bearer {authToken}" \
-d "email={email}" \
-d "first_name={first_name}" \
-d "last_name={last_name}" \
-d "password={password}" \
-d "roles_permissions={roles_permissions}" \
-d "username={username}" \
# Response
{
"message": "success"
}
# update user password
Updates a user's password to the new password given. Requires AccountId and UserId to be set to "self". Currently users can only change their own passwords.
# POST /v1/accounts/{AccountId}/users/{UserId}/password
# Parameters
Name | Type | Description |
---|---|---|
AccountId | int | 'self' |
UserId | int | 'self' |
old_password | string | current password for account |
new_password | string | new password to be set for the user |
# Example
curl -X POST "https://api.controlbyweb.cloud/api/v1/accounts/{AccountId}/users/{UserId}/password" \
-H "Authorization: Bearer {authToken}" \
-d "old_password={old_password}" \
-d "new_password={new_password}" \
# Response
{
"message": "success"
}
# delete user
# POST /v1/accounts/{AccountId}/users/{UserId}/delete
Deletes a user with UserId from the account with AccountId. The "Delete Users" permission is required.
# Parameters
Name | Type | Description |
---|---|---|
AccountId | int | id of account associated with the user |
UserId | int | id of the user to be deleted |
# Example
curl -X DELETE "https://api.controlbyweb.cloud/api/v1/accounts/{AccountId}/users/{UserId}" \
-H "Authorization: Bearer {authToken}"
# Response
{
"message": "success"
}
# get permissions
# GET v1/permissions/
Returns a list of all possible permissions that can be given to a user. Permissions are broken up into roles all of which are encompassed by the "Admin" role. Roles are only used to orginize permissions. Users that have permission to "Edit Users" can edit the user's permissions. Users cannot edit their own permissions. The inital user for new cloud accounts will have all permissions.
# Parameters
Name | Type | Description |
---|---|---|
authToken | string | Bearer auth Token recieved from call to get Token |
# Example
curl -X GET "https://api.controlbyweb.cloud/api/v1/permissions" \
-H "Authorization: Bearer {authToken}"
# Response
[{
"id": "Admin",
"label": "Admin",
"children": [{
"id": "Device Operator",
"label": "Device Operator",
"children": [{
"id": "Setup Devices",
"label": "Setup Devices"
}, {
"id": "Control Devices",
"label": "Control Devices"
}, {
"id": "View Logged Data",
"label": "View Logged Data"
}]
}, {
"id": "Device Manager",
"label": "Device Manager",
"children": [{
"id": "Add Devices",
"label": "Add Devices"
}, {
"id": "Edit Devices",
"label": "Edit Devices"
}, {
"id": "Delete Devices",
"label": "Delete Devices"
}]
}, {
"id": "Device Tag Manager",
"label": "Device Tag Manager",
"children": [{
"id": "Add Device Tags",
"label": "Add Device Tags"
}, {
"id": "Edit Device Tags",
"label": "Edit Device Tags"
}, {
"id": "Delete Device Tags",
"label": "Delete Device Tags"
}]
}, {
"id": "DAT Urls Manager",
"label": "DAT Urls Manager",
"children": [{
"id": "Add DAT Urls",
"label": "Add DAT Urls"
}, {
"id": "Edit DAT Urls",
"label": "Edit DAT Urls"
}, {
"id": "Delete DAT Urls",
"label": "Delete DAT Urls"
}]
}, {
"id": "User Manager",
"label": "User Manager",
"children": [{
"id": "Add Users",
"label": "Add Users"
}, {
"id": "Edit Users",
"label": "Edit Users"
}, {
"id": "Delete Users",
"label": "Delete Users"
}]
}, {
"id": "Account Manager",
"label": "Account Manager",
"children": [{
"id": "Add Accounts",
"label": "Add Accounts"
}, {
"id": "Edit Accounts",
"label": "Edit Accounts"
}, {
"id": "Delete Accounts",
"label": "Delete Accounts"
}]
}, {
"id": "Remote Log Servers Manager",
"label": "Remote Log Servers Manager",
"children": [{
"id": "Add Remote Log Servers",
"label": "Add Remote Log Servers"
}, {
"id": "Edit Remote Log Servers",
"label": "Edit Remote Log Servers"
}, {
"id": "Delete Remote Log Servers",
"label": "Delete Remote Log Servers"
}]
}]
}]