If you just want to use HTTP as a transport mechanism, then everything goes. If, on the other hand, you want to develop a truly RESTful API, you should learn about REST. As a start, consider the Richardson maturity model. I don't consider an API RESTful unless it's a level 3 API, but even at level 1, you should model the API as a set of resources.
Each resource should be identified by a unique URL, so that already rules out two of the three options in the OP.
The resources should be identified by their URL, but not as suggested. At level 2, actions are indicated by HTTP verbs (GET
, POST
, DELETE
, etc.). Thus, to support creation of an order, I'd envision an HTTP request like this:
POST /orders HTTP/1.1
Content-Type: application/json
{
"orderNumber": 1234
}
A successful request should result in a response in the 200 range (200 OK
, 201 Created
, etc.).
If instead you want to create a shipment resource, you could POST
to a shipments
collection resource:
POST /shipments HTTP/1.1
Content-Type: application/json
{
"orderNumber": 1234
}
Resources like orders
and shipments
are typically called collection resources because they represent collections of other resources. They typically support only the POST
and GET
verbs, where GET
would enumerate all the resources in the collection.
Each POST
against a collection resource typically results in the creation of a 'sub resource' with its own address. For example, when you create an order, the created address might be /orders/1234
. Such a resource would typically support GET
, DELETE
, and maybe PUT
, but not POST
.
I highly recommend Allamaraju Subrahmanyam's book RESTful Web Services Cookbook for anyone wanting to get into REST API design. It's easy to read and full of practical solutions.