Custom API Response

Custom API Response

Hi, is there a way to customize the API response?

I have a form with two fields (email, username) having no duplicate values validation. The problem is whenever I add a new record with existing values the API status response is always 'Failure, This value already exists. Enter a unique value', it does not specify what field/s has the error.