The Root Object


All requests and responses consist of a JSON object with a single key containing all the data. When creating an object, the value is an object representing the entity to be created, and they key is named for the type of object being created. This can be seen on line 5 of listing 2 and in the square bracket nesting syntax of listing 1 as previously discussed.

This pattern is repeated for the response objects. As before there is a root object, with a single key. The value is an array containing all the objects returned. Please note that the breathe API will always return an array of objects, even if only a single object is contained within. Correspondingly, the key will be the pluralised version of the object type.

For example, if we are requesting a list of employees, the API will return an object with a key employees pointing to an array of employee objects. However, if our request returns a single employee object, such as when we create a new employee, the API will also return an object with an employees key pointing to an array containing our single newly created employee. This behaviour is implemented to ensure consistency across API responses, reducing the number of special cases your consuming code will have to deal with