Skip to main content
POST
/
secured
/
delete_user
Delete User
curl --request POST \
  --url https://api.example.com/secured/delete_user \
  --header 'Content-Type: application/json' \
  --data '{
  "id": 123
}'
{
  "msg": "<string>",
  "401 Unauthorized": {}
}

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header.
This action is permanent and cannot be undone. All user data will be removed from the database.

Request Body

id
number
required
ID of the user to delete
curl --location 'http://localhost:8080/secured/delete_user' \
--header 'Content-Type: application/json' \
--header 'Authorization: YOUR_JWT_TOKEN' \
--data-raw '{
  "id": 5
}'

Response

msg
string
Success or error message

Success Response (200)

{
  "msg": "Usuario eliminado"
}

Error Responses

401 Unauthorized
object
Returned when the JWT token is invalid or missing
{
  "msg": "Token_invalido"
}
or
{
  "msg": "Sin autorización"
}

Implementation Details

The endpoint performs a direct deletion from the usuarios table:
DELETE FROM usuarios WHERE id = ?
Ensure that cascading deletes or foreign key constraints are properly handled if the user has related records in other tables (e.g., bitacora, productos_publicados).

Best Practices

  • Confirmation: Always implement a confirmation dialog in your application before calling this endpoint
  • Audit Trail: Consider implementing soft deletes or maintaining an audit log of deleted users
  • Related Data: Check for related data (activity logs, published products) before deletion
  • Permissions: Restrict this endpoint to admin-level users only

Build docs developers (and LLMs) love