Search code examples
searchgmailmessagegmail-api

Search for messages with a particular threadId in Gmail API


Using the new gmail api (https://developers.google.com/gmail/api/) I'd like to search for messages with a particular threadId.

My use case is that I'd like to find all messages on a thread that don't have an attachment and aren't a draft. Instead of fetching all the messages in a thread using thread.get and then inspecting each message to check if its a draft or has an attachment (non trivial), I'd rather just issue the query on messages.list of "-has:attachment -is:draft threadId:FOO".

Although I can't seem to find how to specify a threadid when executing a search. Any ideas?


Solution

  • "Supports the same query format as the Gmail search box." ( from: https://developers.google.com/gmail/api/v1/reference/users/messages/list )

    The search query format supported by the Gmail search box is documented here: https://support.google.com/mail/answer/7190?hl=en

    (Short answer is that's not supported.)