---
swagger: "2.0"
host: "localhost:3000"
schemes:
  - https
  - http
info:
  title: Litmus Portal Authentication API
  version: 2.7.0
  description: |
    Litmus Portal Authentication APIs are used to authenticate the identity of a user and to perform several user-specific tasks like:
     <li>Update Profile</li>
     <li>Change Password</li>
     <li>Reset Password</li>
     <li>Create new users etc.</li>
paths:
  "/status":
    get:
      description: This API is used to check the status of the server.
      responses:
        "200":
          description: OK
          examples:
            application/json:
              status: up
          schema:
            type: object
      parameters: []
      produces:
        - application/json
  "/login":
    post:
      description: |
        This API is used to login into auth server.
        <table>
          <tr>
          <th>Field</th>
          <th>Possible values</th>
          <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>username</td>
            <td>admin</td>
            <td>Mandatory</td>
           </tr>
           <tr>
            <td>password</td>
            <td>pass123</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              access_token: ACCESS_TOKEN
              expires_in: 86400
              type: Bearer
          schema:
            type: object
        "401":
          description: Unauthorized
          examples:
            application/json:
              error: unauthorized
              error_description:
                The user does not have requested authorization to
                access this resource
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              username: admin
              password: admin
      consumes:
        - application/json
      produces:
        - application/json
  "/users":
    get:
      description: This API is used to get the list of users
      responses:
        "200":
          description: OK
          examples:
            application/json:
              - _id: f8036c51-0d79-4cd7-a7d0-45dcadb80eeb
                username: admin
                email: user1@litmus.com
                name: user1
                role: admin
                created_at: "1627040098"
          schema:
            type: object
      parameters: []
      produces:
        - application/json
  "/getUser/{user_id}":
    get:
      description: This API is used to get the details of an user by passing uid in the URL
      responses:
        "200":
          description: OK
          examples:
            application/json:
              _id: f8036c51-0d79-4cd7-a7d0-45dcadb80eeb
              username: admin
              email: user1@litmus.com
              name: user1
              role: admin
              created_at: "1627040098"
          schema:
            type: object
      parameters:
        - name: user_id
          required: true
          description: ID of the user
          in: path
          type: string
      produces:
        - application/json
  "/update/password":
    post:
      description: |
        This API is used to update the password
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>username</td>
            <td>admin</td>
            <td>Optional</td>
          </tr>
          <tr>
            <td>old_password</td>
            <td>pass123</td>
            <td>Mandatory</td>
          </tr>
          <tr>
            <td>new_password</td>
            <td>pass1234</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: password has been reset
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              username: admin
              old_password: admin
              new_password: litmus
      consumes:
        - application/json
      produces:
        - application/json
  "/create":
    post:
      description: |
        This API is used to create a new user.
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>username</td>
            <td>user1</td>
            <td>Mandatory</td>
          </tr>
          <tr>
            <td>password</td>
            <td>pass123</td>
            <td>Mandatory</td>
          </tr>
          <tr>
            <td>role</td>
            <td>admin</td>
            <td>Mandatory</td>
          </tr>
          <tr>
            <td>email</td>
            <td>user1@gmail.com</td>
            <td>Optional</td>
          </tr>
          <tr>
            <td>name</td>
            <td>admin</td>
            <td>Optional</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              _id: 5873815a-1535-4b1c-8766-2fe53c726276
              username: test1
              email: test1@litmus.com
              name: Test Account
              role: admin
              created_at: "1627040799"
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              username: test1
              password: test1
              role: admin
              email: test1@litmus.com
              name: Test Account
      consumes:
        - application/json
      produces:
        - application/json
  "/reset/password":
    post:
      description: |
        This API is used to reset the password of a user.
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>username</td>
            <td>test1</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>new_password</td>
            <td>pass1234</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: password has been reset successfully
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              username: test1
              new_password: test2
      consumes:
        - application/json
      produces:
        - application/json
  "/update/details":
    post:
      description: |
        This API is used to update the details of a user.
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>name</td>
            <td>test1</td>
            <td>Optional</td>
          </tr>
           <tr>
            <td>email</td>
            <td>test1@test.com</td>
            <td>Optional</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: User details updated successfully
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              name: Administrator
              email: admin@litmus.com
      consumes:
        - application/json
      produces:
        - application/json
  "/update/state":
    post:
      description: |
        This API is used to update the state of a user.
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>username</td>
            <td>test1</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>is_deactivate</td>
            <td>true</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: user's state updated successfully
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              username: test1
              is_deactivate: true
      consumes:
        - application/json
      produces:
        - application/json
  "/create_project":
    post:
      description: |
        This API is used to create a project
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_name</td>
            <td>My project</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              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: ""
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_name: my project
      consumes:
        - application/json
      produces:
        - application/json
  "/get_project/{project_id}":
    get:
      description: |
        This API is used to get details of a project with given project ID
      responses:
        "200":
          description: OK
          examples:
            application/json:
              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: ""
          schema:
            type: object
      parameters:
        - name: project_id
          required: true
          description: ID of the project
          in: path
          type: string
      produces:
        - application/json
  "/get_user_with_project/{username}":
    get:
      description: |
        This API is used to get details of a project for a user
      responses:
        "200":
          description: OK
          examples:
            application/json:
              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: "",
                    },
                  ]
          schema:
            type: object
      parameters:
        - name: username
          required: true
          description: username of the user
          in: path
          type: string
      produces:
        - application/json
  "/list_projects":
    get:
      description: |
        This API is used to get project details of logged in user
      responses:
        "200":
          description: OK
          examples:
            application/json:
              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: "",
                  },
                ]
          schema:
            type: object
      parameters: []
      produces:
        - application/json
  "/get_projects_stats":
    get:
      description: |
        This API is used to get overall stats for all the projects(accessible only to admin).
      responses:
        "200":
          description: OK
          examples:
            application/json:
              data:
                [
                  {
                    Name: admin's project,
                    ProjectId: "430baca1-cdea-4886-bd80-9cfa204ea81f",
                    Members:
                      {
                        Owner:
                          [
                            {
                              UserId: "6abec0cf-7263-4519-bd69-7e02e26837fa",
                              Username: admin,
                            },
                          ],
                        Total: 2,
                      },
                  },
                ]
          schema:
            type: object
      parameters: []
      produces:
        - application/json
  "/update_projectname":
    post:
      description: |
        This API is used to update a project name
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_id</td>
            <td>384f6666-3b7d-4381-b5b5-bfc4c3dedbc8</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>project_name</td>
            <td>admin's project</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: Successful
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_id: 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8
              project_name: admin's project
      consumes:
        - application/json
      produces:
        - application/json
  "/send_invitation":
    post:
      description: |
        This API is used to send project invite to an user
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_id</td>
            <td>384f6666-3b7d-4381-b5b5-bfc4c3dedbc8</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>user_id</td>
            <td>3bdc0bd9-fc46-433b-ac21-05d555566c46</td>
            <td>Mandatory</td>
          </tr>
          <tr>
            <td>role</td>
            <td>Viewer</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              data:
                UserID: 3bdc0bd9-fc46-433b-ac21-05d555566c46
                UserName: john
                Name: ""
                Role: "Viewer"
                Email: ""
                Invitation: "Pending"
                JoinedAt: "1640676874"
                DeactivatedAt: ""
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_id: 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8
              user_id: 3bdc0bd9-fc46-433b-ac21-05d555566c46
              role: Viewer
      consumes:
        - application/json
      produces:
        - application/json
  "/accept_invitation":
    post:
      description: |
        This API is used to accept a project invite
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_id</td>
            <td>384f6666-3b7d-4381-b5b5-bfc4c3dedbc8</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>user_id</td>
            <td>3bdc0bd9-fc46-433b-ac21-05d555566c46</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: Successful
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_id: 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8
              user_id: 3bdc0bd9-fc46-433b-ac21-05d555566c46
      consumes:
        - application/json
      produces:
        - application/json
  "/decline_invitation":
    post:
      description: |
        This API is used to decline a project invite
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_id</td>
            <td>384f6666-3b7d-4381-b5b5-bfc4c3dedbc8</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>user_id</td>
            <td>3bdc0bd9-fc46-433b-ac21-05d555566c46</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: Successful
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_id: 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8
              user_id: 3bdc0bd9-fc46-433b-ac21-05d555566c46
      consumes:
        - application/json
      produces:
        - application/json
  "/remove_invitation":
    post:
      description: |
        This API is used to revoke a project invite or remove a project member
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_id</td>
            <td>384f6666-3b7d-4381-b5b5-bfc4c3dedbc8</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>user_id</td>
            <td>3bdc0bd9-fc46-433b-ac21-05d555566c46</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: Successful
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_id: 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8
              user_id: 3bdc0bd9-fc46-433b-ac21-05d555566c46
      consumes:
        - application/json
      produces:
        - application/json
  "/leave_project":
    post:
      description: |
        This API is used to leave a project
        <table>
          <tr>
            <th>Field</th>
            <th>Possible values</th>
            <th>Mandatory/Optional</th>
          </tr>
          <tr>
            <td>project_id</td>
            <td>384f6666-3b7d-4381-b5b5-bfc4c3dedbc8</td>
            <td>Mandatory</td>
          </tr>
           <tr>
            <td>user_id</td>
            <td>3bdc0bd9-fc46-433b-ac21-05d555566c46</td>
            <td>Mandatory</td>
          </tr>
        </table>
      responses:
        "200":
          description: OK
          examples:
            application/json:
              message: Successful
          schema:
            type: object
      parameters:
        - name: body
          in: body
          schema:
            type: object
            example:
              project_id: 384f6666-3b7d-4381-b5b5-bfc4c3dedbc8
              user_id: 3bdc0bd9-fc46-433b-ac21-05d555566c46
      consumes:
        - application/json
      produces:
        - application/json
