Permanently removes a digital account from the Accounts Service. The endpoint enforces role-based access control directly in the controller: a principal holdingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Gianluca-X/DigitalMoney/llms.txt
Use this file to discover all available pages before exploring further.
ROLE_ADMIN may delete any account by ID, while a principal with ROLE_USER may only delete an account whose stored email field matches the email extracted from their JWT. Any attempt to delete another user’s account without admin privileges is rejected with 401 Unauthorized.
Endpoint
http://localhost:8085
Full URL: http://localhost:8085/accounts/{id}
Authentication
Authentication object. Unauthenticated requests — where authentication is null or isAuthenticated() returns false — are rejected immediately with 401 Unauthorized.
Authorization Logic
The controller applies the following decision tree before invoking the service layer:- No authentication present →
401 Unauthorized - Principal has
ROLE_ADMIN→ deletion proceeds unconditionally - Principal has
ROLE_USER→ the account record is fetched; ifaccount.emailequals the JWT principal name, deletion proceeds; otherwise →401 Unauthorized
Path Parameters
The primary key of the digital account to delete.
Response
A successful deletion returns204 No Content with an empty body.
Example
Admin deleting any account
204 No Content (empty body)
User deleting their own account
7. If the emails do not match, the response will be 401 Unauthorized.
Response: 204 No Content (empty body)
Error Codes
| HTTP Status | Description |
|---|---|
401 Unauthorized | The Authorization header is missing, the token is invalid/expired, the Authentication object is not marked as authenticated, or the authenticated user’s email does not match the account’s stored email. The UnauthorizedException is handled by GlobalExceptionHandler and always maps to 401. |
404 Not Found | No account exists with the provided id. Thrown as ResourceNotFoundException by the service layer and handled by GlobalExceptionHandler. |
