liveBook · Manning

Request message

As explained in The Design of Web APIs, Second Edition

POST is the HTTP method for submitting data to a resource for processing, commonly resulting in resource creation or another state change.

A POST request asks a server to process something according to the meaning of the targeted resource. In a REST API, POST commonly creates an element in a collection, but it can also represent actions such as starting or sending something. The method says what kind of interaction is requested; the path identifies the resource that receives it. section 4.3.1 section 3.1.1

Add a product to a catalog

Use POST /products to add a product. The server creates it and returns a reference that the consumer can use with GET /products/{Product reference}. POST lets the system generate that reference, avoiding collisions when product references would otherwise be random numbers. section 4.3.5

The usual collection pattern is POST /elements to create an element, then GET /elements/{element identifier} to read it. A meaningful collection path also makes an API easier to guess: POST /customers suggests adding a customer more clearly than POST /add-customer. section 4.3.6 section 9.3.1

Choose the method by the operation, not just by whether data is sent:

Take care when retrying POST. Identical POST requests are not idempotent: replaying POST /transfers can create multiple money transfers. Before choosing an automatic retry, consider what repeating the operation would do to server state. section 12.5.2

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains method choice through resource paths, creation identifiers, and replay behavior; does not specify a POST body schema.
Examples
Uses POST /products with a returned reference, POST /customers as a guessable path, and POST /transfers as a replay hazard.
What it assumes
Introduces HTTP methods and resource paths, then uses collection and element paths to explain operation choices.
What you can do after
Apply it to choose a collection creation operation and assess the risk of replaying its request.
How it connects
Connects POST to REST resources, CRUD, resource identifiers, PUT, GET, and HTTP idempotency.

Also explained in

Compare how 15 books explain request message →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.