Open a five-message reply chain and look at how much of it is actually new. One or two sentences at the top, then a wall of quoted history, a signature, a legal disclaimer, and "Best regards." For a human skimming, that noise is just clutter. For code, it's worse: feed that blob to a language model for summarization and you're paying for tokens of quoted text the model has already seen, and showing it as a preview means the same quoted chain on every message. Cleaning email pulls out just the meaningful text, and this post wires it up with the Email API and the CLI.
It's a worked use case rather than an endpoint tour, covering the clean conversation endpoint and the cleaned-message webhook from two angles: the HTTP API your backend calls and the nylas CLI for cleaning a message from the terminal. I work on the CLI, so the commands below are the ones I reach for when I want to see what cleaning actually returns.
Two ways to clean a message
There are two paths, and which you pick depends on whether you have a message in hand or want every incoming message cleaned automatically. The on-demand path is a single endpoint: you pass one or more message IDs and get back the cleaned text, which suits a "summarize this thread" button or a one-off processing job. The automatic path is a webhook, message.created.cleaned, that fires a cleaned version of every new message once you enable the Clean Conversations feature for your application.






