title: Efficient way of syncing Gmail Inbox messages using the new Gmail API?
body: <p>A web application sends an email on behalf of a <strong>UserA</strong> to <strong>UserB</strong>, using the new Gmail API (<strong><em>Users.messages: send</em></strong>). </p>
  
  <p>The synchronous response contains <em>threadId</em>, <em>messageId</em> which are stored in the database. </p>
  
  <p>We then query the history API for any changes in user's inbox (<strong><em>Users.history: list</em></strong>).</p>
  
  <p>Is there an efficient way to get all the updates since last sync (new replies, read/unread changes)?</p>
  
  <p>One implementation that we tried was to filter the history API results through a custom label. Unfortunately, we noticed that once a thread/message is tagged with a specific label any subsequent responses are not labeled automatically and new replies are not included in the history API response.</p>
  
  <p>A second approach was to query threads using gmail advanced search for a particular label and date (e.g. after:2014/08/29 label:MY_LABEL). The problem was that gmail does not return threads that were created before 2014/08/29 but had a reply on that date.</p>
  
  <p>Any scalable suggestions would be greatly appreciated.</p>