title: What is the appropriate HTTP status code response for a general unsuccessful request (not an error)?
body: <p>I'm creating a RESTful API that will process a number of user interactions, including placing orders using stored credit cards.</p>
  
  <p>In the case of a successful order, I'm returning a 200 OK, and in the case where the order request is malformed or invalid I'm returning a 400 Bad Request. But what should I return if there is a problem during the actual processing of the order?</p>
  
  <ol>
  <li>Client POSTS order to server for a user resource. If user does not exist, 404 Not Found is returned.</li>
  <li>Order format and information is validated. If not valid, 400 Bad Request is returned.</li>
  <li>Order is processed. If the order is successful, a 201 Created is returned for the order. If an unexpected error is encountered, a 500 Server Error is returned.</li>
  </ol>
  
  <p>The last step is the problem - what do I return if the order doesn't complete for any other reason? Possible scenarios could include:</p>
  
  <ul>
  <li>Product is sold out</li>
  <li>User maximum order limit reached</li>
  <li>Credit card transaction failure (insufficient funds, etc.)</li>
  </ul>
  
  <p>This doesn't seem like it would be appropriate for either a 400 or 500. If anything I could see it as a 400 if there's no better code - the request was invalid according to the business rules. It just doesn't seem accurate.</p>
  
  <p>Edit: Also found <a href="https://stackoverflow.com/questions/2190945/what-http-response-code-for-rest-service-on-put-method-when-domain-rules-invalid">this existing discussion</a> of the same topic. All of the answers there seem to point to using status codes for this type of violation, with some discussion between using 400, 409, or the 422 extension.</p>