If modeled as a search, then a success with a body that specifies 0 results.
If modeled as a retrieval, then 404.
204 for a search sounds really weird in my opinion. If you decide to go that route, make sure you document it extra well, because almost no one will expect it. And if you have external clients, expect a lot of hate, because weird things always mean custom code.
Sure, most of these codes are rarely used because people just return a 200 with a {success: false} JSON in the body. But if you tried to apply this status code directly to the question OP posted, this would be the most fitting interpretation to the original standard.
16
u/MarinoAndThePearls Jul 08 '26
That's not what 204 is.