Search code examples
ruby-on-railsapirestapi-design

Batch Updating in Rest API


I have a curious question regarding REST API design!

There is a resource called users and there are different user-types

Say if I want to delete a user by Rest design I would have an endpoint like

DELETE /users/id

But now I want to delete all users with a specific user-type and maybe other params that I can't send as a query params. I read a bunch of documentation against using body params for DELETE

So I thought having a POST /users/delete route would be a better option.

Now I am confused if my new route POST /users/delete can be used for both individual user deletion and multiple user deletion. Does this violate any REST standard?

If not what would be another way to do this?


Solution

  • Does this violate any REST standard?

    No - it may violate some of the Rails conventions, but it is perfectly fine as far as a REST client is concerned.


    It may help to translate your question into the language of HTML and the world wide web: is there any violation of REST principles if you have two different web forms that submit requests to the same resource?

    And the answer is no - it still "just works"; browsers use the standardized processing rules to take the information of the form and from it create the appropriate HTTP request, and then send it across the network to the right place, without needing to know anything about the semantics (aside from the general purpose semantics defined by the HTTP specification).