Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP 200 (not 404) status for an empty list result returned from a REST endpoint

Please give me examples of official specification, or trusted recommendations that can prove my business partner that when they return an empty list from a REST endpoint, the HTTP status should be 200, not 404. For me RFC-2616 is obvious, but also general and doesn't discuss the case of an empty set as a result. I'm looking for strong arguments for a discussion.

Kind regards, Kamil.

like image 712
Kamil Murawski Avatar asked Sep 13 '25 00:09

Kamil Murawski


1 Answers

RFC 2616 is an obsolete document. The current specification for the 404 status code is RFC 7231 § 6.5.4, which seems clear enough to me:

The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

If the empty list is a valid representation of your resource (as opposed to an error message, for example), this precludes 404.

like image 92
Vasiliy Faronov Avatar answered Sep 14 '25 17:09

Vasiliy Faronov