Am I missing something?
A little bit, maybe.
REST is the architectural style of the world wide web; it a collection of constraints that were used in the 1990s to aid the development of the HTTP/1.1 standards (RFC 2068, RFC 2616).
So when we are talking about resources, "information that can be named", you can think of resources as generalizations of documents. See Webber 2011 - we use HTTP to transfer documents over a network.
So we have GET
semantics to retrieve a document, and PUT
, POST
, PATCH
semantics to modify documents.
The interesting business behaviors are side effects of the edits we make to documents. But from the outside, a REST API is just a dumb document store.
A resource identifier like /documents/create
doesn't necessarily violate REST principles.
Consider how we send information to a server on the web: that usually happens by navigating to some document that has a web form, we input our information into the form, and when we submit the form our browsers uses standardized form processing rules to create from the form an HTTP request.
That's REST, and it doesn't stop being REST because the form URI has a "that's not REST" spelling, and it doesn't stop being REST if the form.action has the "that's not REST" spelling.
Because REST cares about caching, and because HTTP caches have standardized mechanics, choosing a resource model that is well aligned with caching is going to allow you to leverage all of the general purpose work that has been done on web caches "for free".
It is very common to create resources that do not represent any persistent entity but instead encapsulate behaviour that is invoked once an appropriate verb is used on them
Consider a request like this:
PUT /e2b1dbbc-1cdb-4510-a75e-b88284392d2c
Content-Type: text/plain
Please turn off the lights
From the perspective of REST components, this just says to change the current representation of the document /e2b1dbbc-1cdb-4510-a75e-b88284392d2c to match the body of the request.
Actually doing the work to turn off the lights is a side effect.
In other words, we could design our resource model such that each change is communicated by adding another document to our document store.
And that's fine.
Or we could instead design our resource model such that each change is communicated by modifying an existing document
POST /things-to-do
Content-Type: text/plain
Please turn off the lights
The document store model being a facade in front of our domain model, so that we can use all of the lovely tooling that has been developed for the web to talk to our domain.