Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TheSerchCp/SEAM-API/llms.txt

Use this file to discover all available pages before exploring further.

The DELETE /api/v1/users/:id endpoint permanently removes a user account from the database by their numeric primary key. The service verifies the user exists before issuing the delete query. On success the response returns null in the data field confirming the record has been removed. This endpoint requires a valid JWT token and that the caller’s role has the DELETE /api/v1/users/:id permission registered in the database.

Endpoint

DELETE /api/v1/users/:id
Base URL: http://localhost:{PORT}/api/v1 Authentication: JWT Bearer token + role permission DELETE /api/v1/users/:id

Path Parameters

id
string
required
The numeric ID of the user to delete. Must match the pattern ^\d+$. Validated by validate.middleware against getByIdSchema before the controller runs.

Example Request

curl -X DELETE http://localhost:3000/api/v1/users/7 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Responses

200 OK

Returned when the user exists and the deletion completes successfully. The data field is null — there is no record to return after deletion.
{
  "success": true,
  "message": "Usuario eliminado exitosamente",
  "data": null
}
success
boolean
Always true for successful responses.
message
string
Human-readable confirmation: "Usuario eliminado exitosamente".
data
null
Always null — the deleted record is no longer available.

400 Bad Request — Invalid ID Format

Returned when the :id path segment does not match ^\d+$ (letters, special characters, or decimals are rejected).
{
  "success": false,
  "message": "El campo 'id' no cumple con el patrón requerido",
  "data": null
}

401 Unauthorized

Returned when the Authorization header is missing, the token is malformed, or the token has expired.
{
  "success": false,
  "message": "Token inválido o expirado",
  "data": null
}

403 Forbidden

Returned when the JWT is valid but the caller’s role does not have DELETE /api/v1/users/:id in the permissionXRole table.
{
  "success": false,
  "message": "No tienes permisos para acceder a este recurso",
  "data": null
}

404 Not Found

Returned when no user with the given ID exists in the database. The service calls findById before deleting and throws NotFoundError if the record is absent.
{
  "success": false,
  "message": "Usuario con id 7 no encontrado",
  "data": null
}

409 Conflict — User Has Dependents

Returned when the database raises ER_ROW_IS_REFERENCED_2, meaning another table contains rows that reference this user via a foreign key constraint. The user cannot be deleted while dependent records exist.
{
  "success": false,
  "message": "No se puede eliminar el usuario porque tiene registros relacionados",
  "data": null
}
To resolve this, remove or reassign the dependent records before retrying the delete.

Permission Setup

For a role to access this endpoint, a record must exist in the permissions table with nameUri = "DELETE /api/v1/users/:id" and be linked to the role in permissionXRole. The roles.middleware derives this URI automatically from the Express route pattern:
DELETE /api/v1/users/:id

This operation is permanent. There is no soft-delete mechanism — once a user account is deleted it cannot be recovered through the API. The row is immediately removed from the users table. Ensure you have confirmed the correct id and have obtained appropriate authorization before calling this endpoint.

Build docs developers (and LLMs) love