formula 409
It’s easy to make an API, but it is not so easy to make a good API.
Using the appropriate http status code in a response is one sign I use to tell if I am dealing with a good API. It shows attention to detail.
Today I learned a great application of the 409
error code, which indicates a conflict.
From w3’s status code definitions:
This response would most often be encountered from a PUT endpoint, where there is a problem updating a resource. But I imagine it would also be appropriate for a POST request to create a resource where there is a naming collision and uniqueness is being enforced.