iotoms Docs

Update a user

PUT
/api/v1/management/users/{id}

Updates a back-office user; only the fields you send change. Covers name, email, status, role, password (your own requires currentPassword) and PIN access. You cannot manage a user whose role has more access than your own.

How to use it

  1. Get the user ID from List users and send only the fields to change.
  2. To change your own password also send currentPassword; an administrator resetting someone else's password does not need it.
  3. A role change is recorded in the role audit trail. You cannot edit a user, or assign a role, with more access than your own role.

Authorization

BearerAuth
headerAuthorizationBearer <JWT>

Path Parameters

id*integer

ID of the record.

Formatint64

Request Body

application/json
  1. body
password?|

New password, only to change it. At least 8 characters with upper and lower case letters, a digit and a special character (@$!%*?&._^#).

Match^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&._^#])[A-Za-z\d@$!%*?&._^#]+$
Length8 <= length <= 255
currentPassword?|

Current password. Required only when you change your own password; ignored when resetting someone else's.

enablePin?|

Turn PIN access on or off. Omit to leave unchanged; turning it off removes the stored PIN.

pin?|

New PIN, 4 to 6 digits. Required when enabling PIN access and no PIN is stored yet.

Match^\d{4,6}$
roleId?|

New role ID from List roles. Omit to keep the current role. The change is recorded in the role audit trail.

Formatint64
firstName?|

New first name, up to 255 characters. Omit to keep.

Length0 <= length <= 255
lastName?|

New last name, up to 255 characters. Omit to keep.

Length0 <= length <= 255
email?|

New email address; must be a valid email. Omit to keep.

status?|

Account status: active or inactive (case-insensitive). Omit to keep.

Match^(?i)(active|inactive)$

Response Body

OK

*/*
  1. response
status*string

Outcome of the call: SUCCESS when the request worked, ERROR when it did not.

message*string

Short human-readable message describing the result, for logs or display; do not parse it.

data?

The user's profile as it now stands. Passwords and PINs are never returned.

Example Request
curl -X PUT 'https://beta.iotoms.com/api/v1/management/users/0' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "status": "string",  "message": "string",  "data": {    "userId": 0,    "username": "string",    "roleId": 0,    "enablePin": true,    "firstName": "string",    "lastName": "string",    "email": "string",    "passwordUpdatedOn": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "status": "string"  }}