Skip to main content
DELETE
/
api
/
accounts
/
:id
curl -X DELETE https://api.yourfinanceapp.com/api/accounts/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Old Savings Account",
  "type": "SAVINGS",
  "currency": "USD",
  "balance": 0,
  "color": "#3B82F6",
  "icon": "piggy-bank",
  "targetAmount": null,
  "targetDate": null,
  "isDefault": false,
  "userId": "123e4567-e89b-12d3-a456-426614174000",
  "createdAt": "2025-01-15T10:30:00Z",
  "updatedAt": "2025-12-20T14:22:00Z"
}
Deletes an account for the authenticated user. Default accounts cannot be deleted.

Path Parameters

id
string
required
The unique identifier of the account to delete

Validation Rules

Cannot delete default accounts - If the account has isDefault: true, the deletion will fail with a 400 Bad Request error.
  • The account must exist and belong to the authenticated user
  • The account must not be marked as default
  • User must be authenticated with a valid JWT token

Cascade Behavior

When an account is deleted, related transactions are handled according to the database schema:
  • Transactions: The accountId field has no explicit onDelete cascade in the schema, so transactions will remain but may need manual cleanup or have their accountId set to null depending on database constraints.
  • Consider transferring transactions to another account or archiving them before deletion to maintain data integrity.

Response

Returns the deleted account object upon successful deletion.
id
string
Unique identifier of the deleted account
name
string
Name of the deleted account
type
string
Account type that was deleted
balance
number
Final balance of the account
currency
string
Currency code
userId
string
Owner user ID
createdAt
string
Original creation timestamp
updatedAt
string
Last update timestamp

Error Responses

404
error
Account not foundThe account doesn’t exist or doesn’t belong to the authenticated user.
400
error
Cannot delete default accountThe account is marked as default and cannot be deleted. Change the default account first or remove the default flag.
401
error
UnauthorizedMissing or invalid authentication token.
curl -X DELETE https://api.yourfinanceapp.com/api/accounts/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Old Savings Account",
  "type": "SAVINGS",
  "currency": "USD",
  "balance": 0,
  "color": "#3B82F6",
  "icon": "piggy-bank",
  "targetAmount": null,
  "targetDate": null,
  "isDefault": false,
  "userId": "123e4567-e89b-12d3-a456-426614174000",
  "createdAt": "2025-01-15T10:30:00Z",
  "updatedAt": "2025-12-20T14:22:00Z"
}

Build docs developers (and LLMs) love