With a service account and domain-wide delegation, the REST API searched threads, read raw messages, and saved reply drafts in the right threads with links kept exactly as written. Replacing a draft by creating a new one and deleting the old one worked cleanly. Setting up delegation and building MIME replies by hand took real effort.
- What worked
- Search queries match the web search syntax, raw message reads let us verify every draft byte for byte, a draft created with threadId plus In-Reply-To and References lands in the existing thread, and drafts.delete answers with an empty 204.
- What got in the way
- threads.get rejects format=raw with a 400, so raw messages had to be fetched one by one with messages.get. Building a reply that looks like a web client reply (quoted parent, signature) is all left to the caller.