Fork me on GitHub

an HTTP question - i'm creating a sub-resource which causes some upstream actions which may fail, despite the creation of the sub-resource being successful (registering a phone # against a user sends an SMS to the user, which may fail) ... what's the best way of indicating this to a client, which needs to be able to present a "we registered your phone#, try again later for the SMS" to the user... i could use a 502, but 502s can happen for other reasons, so could be a pain to process... does it sound reasonable to put a status-description structure into a 201 to indicate a qualified success ?


I really think of 5xx as being for truly exceptional things and these don't sound like exceptions as such.


imo response code only really matters for what you want intermediaries to do


no, something good happened, just not all the good things the user asked for


actual end-point applications can’t do enough from response code alone, and have to make sure intermediaries aren’t sending responses that happen to have the same code - so they need to inspect the body anyway


I think something 2xx and then enough info for the client to decide what (if anything) to do


yeah, that's the way i'm leaning too


maybe a 201 with a location to where the result of the upstream actions will be available


I like @tcoupland ’s idea…


success and then check later where what the end result it


not 5XX that is really for server failures I think.


I'd reply with either a 201 or 202 depending on the specifics... 202 is good for communicating that the request was recorded - but its success or failure isn't really known yet - usually because of asynchrony.


but I'm guessing you don't consider the action to have failed if the sms isn't sent... so 201 is probably best


yeah, it has partially succeeded if the sms isn't sent, but the user will want to re-send the sms at some point later


i went with 201


Some things will automatically raise alerts on 5xx - definitely avoid! I think 2xx + payload is the way to go.

oliy21:09:49 <- choose the cat which seems most appropriate to what you want to do. then use the code it represents