title: REST APIs: How to ensure atomicity?
body: <p>I am developing a small REST API. As I got into analyzing all the possible failure scenarios, which I have to handle to create a reliable and stable system, I went into thinking about how to make my APIs atomic.</p>
  
  <p>If we take a simple case of creating a contact through the POST API.</p>
  
  <ul>
  <li>The server gets the POST request for the new contact.</li>
  <li>Creates the contact in the DB.</li>
  <li>Creates a response to send back to the client.</li>
  <li>The server crashes before sending the response.</li>
  <li>The client gets a timeout error (or connection refused?)</li>
  </ul>
  
  <p>The client is bound to think that the contact creation has failed, though, in fact, the contact was in the DB.</p>
  
  <p>Is this a rare case we can ignore? How do big companies deal with such an issue?</p>