1

We're building a backend with a number of APIs. What should be the ideal range of HTTP codes that I should be using?

I've gone through https://en.wikipedia.org/wiki/List_of_HTTP_status_codes and they give a list such as:

1xx Informational
2xx Success
3xx Redirection
4xx Client Error
5xx Server Error

But since I want to implement my own status codes for various purposes such as missing email, I want to name the response accordingly.

So, according to me, a missing email response should trigger a 4xx response as it's a client error. What I'm trying to understand is that should I look for the first open slot such as #419 or should I begin to number the HTTP codes after #451?

Karan Shah
  • 1,304
  • 11
  • 15

1 Answers1

1

You shouldn't use any custom codes at all - they might conflict with future standardization.

If you think you have a use case for a new code that is of general use, propose it in the right place (the HTTP Working Group).

If you just need something specific to your application, use a 400 (in this case), and provide additional information in the response body.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98