😊Admin APIs

How to use the PAAL AI API docs

PAAL AI User Controller API Documentation

Introduction

This API documentation outlines the endpoints available for admin management in the PAAL AI application. These endpoints allow for the creation of new admin , user authentication, user data manipulation, password management, and email verification.

Base URL

The base URL for all endpoints is: https://paal-ecosystem-backend.onrender.com

Authentication

Some endpoints require authentication using a bearer token in the request header.


Create New Admin

Create a new admin account.

  • URL: /admin/new

  • Method: POST

  • Authentication: Not required

  • Request Body:

    • email (string, required with password): User's email address.

    • password (string, optional): if using user's password.

    • auth (String, optional) If using Google 0auth

Example Request:

{
    "email": "example@email.com",
    "password": "password123"
}

Example Response (Success):

{
    "status": true,
    "accessToken": "<JWT_ACCESS_TOKEN>",
    "verification": "pending"
}

Example Response (Error):

{
    msg: "Sign up details not complete",
    status: 'error',
    error: '1001'
}

Admin Login

Authenticate an existing user.

  • URL: /admin/login

  • Method: POST

  • Authentication: Not required

  • Request Body:

    • email (string, required with password): User's email address.

    • password (string, optional): if using user's password.

    • auth (String, optional) If using Google 0auth

Example Request:

{
    "email": "example@email.com",
    "password": "password123"
}

Example Response (Success):

{
    "status": true,
    "accessToken": "<JWT_ACCESS_TOKEN>",
    "verification": "<verification_status>"
}

Example Response (Error):

{
    msg: "Incorred password given",
    status: 'error',
    error: '1007'
}

Logout

Logout an authenticated admin.

  • URL: /admin/logout

  • Method: POST

  • Authentication: Required (Bearer Token)

Example Response (Success):

{
    "status": true
}

Request Email Verification Code

Request an email verification code for admin verification.

  • URL: /admin/verify

  • Method: POST

  • Authentication: Required (Bearer Token)

Example Response (Success):

{
    "status": true
}

Verify Email Verification Code

Verify the email verification code sent to the admin.

  • URL: /admin/verifycode

  • Method: POST

  • Authentication: Required (Bearer Token)

  • Request Body:

    • code (string, required): Verification code received via email.

Example Request:

{
    "code": "123456"
}

Example Response (Success):

{
    "status": true
}

Modify Admin profile data

Save user data such as email or password.

  • URL: /admin/save

  • Method: POST

  • Authentication: Required (Bearer Token)

  • Request Body: Admin data fields to be updated.

Modifiable fields present

  • fullName

  • password (required with oldPassword)

  • oldPassword

  • email

  • displayName

Example Request:

{
    "email": "newemail@email.com",
    "password": "newpassword123",
    "oldPassword":"0000",
}

Example Response (Success):

{
    "status": true
}

Generate Reset Password Code

Generate a code for resetting the admin's password.

  • URL: /admin/resetpasswordcode

  • Method: POST

  • Authentication: Not required

  • Request Body:

    • email (string, required): User's email address.

Example Request:

{
    "email": "example@email.com"
}

Example Response (Success):

{
    "status": true
}

Reset Password

Reset the admin's password using the reset code.

  • URL: /admin/resetpassword

  • Method: POST

  • Authentication: Not required

  • Request Body:

    • email (string, required): User's email address.

    • code (string, required): Reset code received via email.

    • password (string, required): New password.

Example Request:

{
    "email": "example@email.com",
    "code": "123456",
    "password": "newpassword123"
}

Example Response (Success):

{
    "status": true
}

Error Responses

In case of errors, the API returns JSON responses with appropriate error messages.

Example Error Response:

{
    msg: "There is no modifyable fields present",
    status: 'error',
    error: '1006'
}


Retrieve Admin Info

Retrieve information about an admin user.

  • URL: /admin

  • Method: GET

  • Authentication: Required (Email query parameter or Bearer Token)

  • Query Parameters:

    • email (string, optional): Admin's email address.

  • Request Headers:

    • Authorization: Bearer <TOKEN> (string, optional): Bearer token for authentication.

Example Request (Using Email):

GET /admin?email=admin@example.com

Example Request (Using Bearer Token):

GET /admin/info
Authorization: Bearer <TOKEN>

Example Response (Success):

{
    "status": true,
    "data": {
        "email": "admin@example.com",
        "fullName": "John Doe",
        "displayName": "John",
        "joined": "2023-05-01T12:00:00Z",
        "lastLogin": "2024-05-10T08:30:00Z",
        "verified": "verified",
        "data": {}
    }
}

Example Response (Error):

{
    "error": "Admin user not found"
}

Error Responses

In case of errors, the API returns JSON responses with appropriate error messages.

Example Error Response:

{
    "error": "Email parameter is missing"
}

This documentation provides details on how to interact with the PAAL AI admin management APIs. For any further assistance or clarification, please refer to the API documentation or contact support.

Last updated