I have a project that requires us to track whether a reply has been sent for an email. We send mails using Gmail API and its getting send successfully without any issues. But if some user has setup an auto response service and that service has a different subject the gmail treats it as a seperate thread.
In my backend I get specific threads from users and iterate to check if there is any entry present in the messages having header 'To' as the mail creator. 
It works as it should but Iam not able to track emails outside the thread. Is there any solution to do this?
By thread I'm assuming you mean "E-mail" thread and not "processing thread".
I'm also assuming that you might be looking for the "References" or "In-reply-to" headers to identify the email threads, but in my opinion, if that information is not added by the auto-responder, then you should be looking for other headers like the Reply-to which theoretically should identify with the original address that you sent an email to, that combined with looking for the newest thread associated with that email you could make a list of potential associated threads. If that information is not present, you could only do the time difference approach and for example if the sent email was at 10:40 and the auto-responder replies at 10:41 then that might be a match, but if you send 1000 emails to different addresses in a very short amount of time then your life is a lot more difficult and I'm not sure it's even possible in that case.
Tracking Email replies