http status code for failed email send

3.8k views Asked by At

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?

1

There are 1 answers

2
Edgar On BEST ANSWER

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)