deleteApi - n1lby73/industrial-IOT GitHub Wiki

Overview

The Delete API endpoint removes a user from the database based on their email. It requires authorization through a valid JSON Web Token (JWT) with the role of "owner".

Endpoint URL

  • URL: https://industrialiot.onrender.com/api/delete
  • Method: DELETE

Request Parameters

  • Headers:
    • Authorization: Bearer <ACCESS_TOKEN>
    • Content-Type: application/json
  • Body Parameters:
Parameter Type Description
email String User's email (required).

Responses

  • Success Response:

    • Status Code: 200 OK
    • Response Body:
      {
        "success": "<USER_EMAIL> has been deleted from the database"
      }
      • Description: Indicates successful deletion of the user from the database.
  • Error Responses:

    • Status Code: 401 Unauthorized

      • Response Body:
        {
            "msg": "not authorized"
        }
      • Description: Indicates unauthorized access for users without the "owner" role.
    • Status Code: 401 Unauthorized

      • Response Body:
        {
            "msg": "owner cannot be deleted"
        }
      • Description: Indicates the attempt to delete the "owner" user, which is not permitted.
    • Status Code: 404 Not Found

      • Response Body:
        {
            "Error": "Invalid Email"
        }
      • Description: Indicates that the specified user email does not exist in the database.
    • Status Code: 500 Internal Server Error

      • Response Body:
        {
            "Error": "Failed to delete user",
            "Details": "<ERROR_DETAILS>"
        }
      • Description: Indicates a server error occurred during the user deletion process.

Usage

  1. Request Method: DELETE

  2. Endpoint URL: https://industrialiot.onrender.com/api/delete

  3. Header:

    {
        Authorization: Bearer <ACCESS_TOKEN>
        Content-Type: application/json
    }
  4. Request Body: Users login credentials.

    {
        "email": "[email protected]",
    }
⚠️ **GitHub.com Fallback** ⚠️