Skip to content

Admin API

M♢NTΛSIM edited this page Aug 17, 2024 · 1 revision

Admin API Documentation

Create New Admin

  • POST /

    • Summary: Creates a new administrator account. This endpoint is accessible only to users with admin permissions.
    • Security: Requires bearer token authentication.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "description": "Email address for the new admin."
            },
            "password": {
              "type": "string",
              "description": "Password for the new admin account."
            }
          }
        }
    • Responses:
      • 201 Created: Admin created successfully.
      • 409 Conflict: Email already registered.
      • 403 Forbidden: Email already registered as a user.
      • 400 Bad Request: Invalid email provided.
  • All Other Methods on /

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Verify Admin Email

  • GET /verify/{token}

    • Summary: Verifies the admin's email using the provided token.
    • Parameters:
      • Path Parameter: token
        • Type: string
        • Description: Verification token sent to the admin's email.
    • Responses:
      • 200 OK: Email verified successfully.
      • 403 Forbidden: Invalid or expired token.
  • All Other Methods on /verify/{token}

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Resend Verification Email

  • GET /resend-verification/{id}

    • Summary: Resends the verification email to the admin using the admin ID.
    • Parameters:
      • Path Parameter: id
        • Type: string
        • Description: Admin ID for whom to resend the verification email.
    • Responses:
      • 200 OK: Verification email resent successfully.
      • 404 Not Found: Admin not found.
      • 403 Forbidden: Email already verified.
  • All Other Methods on /resend-verification/{id}

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Request New Password

  • PUT /requestBooks-new-password

    • Summary: Initiates a password reset process for an admin.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "description": "Email address of the admin."
            }
          }
        }
    • Responses:
      • 200 OK: Password reset email sent successfully.
      • 404 Not Found: No account found with that email address.
      • 401 Unauthorized: Email not verified.
  • All Other Methods on /requestBooks-new-password

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Reset Admin Password

  • PUT /reset-password/{token}

    • Summary: Resets the admin's password using a provided token.
    • Parameters:
      • Path Parameter: token
        • Type: string
        • Description: Reset password token sent to the admin's email.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "newPassword": {
              "type": "string",
              "description": "The new password to be set."
            },
            "confirmNewPassword": {
              "type": "string",
              "description": "Confirmation of the new password."
            }
          }
        }
    • Responses:
      • 200 OK: Password reset successfully.
      • 403 Forbidden: Invalid or expired token.
  • All Other Methods on /reset-password/{token}

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.