API Example User Admin

NOTE: We do NOT recommend attempting to post user permission groups or office settings. This process is difficult to accomplish through the API. We recommend that you simply post / create the user and then your Org Admin will have to assign permissions.

POST https://securelb.trackerproducts.com/api/users/

Sample format for submit

{

"firstName": "Bob",

"middleName": "",

"lastName": "Smith",

"organizationId": X,

"officeId": XX,

"email": "bob.smith@invalidemail.com",

"mobilePhone": "123-456-7891",

"otherphone": "",

"active": true,

"emailDisable": false,

"groups":[ ],

"personFormData":[ ]

}

X = Org ID found in Settings > Offices XX = Org ID found in Settings > Offices

After your post, you will receive an ID and a GUID in the response. You will need this for POSTing permissions for this new user.

"id": 27667,

"guid": "65439632-0e4f-e811-9ab8-303a64ac4dc3",

GETing Permissions Groups

https://securelb.trackerproducts.com/api/groups


{

"id": 1390,

"name": "Power User",

"description": "Power Users (All except Admin)",

"organizationId": 371,

"organizationName": "Free Org Test",

"hasUsers": true

},


POSTing back User along with Permission Group for that user

https://securelb.trackerproducts.com/api/groups/userperms

We can now set permissions to one of the above groups.


{"UserIds":[27668,27667],

"OfficeToGroups":[{

"officeId":602,

"officeName":"Default Office",

"groups":

[

{

"id":1390,

"name":"Power User",

"description":"Power Users (All except Admin)",

"organizationId":371,

"organizationName":"Free Org Test",

"hasUsers":true,

"route":"groups",

"reqParams":null,

"restangularized":true,

"fromServer":true,

"parentResource":null,

"restangularCollection":false,

"selected":false,

"selectAll":false

},


Retrieving user data for a single user

GET

https://securelb.trackerproducts.com/api/users/1

X = id - NOTE This is the id of the user record, not the PersonId which is a property in the user record.

This will return the user record with an id of 1, which will look like the following:

{

"id": 1,

"guid": "adf879d3-bc5b-e511-a0e6-06e9f5d49c4d",

"email": "jsparrow@trackerproducts.com",

"mobilePhone": "088-346-9605",

"otherPhone": "088-346-9605",

"isAdmin": true,

"hasReservedLicense": true,

"firstName": "Jack",

"middleName": "3176D103FF",

"lastName": "Sparrow",

"name": "Jack 3176D103FF Sparrow",

"personId": 1,

"organizationId": 1,

"organizationName": null,

"officeId": 1,

"photoId": 1,

"photoUrl": null,

"createdDate": "2015-06-26T15:31:01.2524727+00:00",

"lastLoginDate": "2018-07-25T11:29:47.8147558+00:00",

"loginCount": 2775,

"active": true,

"note": null,

"dateFormat": "mediumDate",

"dateTimeFormat": "medium",

"jwtToken": "eyJ0eXAiOi.............",

"isOrgAdmin": true,

"isGoogleAuthenticatorEnabled": false,

"googleAuthenticatorSecretKey": null,

"emailDisable": true,

"groups": [


],

"userGroups": [


],

"personFormData": null

}


If you would like to see permission groups as part of the return data, groups=true is added to the request:

https://securelb.trackerproducts.com/api/users/1?groups=true


Retrieving a list of users

GET

https://securelb.trackerproducts.com/api/users/search

Here is an example of the search request body:

{

"page": 0,

"count": 100,

"searchString": "User",

"orderBy": "OfficeName",

"orderByAsc": true,

"officeId": 0,

"onlyActiveUsers": true

}

In the above example we are returning all of the active users in the organization.


Example how to search for a user using email:


https://securelb.trackerproducts.com/api/users/search


Here is the body of my search:

{

"page": 0,

"count": 100,

"searchString": "someemail@someemail.com",

"orderBy": "MobilePhone",

"orderByAsc": true,

"officeId": 0,

"onlyActiveUsers": true

}


User Typeahead search

Another search option is to use the typeahead search endpoint: http://securelb.trackerproducts.com/api/users/typeahead?search=mike


This endpoint will search the following fields:

- First Name

- Middle Name

- Last Name

- Email

- Alias (this property is a part of the person record associated with a user)


Here is an example of using this endpoint:

http://securelb.trackerproducts.com/api/users/typeahead?search=mike


will return an array of users along with a count of the users returned by the query in the following format:

{

"users": [

{

"id": 17663,

"text": " Mike Singleton (msingleton@trackerproducts.com)"

}

],

"usersCount": 1

}


Here is an example of searching by email address:

http://securelb.trackerproducts.com/api/users/typeahead?search=tracker


which returns the following:

{

"users": [

{

"id": 1,

"text": " Jack 3176D103FF Sparrow (jsparrow@trackerproducts.com)"

},

{

"id": 17663,

"text": " Mike Singleton (msingleton@trackerproducts.com)"

},

{

"id": 17664,

"text": " Victor Frankenstein (1msingleton@trackerproducts.com)"

}

],

"usersCount": 3

}

Other User Controller Endpoints



Get User By UserId

GET https://securelb.trackerproducts.com/api/users/####

where #### is the userId


Get Current User

GET https://securelb.trackerproducts.com/api/users/currentUser


Get User Without JwtToken

For users integrating with the API, it is sometimes beneficial to get user data without the jwtToken:

https://securelb.trackerproducts.com/api/users/getUserWithoutJwtToken/####

where #### is the userId

If you would like to see permission groups as part of the return data, groups=true is added to the request:

GET https://securelb.trackerproducts.com/api/users/getUserWithoutJwtToken/####?groups=true

Here is the return data from this request:

{

"id": 17663,

"guid": "bf54d419-d50d-e811-9ab0-303a64ac4dc3",

"email": "msingleton@trackerproducts.com",

"mobilePhone": "222-2222",

"otherPhone": "",

"isAdmin": false,

"hasReservedLicense": false,

"firstName": "Mike",

"middleName": "",

"lastName": "Singleton",

"name": "Mike Singleton",

"personId": 1634850,

"organizationId": 1,

"organizationName": "Tracker Products",

"officeId": 1,

"photoId": 17663,

"photoUrl": null,

"createdDate": "2018-02-09T20:09:15.7175598+00:00",

"lastLoginDate": "2018-11-27T18:12:54.1948624+00:00",

"loginCount": 347,

"active": true,

"note": null,

"dateFormat": "longDate",

"dateTimeFormat": "medium",

"jwtToken": "",

"isOrgAdmin": false,

"isGoogleAuthenticatorEnabled": false,

"googleAuthenticatorSecretKey": null,

"emailDisable": false,

"groups": [

"SAFE Digital Forensics Tracking-445 Office: Power User",

"SAFE Digital Forensics Tracking-SAFE Digital Forensics Tracking - Honk Kong: Power User",

"SAFE Digital Forensics Tracking-SAFE Digital Forensics Tracking - London: Power User",

"SAFE Digital Forensics Tracking-SAFE Digital Forensics Tracking - New York: Power User",

"SAFE Digital Forensics Tracking-SAFE Digital Forensics Tracking - Vegas:\ Power User",

"Smns (Assets)-506 Office: Power User",

"Smns (Assets)-507 Office: Power User",

"Smns (Assets)-509 Office: Power User",

"Smns (Assets)-EUC Windows: Power User",

"Tracker Products-1 Office: Basic User",

"Tracker Products-231 Office: Basic User"

],

"userGroups": [

{

"id": 16,

"text": "Sessions User 2 Group"

}

],

"personFormData": null,

"languageTemplateId": null

}