DEV Community

Discussion on: The Complete Guide to Status Codes for Meaningful ReST APIs - Conclusion

Collapse
 
_staticvoid profile image
Lucas Santos

In this case I suggest you use other code, the 402 relates to a resource that itself needs a payment, like when you have a premium API and this API is not paid for by the user (just an example).

One code you can use, if your product communicates with something external and you expect something to be true (the payment), you can extend the definition to business rules and use either 412 as this is a precondition for the API to go forth, or 417 (my personal favorite) as it's part of an expectation your server had but it didn't come true.

If you really want to attain to the definition, you can add the Expect header too.