title: Complex Transactions in REST?
body: <p>This is a follow up question to :
  <a href="https://stackoverflow.com/questions/147207/transactions-in-rest">Transactions in REST?</a></p>
  
  <p>How does one implement a REST API that offers full transaction capabilities to it's clients?</p>
  
  <p>For example, if a client wants to create a transaction that will do the following operations:</p>
  
  <ul>
  <li>create one or more objects.</li>
  <li>update one or more objects.</li>
  <li>delete one or more objects.</li>
  </ul>
  
  <p>While it's a valid requirement for a transaction, it seems to break the REST requirements to use PUT to create, POST to update and DELETE to delete.</p>
  
  <p>My current solution involves handling the entire system as one hierarchical object structure and using the POST operation. For example:</p>
  
  <pre><code>POST /system
  {
      "Users" : [
          {
              "ID":"123",
              "name":"bob"   
              // update the user with ID matching 123, 
              // set his name to "bob"
          },
          {
              "ID":"456",
              "delete":"true"
              // trigger a delete on user with ID 456
          }
      ],
      "Products" : [
          {
              "name":"foo"   
              // create a product named "foo" since no ID is provided
          },
      ]
  }
  </code></pre>
  
  <p>So far, this satisfies most REST requirements except for the "delete" flag which isn't really a piece of data.</p>
  
  <p>I'm curious to know if anyone found a better solution.</p>