Skip to main content
Soft deletes a union member by setting their deletedAt timestamp. Members with active loans cannot be deleted.

Authorization

Requires authentication with one of the following roles:
  • Admin: Can delete any member
  • Supervisor: Can delete members in unions managed by their credit officers
  • Credit Officer: Can delete members in their assigned unions only

Path Parameters

id
string
required
The unique identifier of the union member to delete

Response

success
boolean
Indicates if the deletion was successful
message
string
Success or error message

Deletion Rules

  • Soft Delete: The member is not permanently removed. Instead, the deletedAt field is set to the current timestamp.
  • Active Loans Check: Members with active loans (where deletedAt is null) cannot be deleted. You must resolve all loans first.
  • Permission-Based: Users can only delete members they have permission to manage based on their role.

Error Scenarios

If the member has any active loans, the deletion will fail with a 400 error:
{
  "success": false,
  "message": "Cannot delete member with active loans. Please resolve loans first."
}
You must complete, cancel, or otherwise resolve all loans before deleting the member.
If the member ID doesn’t exist or the member is already deleted:
{
  "success": false,
  "message": "Union member not found"
}
If the user doesn’t have permission to delete this member:
{
  "success": false,
  "message": "Credit officers can only delete members from their unions"
}
Or for supervisors:
{
  "success": false,
  "message": "You can only delete members under your supervision"
}
curl -X DELETE "https://api.example.com/api/union-members/clx123abc" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "success": true,
  "message": "Union member deleted successfully"
}
Soft Delete: Deleted members are not permanently removed from the database. They can potentially be restored by updating their deletedAt field to null through direct database access if needed.
Data Integrity: Always ensure all related loans are resolved before attempting to delete a member to maintain data integrity and avoid errors.

Build docs developers (and LLMs) love