title: REST API: Best way to do/undo an action on a resource
body: <p><em>Note: I consider here that <code>POST</code> means "create" and <code>PUT</code> means "update", as GitHub does. This is not the place to argument in favor of <code>POST</code> or <code>PUT</code>.</em></p>
  
  <p>I have a <code>company</code> resource and an <code>assign</code> action. I'm wondering how to translate this behavior in my REST API.</p>
  
  <p>I thought about something like:</p>
  
  <pre><code>PUT /company/:id/assign
  user_id: 5
  </code></pre>
  
  <p>What about if I want to <strong>unassign</strong> this user? </p>
  
  <ul>
  <li>Should I use a boolean as a parameter?</li>
  <li>Should I use an <code>unassign</code> action?</li>
  <li>Should I use use another HTTP verb?</li>
  </ul>
  
  <p>On the latest GitHub API I saw how to <a href="https://developer.github.com/v3/gists/#star-a-gist" rel="noreferrer">star a gist</a>:</p>
  
  <pre><code>PUT /gists/:id/star
  </code></pre>
  
  <p>Why not, but how to <a href="https://developer.github.com/v3/gists/#unstar-a-gist" rel="noreferrer">unstar a gist</a>:</p>
  
  <pre><code>DELETE /gists/:id/star
  </code></pre>
  
  <p>It seems pretty strange to me. You are <strong>updating</strong> an action on a resource and <strong>deleting</strong> it. Weird. I could understand whether <code>POST</code> instead of <code>PUT</code>.</p>
  
  <p><code>POST /gists/:id/star</code> and <code>DELETE /gists/:id/star</code> seems more logic to me. What do you think?</p>
  
  <p><strong>EDIT:</strong> I'm going to work with <code>POST</code> and <code>DELETE</code>. But as this is not possible to send data with the <code>DELETE</code> method, I have to pass the <code>user_id</code> in URL:</p>
  
  <pre><code>POST /company/:id/assign/:user_id
  DELETE /company/:id/assign/:user_id 
  </code></pre>