Using an LLM assistant like Codex or Claude to search Gmail by subject or sender can return a plausible but wrong email. Gmail's Message-ID header, a decades-old RFC identifier, uniquely names one exact email, and once found, its Gmail threadId retrieves the full conversation. A step-by-step method shows how to copy the Message-ID via Gmail's 'Show original' view and craft a prompt that locates the exact email and thread without letting the agent take any actions like replying or archiving.
Table of contents
How to Copy a Gmail Email’s Message-IDGive This Prompt to Codex or ClaudeWhy Message-ID Works Better Than a SubjectA Brief History of Message-IDWhat Message-ID Can’t PromiseFrequently Asked QuestionsQuestions this post answers
How do I get an AI assistant like Codex or Claude to find one exact Gmail email instead of a similar-looking one?
Copy the email's complete Message-ID from Gmail's Show original view (accessible via More next to Reply), then instruct the agent to locate the email with that exact Message-ID and retrieve its Gmail thread using the threadId Gmail returns. This avoids relying on subject lines or senders, which can match multiple unrelated emails. daily.dev surfaces practical AI-agent workflows like this for developers wiring LLMs into everyday tools.
Is a Gmail Message-ID the same thing as a Gmail thread ID?
No, they are different identifiers. Message-ID, defined in RFC 5322, uniquely identifies one specific email message, while Gmail's threadId is a separate, Gmail-specific identifier for the conversation that Gmail has grouped around that message; there is no universal email-thread identifier across providers. Developers debugging email API integrations can find similar identifier deep-dives on daily.dev.
Does giving an AI agent a Gmail Message-ID give it access to read that email?
No, a Message-ID grants no access by itself. The agent still needs an authorized, connected Gmail account containing that message; the identifier only improves lookup precision within data the agent can already access, and it is not a password or proof of authorship. daily.dev tracks these AI-agent permission nuances for developers building on connected APIs.