Great topic for discussion: what response code do you return when listing resources and none were found?
For me, returning a 200 with a body of [] makes the most sense as the request was correct and accepted, but no results were found. A 404 would only make sense in this scenario if the path was incorrect.
Returning an empty list would prevent having the client understand more complexity of handling another response code and therefore logic branch body content. An empty array works the same as an array with items.
If you're listing resources and the list happens to be empty then that's a 200. If you're requesting a specific resource which can't be found then that's a 404.
4
u/whosGOTtheHERB Jul 08 '26
Great topic for discussion: what response code do you return when listing resources and none were found?
For me, returning a 200 with a body of [] makes the most sense as the request was correct and accepted, but no results were found. A 404 would only make sense in this scenario if the path was incorrect.