Litmus Portal Authentication API API Reference

Litmus Portal Authentication APIs are used to authenticate the identity of a user and to perform several user-specific tasks like:

  • Update Profile
  • Change Password
  • Reset Password
  • Create new users etc.
  • API Endpoint
    https://localhost:3000
    Schemes: https, http
    Version: 2.7.0

    Paths

    GET /status

    This API is used to check the status of the server.

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "status": "up"
    }
    

    POST /login

    This API is used to login into auth server.

    Field Possible values Mandatory/Optional
    username admin Mandatory
    password pass123 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "username": "admin",
      "password": "admin"
    }
    
    200 OK

    OK

    type
    object
    401 Unauthorized

    Unauthorized

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "access_token": "ACCESS_TOKEN",
      "expires_in": 86400,
      "type": "Bearer"
    }
    
    Response Example (401 Unauthorized)
    {
      "error": "unauthorized",
      "error_description": "The user does not have requested authorization to access this resource"
    }
    

    GET /users

    This API is used to get the list of users

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    [
      {
        "_id": "f8036c51-0d79-4cd7-a7d0-45dcadb80eeb",
        "username": "admin",
        "email": "user1@litmus.com",
        "name": "user1",
        "role": "admin",
        "created_at": "1627040098"
      }
    ]
    

    GET /getUser/{user_id}

    This API is used to get the details of an user by passing uid in the URL

    user_id: string
    in path

    ID of the user

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "_id": "f8036c51-0d79-4cd7-a7d0-45dcadb80eeb",
      "username": "admin",
      "email": "user1@litmus.com",
      "name": "user1",
      "role": "admin",
      "created_at": "1627040098"
    }
    

    POST /update/password

    This API is used to update the password

    Field Possible values Mandatory/Optional
    username admin Optional
    old_password pass123 Mandatory
    new_password pass1234 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "username": "admin",
      "old_password": "admin",
      "new_password": "litmus"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "password has been reset"
    }
    

    POST /create

    This API is used to create a new user.

    Field Possible values Mandatory/Optional
    username user1 Mandatory
    password pass123 Mandatory
    role admin Mandatory
    email user1@gmail.com Optional
    name admin Optional
    Request Content-Types: application/json
    Request Example
    {
      "username": "test1",
      "password": "test1",
      "role": "admin",
      "email": "test1@litmus.com",
      "name": "Test Account"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "_id": "5873815a-1535-4b1c-8766-2fe53c726276",
      "username": "test1",
      "email": "test1@litmus.com",
      "name": "Test Account",
      "role": "admin",
      "created_at": "1627040799"
    }
    

    POST /reset/password

    This API is used to reset the password of a user.

    Field Possible values Mandatory/Optional
    username test1 Mandatory
    new_password pass1234 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "username": "test1",
      "new_password": "test2"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "password has been reset successfully"
    }
    

    POST /update/details

    This API is used to update the details of a user.

    Field Possible values Mandatory/Optional
    name test1 Optional
    email test1@test.com Optional
    Request Content-Types: application/json
    Request Example
    {
      "name": "Administrator",
      "email": "admin@litmus.com"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "User details updated successfully"
    }
    

    POST /update/state

    This API is used to update the state of a user.

    Field Possible values Mandatory/Optional
    username test1 Mandatory
    is_deactivate true Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "username": "test1",
      "is_deactivate": true
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "user's state updated successfully"
    }
    

    POST /create_project

    This API is used to create a project

    Field Possible values Mandatory/Optional
    project_name My project Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_name": "my project"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "data": {
        "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
        "Name": "my project",
        "Members": [
          {
            "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b",
            "Role": "Owner",
            "Invitation": "Accepted",
            "JoinedAt": "1640676874"
          }
        ],
        "State": "active",
        "CreatedAt": "1627040799",
        "UpdatedAt": "1627040799",
        "RemovedAt": ""
      }
    }
    

    GET /get_project/{project_id}

    This API is used to get details of a project with given project ID

    project_id: string
    in path

    ID of the project

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "data": {
        "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
        "Name": "my project",
        "Members": [
          {
            "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b",
            "UserName": "admin",
            "Name": "",
            "Role": "Owner",
            "Email": "",
            "Invitation": "Accepted",
            "JoinedAt": "1640676874",
            "DeactivatedAt": ""
          }
        ],
        "State": "active",
        "CreatedAt": "1627040799",
        "UpdatedAt": "1627040799",
        "RemovedAt": ""
      }
    }
    

    GET /get_user_with_project/{username}

    This API is used to get details of a project for a user

    username: string
    in path

    username of the user

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "data": {
        "ID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b",
        "UserName": "admin",
        "CreatedAt": "1627040799",
        "Email": "",
        "Name": "",
        "Projects": [
          {
            "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
            "Name": "my project",
            "Members": [
              {
                "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b",
                "Role": "Owner",
                "Invitation": "Accepted",
                "JoinedAt": "1640676874"
              }
            ],
            "State": "active",
            "CreatedAt": "1627040799",
            "UpdatedAt": "1627040799",
            "RemovedAt": ""
          }
        ]
      }
    }
    

    GET /list_projects

    This API is used to get project details of logged in user

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "data": [
        {
          "ID": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
          "Name": "my project",
          "Members": [
            {
              "UserID": "c0b43e3f-8e7f-475e-9aa3-c2393a0f408b",
              "Role": "Owner",
              "Invitation": "Accepted",
              "JoinedAt": "1640676874"
            }
          ],
          "State": "active",
          "CreatedAt": "1627040799",
          "UpdatedAt": "1627040799",
          "RemovedAt": ""
        }
      ]
    }
    

    GET /get_projects_stats

    This API is used to get overall stats for all the projects(accessible only to admin).

    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "data": [
        {
          "Name": "admin's project",
          "ProjectId": "430baca1-cdea-4886-bd80-9cfa204ea81f",
          "Members": {
            "Owner": [
              {
                "UserId": "6abec0cf-7263-4519-bd69-7e02e26837fa",
                "Username": "admin"
              }
            ],
            "Total": 2
          }
        }
      ]
    }
    

    POST /update_projectname

    This API is used to update a project name

    Field Possible values Mandatory/Optional
    project_id 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8 Mandatory
    project_name admin's project Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
      "project_name": "admin's project"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "Successful"
    }
    

    POST /send_invitation

    This API is used to send project invite to an user

    Field Possible values Mandatory/Optional
    project_id 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8 Mandatory
    user_id 3bdc0bd9-fc46-433b-ac21-05d555566c46 Mandatory
    role Viewer Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
      "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46",
      "role": "Viewer"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "data": {
        "UserID": "3bdc0bd9-fc46-433b-ac21-05d555566c46",
        "UserName": "john",
        "Name": "",
        "Role": "Viewer",
        "Email": "",
        "Invitation": "Pending",
        "JoinedAt": "1640676874",
        "DeactivatedAt": ""
      }
    }
    

    POST /accept_invitation

    This API is used to accept a project invite

    Field Possible values Mandatory/Optional
    project_id 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8 Mandatory
    user_id 3bdc0bd9-fc46-433b-ac21-05d555566c46 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
      "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "Successful"
    }
    

    POST /decline_invitation

    This API is used to decline a project invite

    Field Possible values Mandatory/Optional
    project_id 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8 Mandatory
    user_id 3bdc0bd9-fc46-433b-ac21-05d555566c46 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
      "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "Successful"
    }
    

    POST /remove_invitation

    This API is used to revoke a project invite or remove a project member

    Field Possible values Mandatory/Optional
    project_id 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8 Mandatory
    user_id 3bdc0bd9-fc46-433b-ac21-05d555566c46 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
      "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "Successful"
    }
    

    POST /leave_project

    This API is used to leave a project

    Field Possible values Mandatory/Optional
    project_id 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8 Mandatory
    user_id 3bdc0bd9-fc46-433b-ac21-05d555566c46 Mandatory
    Request Content-Types: application/json
    Request Example
    {
      "project_id": "384f6666-3b7d-4381-b5b5-bfc4c3dedbc8",
      "user_id": "3bdc0bd9-fc46-433b-ac21-05d555566c46"
    }
    
    200 OK

    OK

    type
    object
    Response Content-Types: application/json
    Response Example (200 OK)
    {
      "message": "Successful"
    }