Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http status code for failed email send

Consider an API call that creates a user. On success, the user is created and a confirmation email is sent. The response status code is 201.

If the user is not created, the response status code is 422.

What should the response status code be if user is created BUT sending the confirmation email failed?

like image 844
csi Avatar asked Apr 20 '26 05:04

csi


1 Answers

The core of the problem lies in mixing a RESTful resource creation and an RPC-style action. The creation of the user, in a RESTful world, would be the atomic operation and return 201 or 422 (or whatever error code you choose). Then the sending of the confirmation email might be another POST to /api/user/confirmationemailtask that then spins off the email process. When you combine the two you find the areas of ambiguity.

(moved comment to answer for posterity)

like image 196
Edgar Avatar answered Apr 22 '26 19:04

Edgar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!