Users

These are the main user accounts that give users access to the system. The API will allow for user account changes and access restrictions as needed.

User Object

The object has the following properties:

NameTypeRead OnlyMandatoryMax Len.Notes
id integer yes no   Automatically assigned when creating a user
user_type string no yes   The user type must be either 'Admin', 'Director', 'Manager' or 'User'
user_status_id character no yes 1 The user_status_id can only be (A)ctive or (L)ocked
first_name string no yes 50 The first name of the user
last_name string no no 50 The last name of the user
email string no yes 150 Must be a valid email address and will be used for the login
password string no yes 20 The password is only required when adding a new user and cannot be changed via the API
can_manage_users boolean no yes   This field is only relevant for user types of 'Manager' and will allow a manager to admin the users within the manager's group items
can_admin_settings boolean no yes   This field is only relevant for user types of 'Admin' and will grant 'Settings' and 'Billing' access
last_login_at datetime yes no   The UTC date and time the user last logged in
last_password_changed_at datetime yes no   The UTC date and time the user last changed their password
created_at datetime yes no   The UTC date and time the user was created
updated_at datetime yes no   The UTC date and time of the last update of the user

JSON Example

{
  "id":                       1234,
  "user_type":                "Manager",
  "user_status_id":           "A",
  "first_name":               "Jim",
  "last_name":                "Jones",
  "email":                    "jim@simplekpi.com",
  "password":                 null,
  "can_manage_users":         true,
  "can_admin_settings":       false,
  "last_login_at":            "2012-11-10T14:35:00",
  "last_password_changed_at": "2012-12-10T14:35:00",
  "created_at":               "2012-09-10T14:35:00",
  "updated_at":               "2012-11-30T11:01:00"
}

XML Example

<User xmlns="http://schemas.datacontract.org/2004/07/SimpleKPI.Application.Areas.Api.Models"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <id>1234</id>
  <user_type>Manager</user_type>
  <user_status_id>A</user_status_id>
  <first_name>Jim</first_name>
  <last_name>Jones</last_name>
  <email>jim@simplekpi.com</email>
  <password>null</password>
  <can_manage_users>true</can_manage_users>
  <can_admin_settings>false</can_admin_settings>
  <last_login_at>2012-11-10T14:35:00</last_login_at>
  <last_password_changed_at>2012-12-10T14:35:00</last_password_changed_at>
  <created_at>2012-09-10T14:35:00</created_at>
  <updated_at>2012-11-30T11:01:00</updated_at>
</User>

 

Get all Users

GET /api/users

Using curl

curl https://{subdomain}.simplekpi.com/api/users
  -v -u {email_address}:{token}

Example Response

Status: 200 OK
[
  {
    "id":                       1234,
    "user_type":                "Manager",
    "user_status_id":           "A",
    "first_name":               "Marsy",
    "last_name":                "Barr",
    "email":                    "marsy@simplekpi.com",
    "password":                 null,
    "can_manage_users":         true,
    "can_admin_settings":       false,
    "last_login_at":            "2012-11-10T14:35:00",
    "last_password_changed_at": "2012-12-10T14:35:00",
    "created_at":               "2012-09-10T14:35:00",
    "updated_at":               "2012-11-30T11:01:00"
  },
  {
    "id":                       1235,
    "user_type":                "User",
    "user_status_id":           "A",
    "first_name":               "Toby",
    "last_name":                "Lerone",
    "email":                    "toby@simplekpi.com",
    "password":                 null,
    "can_manage_users":         false,
    "can_admin_settings":       false,
    "last_login_at":            "2013-01-10T15:06:00",
    "last_password_changed_at": "2013-01-10T15:36:00",
    "created_at":               "2012-11-02T15:09:00",
    "updated_at":               "2013-01-10T15:36:00"
  }
]

 

Get a User

GET /api/users/{id}

Using curl

curl https://{subdomain}.simplekpi.com/api/users/{id}
  -v -u {email_address}:{token}

Example Response

Status: 200 OK
{
  "id":                       1234,
  "user_type":                "Manager",
  "user_status_id":           "A",
  "first_name":               "Jim",
  "last_name":                "Jones",
  "email":                    "jim@simplekpi.com",
  "password":                 null,
  "can_manage_users":         true,
  "can_admin_settings":       false,
  "last_login_at":            "2012-11-10T14:35:00",
  "last_password_changed_at": "2012-12-10T14:35:00",
  "created_at":               "2012-09-10T14:35:00",
  "updated_at":               "2012-11-30T11:01:00"
}

 

Add a User

POST /api/users

Using curl

curl https://{subdomain}.simplekpi.com/api/users
  -H "Content-Type: application/json"
  -d '{"user_type": "Manager", "user_status_id": "A", "first_name": "Jim", "last_name": "Jones",
       "email": "jim@simplekpi.com", "password": "Password1234", "can_manage_users": true,
       "can_admin_settings": false}'
  -v -u {email_address}:{token} -X POST

Example Response

Status: 201 Created
Location: https://{subdomain}.simplekpi.com/api/users/{id}
{
  "id":                       1234,
  "user_type":                "Manager",
  "user_status_id":           "A",
  "first_name":               "Jim",
  "last_name":                "Jones",
  "email":                    "jim@simplekpi.com",
  "password":                 null,
  "can_manage_users":         true,
  "can_admin_settings":       false,
  "last_login_at":            "2012-11-10T14:35:00",
  "last_password_changed_at": "2012-12-10T14:35:00",
  "created_at":               "2012-09-10T14:35:00",
  "updated_at":               "2012-11-30T11:01:00"
}

 

Update a User

PUT /api/users/{id}

Using curl

curl https://{subdomain}.simplekpi.com/api/users/{id}
  -H "Content-Type: application/json"
  -d '{"id": 1234, "user_type": "Manager", "user_status_id": "A", "first_name": "Jim", "last_name": "Jones",
       "email": "jim@simplekpi.com", "can_manage_users": true, "can_admin_settings": false}'
  -v -u {email_address}:{token} -X PUT

Example Response

Status: 200 OK
{
  "id":                       1234,
  "user_type":                "Manager",
  "user_status_id":           "A",
  "first_name":               "Jim",
  "last_name":                "Jones",
  "email":                    "jim@simplekpi.com",
  "password":                 null,
  "can_manage_users":         true,
  "can_admin_settings":       false,
  "last_login_at":            "2012-11-10T14:35:00",
  "last_password_changed_at": "2012-12-10T14:35:00",
  "created_at":               "2012-09-10T14:35:00",
  "updated_at":               "2012-11-30T11:01:00"
}

 

Delete a User

DELETE /api/users/{id}

Using curl

curl https://{subdomain}.simplekpi.com/api/users/{id}
  -v -u {email_address}:{token}

Example Response

Status: 200 OK