Most examples of RESTful APIs assume you are dealing with collections of things, e.g.
POST /books/
- create a book
GET /books/
- get a list of books
GET /books/1/
- get a particular book
However, there are some circumstances where you might want to create a singleton resource. For example, a new user might want to create a profile relating to themselves, the authenticated user.
POST /profile
PUT /profile
Is there any convention about how to create such singleton resources? i.e. using POST
vs PUT
. In terms of whether to use POST
or PUT
, does it make a difference if the resource can be modified after creation? Does the idempotency requirement of PUT
require that it must be possible to update the resource after it is first created?