Spam Detection for Inbound Agent Mail Nylas has introduced spam detection policies for its Agent Accounts, which are mailboxes built for AI agents and system identities. The policies filter spam at the mailbox layer before the agent processes messages, using DNS blocklists and header anomaly detection to prevent contaminated context. Developers can also create rules to block or mark messages as spam based on sender fields, with support for maintainable lists. Spam aimed at a human wastes attention; spam aimed at an autonomous agent becomes input — so filter it before the model ever sees it: curl --request POST \ --url "https://api.us.nylas.com/v3/policies" \ --header "Authorization: Bearer $NYLAS API KEY" \ --header "Content-Type: application/json" \ --data '{ "name": "Agent inbound hygiene", "spam detection": { "use list dnsbl": true, "use header anomaly detection": true, "spam sensitivity": 1.0 } }' That's a policy for Agent Accounts — the Nylas-hosted mailboxes currently in beta built for AI agents and system identities. Attach it to a workspace and every account in that workspace inherits the spam settings. Here's what each knob does and how to tune it for a reader that never gets suspicious on its own. An LLM agent will earnestly process whatever lands in its inbox: phishing, junk, auto-replies, and messages whose entire purpose is to manipulate the model. The threat isn't annoyance, it's contaminated context. Policy-level spam detection gives you two independent signals, evaluated when mail arrives over SMTP: use list dnsbl use header anomaly detection Both run before your application sees anything, which is the right place for this work. Filtering at the mailbox layer is cheaper than teaching every downstream prompt to be skeptical, and per the mailboxes guide https://developer.nylas.com/docs/v3/agent-accounts/mailboxes/ , inbound filtering also keeps the agent from reacting to loops and mailer-daemon noise. A message that trips spam detection routes to the junk folder — one of the six system folders every account ships with — instead of inbox . The agent's normal read path listing inbox messages, reacting to inbound webhooks for new mail simply doesn't encounter it, but nothing is destroyed: you can inspect junk when you're tuning, and false positives are recoverable. Retention is part of the same policy. You can set limit spam retention period and limit inbox retention period independently, with one constraint worth knowing up front: the spam window must be shorter than the inbox window, so junk clears out ahead of real mail. For an agent that handles transient workflows, aggressive spam retention is free hygiene — there's no reason to store a month of junk for a mailbox whose job resolves in hours. Spam detection is probabilistic; sometimes you know the answer in advance. For senders you've already judged, a rule with a block action rejects the message at the SMTP layer — it's never stored, never delivered, never an event your application has to ignore: curl --request POST \ --url "https://api.us.nylas.com/v3/rules" \ --header "Authorization: Bearer $NYLAS API KEY" \ --header "Content-Type: application/json" \ --data '{ "name": "Block spam-domain.com", "priority": 1, "trigger": "inbound", "match": { "conditions": { "field": "from.domain", "operator": "is", "value": "spam-domain.com" } }, "actions": { "type": "block" } }' There's a softer middle ground too: a rule with a mark as spam action routes matching mail to junk deterministically, without the terminal finality of block . Use it for gray-area senders — newsletters, notification floods — that you want out of the agent's way but available for review. Rules run in priority order from 0 to 1000, lower numbers first, so put your specific known-bad rules ahead of broad pattern matches. One scoping note: inbound rules match only sender fields — from.address , from.domain , and from.tld — with the operators is , is not , contains , and in list . String matching is case-insensitive, so you don't need variants for SPAM-Domain.com . Hardcoding domains into rule conditions works until the third spam wave, when someone has to edit rule definitions again. Lists fix the maintenance problem: a list is a typed collection domain , tld , or address that rules reference through the in list operator, so updating who's blocked means updating the list — every rule that points at it picks up the change immediately, and a non-engineer can do it. Add to the blocklist — up to 1000 items per request curl --request POST \ --url "https://api.us.nylas.com/v3/lists/$LIST ID/items" \ --header "Authorization: Bearer $NYLAS API KEY" \ --header "Content-Type: application/json" \ --data '{ "items": "spam-domain.com", "another-bad-domain.net" }' Values are lowercased and trimmed on write, validated against the list's type a domain list rejects full email addresses , and duplicates are silently ignored — so an automated "report spam" pipeline can append blindly. The rule side just swaps the operator: { "field": "from.domain", "operator": "in list", "value": "