HTTP Method to use for adding to a collection in a RESTful API

api, http-method, rest

Solution

If the tags being sent in the request body are intended to be added to a collection, rather than replace, I would suggest POST. If you intend to replace the existing tags, use PUT.

Problem

I have a resource that represents a collection of tags: ``` /users/{username}/tags ``` An API client should be able to add a set of tags to this collection in a single HTTP request. I thought about how to do this and first thought about using the PUT or POST methods. However I think this would imply that the client is "setting" or "replacing" the tags in that collection. What would be the most appropriate HTTP method (or perhaps a different mechanism) to "add" multiple tags to that collection? ``` {HTTP METHOD} /users/{username}/tags ``` Request Body: ``` ["short", "crazy", "funny"] ```

Original source