change chats api to return error codes instead of error messages