Delete a User
11 min
API Endpoint Documentation: /api/users/remove
Description:
This endpoint allows the removal of a specific user from the system by sending a POST request with the user's ID and an authorization token.
Endpoint:
POST https://<your-site>/api/users/removeHeaders:
- accept: application/json Specifies that the request expects a JSON response.
- authorization: Bearer <JWT Token> A JSON Web Token (JWT) that authenticates the request. Replace <JWT Token> with a valid token.
- content-type: application/json Specifies that the request body is in JSON format.
Request Body:
The request body should be in JSON format and contain the following fields:
- id: string The ID of the user to be removed.
- token: string A valid authentication token (JWT) for the request.
Example Request Body:
{
"id": "6706a2390d654864b3ac1981",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Method:
- POST: Sends a request to remove the specified user from the system.
Example Request (Node.js):
const fetch = require('node-fetch');
const url = 'https://<your-site>/api/users/remove';
const options = {
method: 'POST',
headers: {
'accept': 'application/json',
'authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
'content-type': 'application/json',
},
body: JSON.stringify({
id: "6706a2390d654864b3ac1981",
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
})
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));Response:
The API will return a JSON response indicating the success or failure of the operation.
Success Response (200):
{
"message": "User removed successfully",
"status": "success"
}Error Response (400/401):
{
"message": "Invalid token or user ID",
"status": "error"
}Authentication:
This API requires a valid JWT token for authentication. Ensure that the token is included in the authorization header as Bearer <JWT Token>.
Usage Notes:
- Ensure that the id in the request body matches the user you wish to remove.
- The request must include a valid JWT token for authentication, without which the request will be rejected with a 401 Unauthorized error.