Search code examples
resthateoas

HATEOAS - REST is not truly REST


When REST API don't follow HATEOAS style, it is often referred your REST is not truly REST.

How come we can think of every possible request from clients can map to CRUD operations?

For example if the client(mobile) would like to send a reset password link to user for a given email id, how this shall be thought of as CRUD?


Solution

  • Very few REST advocates will argue that that REST should be applied to everything. I'm a big proponent of REST, but there are more than a few situations where not using HATEOAS is the most pragmatic move. Your example is one of them.

    However, if you want to make this work in a RESTful manner, it's totally still possible.

    For example, a lost password reset link might require a one-time authentication token. This token might be represented by a resource in a collection such as:

    /users/xyz/auth-tokens
    

    And perhaps you can initiate a lost-password email operation by creating a new 'auth-token' resource in that collection using POST.

    Should you? I don't know! Can you? for sure!