Users¶
Create New User¶
- POST /_config/users/¶
Description Creates a new user with a specific role, for example, site-admin, plant-admin, or general-user.
HTTP Method POST
Endpoint:
/_config/users/
Request Header
Authorization
Basic TokenRequest Parameters
Body Parameters
plant_id
(string, optional): The ID of the Plant (plant_id is not required if the user creates a site-admin).site_id
(string, optional): The ID of the Site (site_id is required only if the user creates a site-admin).username
(string, required): The username must be unique (username will be checked while creating the user).mobile_number
(string, required): The user’s mobile number.country_code
(string, required): The country dialing code.user_type
(string, required): User type (previously known as role_name) (e.g., “site-admin”, “plant-admin”).password
(string, optional): New login password (if not provided, an auto-generated password will be sent to the user’s email).modules
(object, optional): Names of modules to grant access to (e.g., “Condition Monitoring”, “Alerting”, etc.).
Sample Request
curl -X POST \ 'https://app.4pointx.com/_config/users/' \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic <token>' \ -d '{ "site_id": "b92f2836-288b-4b3e-b396-4f86d6f14274", "plant_id": "df42ab44-476b-4937-9c8e-6f4787cbf507", "username": "user@email.com", "mobile_number": "1234567890", "country_code": "+91", "password": "xZsl5@7cYuop", "user_type": "general-user", "modules": [ "Alerting", "Configuration" ] }'
Sample Response
Success
{ "status": "CREATED", "message": " 'user@email.com' created." }
Error
{ "error": { "status": 401, "message": "Unauthorized access" } }
{ "error": { "status": 400, "message": "Invalid content type" } }
{ "error": { "status": 400, "message": "Insufficient inputs" } }
{ "error": { "status": 403, "message": "Unauthorized operation!, can't create user" } }
{ "error": { "status": 409, "message": "User already exists" } }
Delete User¶
- DELETE /_config/users/<username>¶
Description Deletes a user account along with the associated role.
HTTP Method DELETE
Endpoint
/_config/users/<username>
Request Header
Authorization
Basic TokenRequest Parameters
URL Parameters
username
(string, required): The username of the user.
Sample Request
curl -X DELETE 'https://app.4pointx.com/_config/users/user@email.com' -H 'Authorization: Basic <token>'
Sample Response
Success
{ "status": "OK", "message": "'user@email.com' deleted." }
Error
{ "error": { "status": 401, "message": "Unauthorized access" } }
{ "error": { "status": 404, "message": "User not found!" } }
{ "error": { "status": 400, "message": "Invalid operation, can't delete user" } }
{ "error": { "status": 403, "message": "Unauthorized operation!, can't delete user" } }
Updating User¶
- PUT /_config/users/<username>¶
Description Updates the details of an existing user.
HTTP Method PUT
Endpoint
/_config/users/<username>
Request Header
Authorization
Basic TokenRequest Parameters
Body Parameters
plant_id
(string, optional): The ID of the Plant (plant_id is not required only for site-admin).site_id
(string, optional): The ID of the Site (site_id is required only if user_type is updated to site-admin).username
(string, required): Unique username of the user.mobile_number
(string, required): User’s mobile number.country_code
(string, required): The Country dialing Code.user_type
(string, required): User type (previously know as role_name) (e.g. “site-admin”, “plant-admin”).password
(string, required): New Login Password (if null password remains same).modules
(object, optional): Names of modules to grant access to (e.g. “Condition Monitoring”, “Alerting” etc).
Sample Request
curl -X PUT \ 'https://app.4pointx.com/_config/users/<username>' \ -H 'Content-Type: application/json' \ -H 'Authorization: Basic <token>' \ -d '{ "site_id": "b92f2836-288b-4b3e-b396-4f86d6f14274", "username": "user@email.com", "mobile_number": "9876543210", "country_code": "+91", "password": "xZsl5@7cYuop", "user_type": "site-admin", "modules": [] }'
Sample Response
Success
{ "status": "OK", "message": "'user@email.com' updated." }
Error
{ "error": { "status": 401, "message": "Unauthorized access" } }
{ "error": { "status": 400, "message": "Invalid content type" } }
{ "error": { "status": 400, "message": "Insufficient inputs" } }
{ "error": { "status": 403, "message": "Unauthorized operation!, can't update User" } }
{ "error": { "status": 404, "message": "User not found" } }
Fetch User¶
- GET /_config/users/<username>¶
Description Returns user details.
HTTP Method GET
Endpoint
/_config/users/<username>
Request Header
Authorization
Basic TokenRequest Parameters
URL Parameters
username
(string, required): The name of the user.
Sample Request
curl -X GET 'https://app.4pointx.com/_config/users/user@email.com' -H 'Authorization: Basic <token>'
Sample Response
Success
{ "hash":"", "reserved":false, "hidden":false, "backend_roles":[], "attributes":{ "site_id":"d2e66edd-f13f-4d00-a7b5-8cab9ef4488d", "plant_id":"*", "user_type":"site-admin", "created_at":"1692685495520", "country_code":"+91", "mobile_number":"1234567890", "last_login_time":"1694849374477", "site_name":"Demo Site", "plant_name":null }, "opendistro_security_roles":[ ], "static":false }
Error
{ "error": { "status": 401, "message": "Unauthorized access" } }
{ "error": { "status": 404, "message": "User not found!" } }
Fetch List of Users¶
- GET /_config/users/_list¶
Description Returns a list of user details.
HTTP Method GET
Endpoint
/_config/users/_list
Request Header
Authorization
Basic TokenRequest Parameters
Query Parameters
plant_id
(string, optional): The ID of the Plant.site_id
(string, optional): The ID of the Site.
Note
Any user_type other than SaaS admin will need the input of query parameters. For SaaS admins, this is optional.
Sample Request
curl -X GET 'https://app.4pointx.com/_config/users/_list?site_id=b92f2836-288b-4b3e-b396-4f86d6f14274&plant_id=df42ab44-476b-4937-9c8e-6f4787cbf507' -H 'Authorization: Basic <token>'
Sample Response
Success
[ { "username": "site@admin.test", "country_code": "+91", "mobile_number": "7894561230", "site_id": "7484c0b9-bc61-4da3-8e17-a0d1ef3d59ce", "plant_id": "*", "user_type": "site-admin", "site_name": "JSW VJNR", "plant_name": null, "created_at": "1692943073373", "last_login_time": "1692945669424", "permissions": null }, { "username": "plant@admin.test", "country_code": "+91", "mobile_number": "7073776214", "site_id": "4230adcb-f349-4780-bf79-4a8c94a3b13b", "plant_id": "7a45d8e5-92d2-46a7-92d3-85aa4bd57bba", "user_type": "plant-admin", "site_name": "4PX Test", "plant_name": "4PX Plant", "created_at": "1698735575387", "last_login_time": "1698745103596", "permissions": [ "Alerting", "Energy Monitoring", "Condition Monitoring" ] } ]
Error
{ "error": { "status": 401, "message": "Unauthorized access" } }