server code for retreat RESTful API