Skip to main content
DELETE
/
auth
/
delete
Delete User Account
curl --request DELETE \
  --url https://api.example.com/auth/delete \
  --header 'Authorization: <authorization>'
{
  "message": "<string>",
  "user": {
    "user.id": 123,
    "user.name": "<string>",
    "user.email": "<string>",
    "user.role": "<string>"
  }
}

Overview

Permanently deletes the authenticated user’s account. This action cannot be undone.

Authentication

Required. This endpoint requires a valid JWT token in the Authorization header.

Request Headers

Authorization
string
required
Bearer token for authentication
Authorization: Bearer <jwt_token>

Request Example

cURL
curl -X DELETE https://api.example.com/auth/delete \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Response

message
string
Success message confirming account deletion
user
object
The deleted user object
user.id
integer
Unique user identifier
user.name
string
User’s full name
user.email
string
User’s email address
user.role
string
User’s role (customer or admin)

Response Example

{
  "message": "Usuario eliminado exitosamente",
  "user": {
    "id": 1,
    "name": "John Doe",
    "email": "[email protected]",
    "role": "customer"
  }
}

Error Responses

401 Unauthorized

Returned when no valid JWT token is provided.
{
  "error": "Unauthorized"
}

404 Not Found

Returned when the user account doesn’t exist.
{
  "error": "Usuario no encontrado"
}

Notes

This operation is permanent and cannot be undone. All associated data (cart, orders) will be affected according to database constraints.
  • The user must be authenticated to delete their own account
  • After deletion, the JWT token becomes invalid
  • Related cart items are cascade-deleted
  • Order history is preserved with user reference

Build docs developers (and LLMs) love