title: Correct HTTP status code for a not satisfiable REST request
body: <p>I currently develop a task queue with a RESTful API.</p>
  
  <p>In order to handle a task, a worker has to create a lease.</p>
  
  <pre><code>PUT .../leases
  </code></pre>
  
  <p>If the task queue has tasks available, this will succeed, a lease will be created and the server responds with status <code>201</code>.</p>
  
  <p>I am unsure how to handle this case when no tasks are available. It is not possible to create a lease, when no tasks are available. Which HTTP status code would be appropriate for this case?</p>
  
  <ul>
  <li><p><code>204 No Content</code> - The client hasn't made anything wrong, but there is no data. </p></li>
  <li><p><code>400 Bad Request</code> - This is imho not applicable, as it means "the request could not be understood by the server", which is not the case</p></li>
  </ul>
  
  <p>In the meantime I thought that this approach might not be ideal. Either I use <code>503</code>, as recommended of Brian and also backed by a passage of <a href="http://restinpractice.com" rel="nofollow">REST in practice</a>, or I change the whole process.</p>
  
  <p>I was thinking of leases which could be created tentatively. That means</p>
  
  <ol>
  <li><code>PUT</code> to <code>/leases</code></li>
  <li>Either create a lease, assign a task and respond with <code>201</code> or create a tentative lease and respond with <code>202</code></li>
  <li>Tentative leases will stay for some time. If tasks gets available, they are assigned to the tentative leases. If there is no task for a specific period of time, the lease gets deleted and the server will respond with <code>410</code></li>
  <li>The client should then start again with 1.</li>
  </ol>