Admin API - Query Users
Routes
Method | URI | Name | Summary |
---|---|---|---|
GET | /v1.0/admin/users | Get list of all users | |
GET | /v1.0/admin/users/count | Get count of all users | |
GET | /v1.0/admin/users/{user_id} | Get single user identity | |
POST | /v1.0/admin/users | Create a user | |
PUT | /v1.0/admin/users/{user_id} | Update User details | |
PUT | /v1.0/admin/users/{user_id}/permissions | Update user permissions to locations | |
DELETE | /v1.0/admin/users/{user_id}/permissions | Delete user permissions to locations | |
GET | /v1.0/admin/users?email={user_email} | Get single user by email | |
GET | /v1.0/admin/users?firstName={first_name} | Get All users that match by first name | |
GET | /v1.0/admin/users?lastName={last_name} | Get All users that match by last name |
Responses
Code | Status | Description | Has headers | Schema |
---|---|---|---|---|
200 | OK | Successful company retrieval | schema | |
400 | Bad Request | Bad request sent to server | schema | |
401 | Unauthorized | You are unauthorized | schema | |
403 | Forbidden | You are forbidden to perform this action | schema |
Get all Users
Example call (don't forget to swap in actual values for bold items):
curl --request GET --url https://api.mydevices.com/v1.0/admin/users \
--header 'authorization: Bearer MyAuthTokenHere' \
--header 'content-type: application/json'
Example result (abbreviated to show 2 users):
{
"count": 2,
"rows": [
{
"access": {
"manageGroupMembership": true,
"mapRoles": true,
"impersonate": false,
"view": true,
"manage": true
},
"id": "99e86f3f-87f4-4d7e-9e87-529e16f27438",
"emailVerified": false,
"totp": false,
"username": "robcan...@yopmail.com",
"lastName": "Canada4",
"disableableCredentialTypes": [
"password"
],
"email": "robcan...@yopmail.com",
"firstName": "Rob",
"createdTimestamp": 1557270232546,
"notBefore": 0,
"attributes": {
"invite_code": [
"null"
],
"invite_timestamp": [
"1557270232528"
],
"invite_status": [
"CREATED"
],
"accepted_timestamp": [
"1557270232528"
],
"is_invited": [
"false"
],
"phone_number": [
"111"
]
},
"enabled": true,
"requiredActions": []
},
{
"access": {
"manageGroupMembership": true,
"mapRoles": true,
"impersonate": false,
"view": true,
"manage": true
},
"id": "99e86f3f-87f4-4d7e-9e87-529e16f27438",
"emailVerified": false,
"totp": false,
"username": "robcan...@yopmail.com",
"lastName": "Canada4",
"disableableCredentialTypes": [
"password"
],
"email": "robcan...@yopmail.com",
"firstName": "Rob",
"createdTimestamp": 1557270232546,
"notBefore": 0,
"attributes": {
"invite_code": [
"null"
],
"invite_timestamp": [
"1557270232528"
],
"invite_status": [
"CREATED"
],
"accepted_timestamp": [
"1557270232528"
],
"is_invited": [
"false"
],
"phone_number": [
"111"
]
},
"enabled": true,
"requiredActions": []
}
]
}
Get User
curl --request GET \
--url https://api.mydevices.com/v1.0/admin/users/b19c2c9d-0000-0000-0000-61113c157c54 \
--header 'Authorization: Bearer Token'
Response
{
"access": {
"manageGroupMembership": true,
"mapRoles": true,
"impersonate": false,
"view": true,
"manage": true
},
"id": "99e86f3f-87f4-4d7e-9e87-529e16f27438",
"emailVerified": false,
"totp": false,
"username": "robcan...@yopmail.com",
"lastName": "Canada4",
"disableableCredentialTypes": [
"password"
],
"email": "robcan...@yopmail.com",
"firstName": "Rob",
"createdTimestamp": 1557270232546,
"notBefore": 0,
"attributes": {
"invite_code": [
"null"
],
"invite_timestamp": [
"1557270232528"
],
"invite_status": [
"CREATED"
],
"accepted_timestamp": [
"1557270232528"
],
"is_invited": [
"false"
],
"phone_number": [
"111"
]
},
"enabled": true,
"requiredActions": []
}
Owner/Admin for Location
Example of how to find the Owner/Admin contact for a Location. This may be useful for those who are putting together a billing system and need to know the Owner contact for a location so that you can match an account with its owner.
Currently looking up this information requires you to first obtain the user_id for the Location in question. You can then use a call to obtain the information. Start by making a call to obtain Companies and then find the corresponding user_id for that company.
{
"id": 1265,
"name": "SecondCo",
"industry": "[\"Food & Beverage\"]",
"address": "101 N Citrus Ave",
...
"user_id": "9c60c56b-d468-4f75-ac76-7670bf425375",
"application_id": "neosmart",
...
}
Then make a call to Users, but look up a specific user id.
curl --request GET --url https://auth.mydevices.com/auth/admin/realms/MyRealm/users/9c60c56b-d468-4f75-ac76-7670bf425375 \
--header 'authorization: Bearer MyAuthTokenHere' \
--header 'content-type: application/json'
Example Response:
{
"id": "9c60c56b-d468-4f75-ac76-7670bf425375",
"createdTimestamp": 1560290037034,
"username": "jdoe-pp061119b@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "John",
"lastName": "Doe",
"email": "jdoe-pp061119b@yopmail.com",
"attributes": {
"accepted_timestamp": [
"1560290037021"
],
"phoneNumber": [
"7205550100"
],
"is_invited": [
"false"
],
"invite_timestamp": [
"1560290037021"
],
"phone_number": [
"7205550100"
],
"invite_status": [
"CREATED"
]
...
}
}
Create User
Example Request:
curl --request POST \
--url https://api.mydevices.com/v1.0/admin/users?notify=true&application_id=your_application_id \
--header 'Authorization: Bearer Token'
--data \
'{
"email": "testiotina0032@mailinator.com",
"password": "testiotina0032", // optional
"first_name": "Test", // optional
"last_name": "Iotina", // optional
"locale": "en-us", // optional
"phone_number": "12345678910" // optional
}'
{
"id": "1880d6e5-a832-474b-b974-9c3206eaff86",
"federated_user_id": "ec68eec3-98c9-4a5f-ab43-4643b3ff9143",
"tina_user_id": "1880d6e5-a832-474b-b974-9c3206eaff86",
"enabled": true,
"email": "testiotina0032@mailinator.com",
"username": "testiotina0032@mailinator.com",
"locale": "en-us",
"phone_number": "12345678910",
"is_invited": "false",
"invite_status": "CREATED",
"accepted_timestamp": "1643404400143",
"invite_timestamp": "1643404400143",
"attributes": {
"locale": [
"en-us"
],
"phoneNumber": [
"12345678910"
],
"is_invited": [
"false"
],
"invite_status": [
"CREATED"
],
"accepted_timestamp": [
"1643404400143"
],
"invite_timestamp": [
"1643404400143"
]
}
}
Update User
Example Request:
curl --request PUT \
--url https://api.mydevices.com/v1.0/admin/users/b19c2c9d-0000-0000-0000-61113c157c54 \
--header 'Authorization: Bearer Token'
--data 'UserModelJson'
{
"access": {
"manageGroupMembership": true,
"mapRoles": true,
"impersonate": false,
"view": true,
"manage": true
},
"emailVerified": false,
"totp": false,
"username": "robcan...@yopmail.com",
"lastName": "Canada4",
"disableableCredentialTypes": [
"password"
],
"email": "robcan...@yopmail.com",
"firstName": "Rob",
"createdTimestamp": 1557270232546,
"notBefore": 0,
"attributes": {
"invite_code": [
"null"
],
"invite_timestamp": [
"1557270232528"
],
"invite_status": [
"CREATED"
],
"accepted_timestamp": [
"1557270232528"
],
"is_invited": [
"false"
],
"phone_number": [
"111"
]
},
"enabled": true,
"requiredActions": []
}
Update User Permissions to Locations
Example Request:
curl --request PUT \
--url https://api.mydevices.com/v1.0/admin/users/b19c2c9d-0000-0000-0000-61113c157c54/permissions \
--header 'Authorization: Bearer Token'
--data
'[
{
"location_id": 10116,
"permission": "view"
},
{
"location_id": 10117,
"permission": "edit"
}
]'
Delete User Permissions to Locations
Example Request:
curl --request DELETE \
--url https://api.mydevices.com/v1.0/admin/users/b19c2c9d-0000-0000-0000-61113c157c54/permissions \
--header 'Authorization: Bearer Token'
--data
'[
{
"location_id": 10116
},
{
"location_id": 10117
}
]'
Query Users
Example Request:
Queries user by email.
curl --request GET \
--url https://api.mydevices.com/v1.0/admin/users?email={user_email} \
--header 'Authorization: Bearer Token'
{
"count": 1,
"rows": [
{
"id": "04e5fafc-c2a7-425b-8378-7c3f7baf6726",
"createdTimestamp": 1601575453318,
"username": "joe@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Joe",
"lastName": "Doe",
"email": "joe@yopmail.com",
"attributes": {
"adminHasOrgRole": [
"false"
],
"adminHasRole": [
"false"
],
"adminHasAppRole": [
"false"
]
},
"disableableCredentialTypes": [],
"requiredActions": [
"record-user-stats-action"
],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"federated_user_id": "04e5fafc-c2a7-425b-8378-7c3f7baf6726",
"tina_user_id": null
}
]
}
Query for user by first name
curl --request GET \
--url https://api.mydevices.com/v1.0/admin/users?firstName={first_name} \
--header 'Authorization: Bearer Token'
{
"count": 4,
"rows": [
{
"id": "3e8811bf-c0b6-4b26-82db-5f789a39c40f",
"createdTimestamp": 1572518751722,
"username": "guardian@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Larry",
"lastName": "Beger",
"email": "guardian@yopmail.com",
"attributes": {
"login_count": [
"1"
],
"sign_up_source": [
"iot-console"
],
"last_login": [
"1572894057437"
],
"first_login": [
"1572894057437"
]
},
"disableableCredentialTypes": [],
"requiredActions": [],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"federated_user_id": "3e8811bf-c0b6-4b26-82db-5f789a39c40f",
"tina_user_id": null
},
{
"id": "b1199ec5-4e0b-4c55-b656-c5d60363839d",
"createdTimestamp": 1580345304414,
"username": "sensorworks.mydevices.com@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Larry",
"lastName": "Liang",
"email": "sensorworks.mydevices.com@yopmail.com",
"disableableCredentialTypes": [],
"requiredActions": [
"record-user-stats-action"
],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"attributes": {},
"federated_user_id": "b1199ec5-4e0b-4c55-b656-c5d60363839d",
"tina_user_id": null
},
{
"id": "e2e1aa70-ae90-44bf-900e-2d044ac33177",
"createdTimestamp": 1580345386600,
"username": "sensorworks@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Larry",
"lastName": "Liang",
"email": "sensorworks@yopmail.com",
"disableableCredentialTypes": [],
"requiredActions": [
"record-user-stats-action"
],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"attributes": {},
"federated_user_id": "e2e1aa70-ae90-44bf-900e-2d044ac33177",
"tina_user_id": null
}
]
}
Query for user by last name
curl --request GET \
--url https://api.mydevices.com/v1.0/admin/users?firstName={last_name} \
--header 'Authorization: Bearer Token'
{
"count": 3,
"rows": [
{
"id": "ba158f55-8c63-444c-ac4b-129ad6708819",
"createdTimestamp": 1558714636482,
"username": "rssi052419stag@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Mike",
"lastName": "Richards",
"email": "rssi052419stag@yopmail.com",
"attributes": {
"requiredActions": [
"UPDATE_PASSWORD",
"UPDATE_PROFILE"
],
"invite_status": [
"PENDING"
],
"invite_code": [
"KAX73JHU"
],
"is_invited": [
"true"
],
"invite_timestamp": [
"1558714636464"
]
},
"disableableCredentialTypes": [],
"requiredActions": [
"record-user-stats-action"
],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"federated_user_id": "ba158f55-8c63-444c-ac4b-129ad6708819",
"tina_user_id": "ba158f55-8c63-444c-ac4b-129ad6708819"
},
{
"id": "4b2d5eb9-e92a-430a-8e46-dcbdb1e0f167",
"createdTimestamp": 1545180144313,
"username": "rsss1218c@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Mike",
"lastName": "Richards",
"email": "rsss1218c@yopmail.com",
"attributes": {
"requiredActions": [
"UPDATE_PASSWORD",
"UPDATE_PROFILE"
],
"invite_code": [
"0HNAVLXY"
],
"invite_status": [
"PENDING"
],
"is_invited": [
"true"
],
"invite_timestamp": [
"1545180144287"
]
},
"disableableCredentialTypes": [],
"requiredActions": [
"record-user-stats-action"
],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"federated_user_id": "4b2d5eb9-e92a-430a-8e46-dcbdb1e0f167",
"tina_user_id": "4b2d5eb9-e92a-430a-8e46-dcbdb1e0f167"
},
{
"id": "21296cae-e462-46ea-9969-a82afeedd727",
"createdTimestamp": 1537309553453,
"username": "rst0918e@yopmail.com",
"enabled": true,
"totp": false,
"emailVerified": false,
"firstName": "Mike",
"lastName": "Richards",
"email": "rst0918e@yopmail.com",
"attributes": {
"accepted_timestamp": [
"1537309553442"
],
"login_count": [
"2"
],
"phoneNumber": [
"6505211135"
],
"sign_up_source": [
"iotinabox"
],
"is_invited": [
"false"
],
"last_login": [
"1537402598708"
],
"invite_timestamp": [
"1537309553442"
],
"phone_number": [
"6505211135"
],
"invite_code": [
"null"
],
"invite_status": [
"CREATED"
],
"first_login": [
"1537395392918"
]
},
"disableableCredentialTypes": [],
"requiredActions": [],
"notBefore": 0,
"access": {
"manageGroupMembership": true,
"view": true,
"mapRoles": true,
"impersonate": true,
"manage": true
},
"application_id": "iotinabox",
"federated_user_id": "21296cae-e462-46ea-9969-a82afeedd727",
"tina_user_id": null
}
]
}