How to exclude a field (or attribute) from REST API response

thats one way to do it, but the easier way would be to just mark it as private then the default sanitization function would remove it from the response