So we have this hot discussion going on in the company about whether to put custom error codes in HTTP Header or in body. We Googled a lot but we couldn't come up with a definitive answer yet.
Here's the situation:
Team A Use HTTP error codes such as 401, 403 and 404 when an application error occurs and have the custom error codes and description in the body. (Examples of APIs doing this Stripe and Twitter)
Team B If a REAL HTTP errors occur, let the HTTP header be 401, 404 or whatever. Other than that, use HTTP 200 all the time, and if there are any application errors put it ONLY in the body. In other words, don't use HTTP Headers for application custom errors. (Example of API doing this Facebook)
Which one do you think is a best practice and why?
Thanks.