Users
To create a new user you must include the following fields in your post:
- alarm_email: Boolean set to 0 or 1 which controls whether the user will receive alarm notification by email.
- alarm_sms: Boolean set to 0 or 1 which controls whether the user will receive alarm notification by SMS.
- company_id: Number that should match your Company ID.
- email: String for the user's email address.
- member_level_id: Number representing the user's level, see the User Permission Levels table below for details.
- name: String for the user's name.
- sms (optional): String for the user's phone number for receiving SMS alarm notifications. Must include country code in the following format "+1 555 555 5555".
- phone (optional): String for the user's phone number. Must include country code in the following format "+1 555 555 5555".
- station_ids: Array of numbers. Each number in the array should correspond to a station id that you want the user to have access to. This array should be empty for admin users (member_level_id: 1) because they will have access to all stations.
- status:: Boolean set to 0 or 1 which controls whether the user's account is active or disabled.
User Permission Levels
Permission | member_level_id: 2 | member_level_id: 3 | member_level_id: 4 |
---|---|---|---|
View admin defined stations | ✓ | ✓ | ✓ |
Create/Update/Delete admin defined stations | ✓ | ✓ | |
Create/Update/Delete projects | ✓ | ||
Create/Update/Delete users | ✓ |
Creating a User
POST route:
http://api.stevens-connect.com/user
Example for creating a user:
curl -H 'Authorization: bearer eyJ0eXAiOiJKV1Q...' -d "name=UserName&alarm_email=0&alarm_sms=0&company_id=32&email=usersemail@emaildomain.com&station_ids[]=1151&station_ids[]=1333&status=1&member_level_id=2" -X POST http://api.stevens-connect.com/user
POST response example:
{
errors: false,
data: {
user: {
alarm_email: 0,
alarm_sms: 0,
company_id: 00,
email: "my_new_user@email.com",
id: 356,
member_level_id: 4,
name: "New Name",
phone: "+1 555 123 4567",
require_password_reset: 1,
sms: "+1 555 123 4567",
status: 1,
user_stations: [
{
id: 10156,
user_id: 356,
station_id: 1151,
created_at: "2018-10-23 15:39:41",
updated_at: "2018-10-23 15:39:41"
},
{…},
{…}
]
}
}
}
Updating a User
All fields are optional for updates.
PATCH route:
http://api.stevens-connect.com/user/<user_id>
Example for updating a user's name, email and member level where 'xxx' represents the user's ID that you wish to update:
curl -H 'Authorization: bearer eyJ0eXAiOiJKV1Q...' -d "name=UpdatedUserName&company_id=32&email=updatedemail@emaildomain.com&member_level_id=" -X PATCH http://api.stevens-connect.com/user/xxx
Deleting a User
DELETE route:
http://api.stevens-connect.com/user/<user_id>
Example for deleting a user where 'xxx' represents the user's ID that you wish to delete:
curl -H 'Authorization: bearer eyJ0eXAiOiJKV1Q...' -X DELETE http://api.stevens-connect.com/user/xxx