Add response codes to APIs

Improve API responses. See invitations api for examples.