liveBook · Manning

HTTP 2xx response

As explained in The Design of Web APIs, Second Edition

A 2xx status class is the HTTP status-code class indicating that a request was successfully received, understood, and processed.

An HTTP 2xx response indicates that the server successfully received, understood, and processed a request. Codes from 200 through 299 form the success class, allowing consumers to interpret unfamiliar codes by their class. section 4.5.1

Choose a specific success status according to the operation’s output and HTTP method:

  • Return 200 OK when a successful read, search, or update returns data. section 4.5.3 section 4.9
  • Return 201 Created for successful resource creation, and 204 No Content when an operation succeeds without response data, such as deletion. section 4.9
  • Prefer assigned, commonly used status codes; avoid unassigned codes because they create compatibility problems and confusion. section 4.5.2

Shopping API and webhook acknowledgments

A consumer requesting GET /products/{Product reference} typically receives 200 OK with product details. A webhook receiver may return 200 OK or 204 No Content after successfully receiving an event; it should respond quickly and need not return data. section 4.5.3 section 14.6.7

Figure 4.12 An HTTP status has a numeric code and human-readable reason. The class system allows for easily identifying whether the code signifies a success or an error and who is at fault.
figure

Use the status-code diagram to distinguish the numeric code, human-readable reason, success class, and likely party responsible for an error. section 4.5.1

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains class semantics, status selection, common operation mappings, and webhook use, while deferring unusual status-code details to registries.
Examples
Uses product retrieval, resource creation, deletion, and event-receiving webhooks as concrete success-response scenarios.
What it assumes
Assumes basic HTTP requests and methods while defining status-code classes and their success, client-error, and server-error roles.
What you can do after
Apply it via HTTP methods and OpenAPI by selecting compatible success statuses for operation outputs and webhook acknowledgments.
How it connects
Connects HTTP methods, REST APIs, HTTP status codes, webhooks, and OpenAPI response descriptions.

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.