Table of Contents

APIs for users

Ramya Priya Updated by Ramya Priya

Here, you can find APIs for

  • Generating JWT (login API)
  • Creating users (POST)
  • Updating users (PUT)
  • Getting a list of all users (GET)
  • Deleting users (DELETE)
  • Assigning attributes of a user to another user

Login API

To access other APIs, JSON Web Token (JWT) is required. The login API provides JWT as a response when username and password are provided as a request.

Request

URL
https://<TELLIUS_URL>/api/login

CURL
curl -X POST \

  https://<TELLIUS_URL>/api/login \
  -H 'content-type: application/json;charset=UTF-8' \
  -d '{"username":"<username>","password":"<password>"}'
Method
POST
Headers
Content-Type: application/json;charset=UTF-8

Body
{
"username": "<username>",
"password": "<password>"
}

Response

Success
Status Code: 200 OK
Body

The response contains the JWT token to be used for subsequent API requests.

{
"id": "18dhfwe332jfls-fehd-fe",
"refreshToken": "ey3bjdfehdjfh",
"token": "rue78djfeuhUIbdjfTY"
}

Create a user

The API can be used to create a new user. The user is added to the groups passed in the request.

Users can only be created using superUser/Admin tokens.

Request

URL
http://<TELLIUS_URL>/users
CURL
curl -v  -H "Content-Type: application/json" \
    -H "Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
    http://<TELLIUS_URL>/users \
    --data'{"username":"newTestUser3","firstName":"Abhishek","lastName":"Saini","password":"teLLius@123","email":"another@gmail.com","groupsIds":["56759e38c7b8fa"],"role":"power","assignDefaultGroup":true,"config":{"talkBackEnabled":false}}'
Method
POST
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body
{
"username": "newTestUser3",
"firstName": "Abhishek",
"lastName": "Saini",
"password": "teLLius@123",
"email": "another@gmail.com",
"groupsIds": ["5675954e38c7b8fa"],
"role": "power",
"assignDefaultGroup": true,
"config": {
"talkBackEnabled": false
}
}

Response

Success
Status Code: 200 OK
Body

The response returns the new user object.

{
"username": "newTestUser3",
"firstName":"Abhishek",
"lastName":"Saini",
"email": "another@gmail.com",
"groups": [{
"name": "SuperUsers",
"permissions": [],
"id": "56759594338c7b8fa"
}],
"id": "568263f80befc92",
"role":"power",
"config":{"talkBackEnabled":false}
}

Update a user

The API can be used to update the attributes of an existing user. The API works only for superUsers, and the request is rejected from any other user.

Request

URL

The value of <userId> is the user ID of the user which needs to be updated.

https://<TelliusUrl>/users/<userId>
CURL
curl -v -X PUT -H "Content-Type: application/json" \
-H "Authorization: <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
http://localhost:8080/users/568263ffed93764e \
--data '{"email": "aNewEmail@gmail.com", "groups": ["sdf3234dsfsdf349j"]}'
Method
PUT
Headers
Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body
{
"email": "aNewEmail@gmail.com",
"groups": ["sdf3234df349j"]
}

Response

Success
Status Code: 200 OK
Body

The response returns the updated user object.

{
"username": "newTestUser3",
"email": "aNewEmail@gmail.com",
"groups": [{
"name": "SuperUsers",
"permissions": [],
"id": "5675959434e38c7b8fa"
}],
"id": "568263ffed9380befc92"
}

Get the list of users

The API returns a list of all the users available.

Request

URL
https://<TelliusUrl>/users
CURL
curl -v -H "Content-Type: application/json" \
-H "Authorization: <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \ http://localhost:8080/users
Method
GET
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json

Response

Success
Status Code: 200 OK
Body
{
"users": [
{
"username": "superUser",
"email": "another2@gmail.com",
"groups": [{
"name": "SuperUsers",
"permissions": [],
"id": "5675959437bab64e38c7b8fa"
}],
"id": "567595de37bab64e38c7b8fb"
},
{
"username": "testUser1",
"email": "test@gmail.com",
"groups": [],
"id": "56826269ed93764e80befc90"
}
]
}

Delete a user

The following API can be used to delete a user.

Request

URL

The value of <userId> is the user ID of the user which needs to be deleted.

https://<TelliusUrl>/users/<userId>
CURL
curl -v -X DELETE -H "Content-Type: application/json" \
 -H "Authorization: <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
        http://localhost:8080/users/568263ffed93764e80befc92
Method
DELETE
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json

Response

Success
Status Code: 200 OK
Body

If the deletion of the user is successful, the API will return a response with status code 200 and an empty response body. If the user is not found, it will return a status code of 404 with an error message in the response body.

Assign user objects

The following API can be used to assign the user object to another user.

Request

URL
https://<TelliusUrl>/assignUserObjects
CURL
curl -v -X POST -H "Content-Type: application/json" \
-H "Authorization: <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
http://localhost:8080/assignUserObjects \
--data '{"previousOwnerId":"9cfcd3fe-d8483cbee", "newOwnerId": "662b1e11-eee6a2e14"}'
Method
POST
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body

The request body contains the previousOwnerId and the newOwnerId parameters, which represent the ID of the user from whom we want to transfer and the ID of the user to whom the objects need to be transferred, respectively.

{
"previousOwnerId":"9cfcd3fe-d0048483cbee",
"newOwnerId": "662b1e11-eee6aec62e14"
}

Response

Success
Status Code: 200 OK
Body

If the user object assignment is successful, the API will return a response with status code 200 and an empty response body. If there is an error in the assignment process, the API may return a status code of 404 or 500 with an error message in the response body.

Did we help you?

APIs for user groups

Contact