Bruno Pedro


Should API operation responses always include references to parent resources? I think so.

Imagine you have the getStoreEmployees operation, which gets all the employees who work in a specific store. The operation is available via an HTTP GET to /stores/{storeId}/employees/{employeeId}. The response includes employee information such as the name, role, and salary. In my opinion, it should also include a reference to the store where the employee works. It can be a full HATEOAS-style or, to simplify things, it can be a shallow reference including only the store’s ID.

Here are some advantages of this approach: