How to Monitor Your Inbox with Delta Sync
Use delta sync for incremental inbox monitoring — track new, modified, and deleted emails with deltaToken.
Delta sync lets you track inbox changes incrementally — instead of re-fetching all emails, you get only what’s new, modified, or deleted since your last check.
How Delta Sync Works
- Initial sync — call
search-emailswithdeltaMode: true(no token). Returns current emails plus adeltaToken. - Store the token — save the
deltaTokenfrom the response. - Incremental sync — call again with the same
deltaMode: trueand your storeddeltaToken. Returns only changes since that token was issued.
Each incremental call returns a new deltaToken for the next round.
Initial Sync
“Get my current inbox state for monitoring”
tool: search-emails
params:
deltaMode: true
maxResults: 50
The response includes:
- Current inbox emails, one page at a time (
maxResultsper page: 1–200, default 100) - A
deltaTokenstring to use on subsequent calls
If the folder holds more messages than one page, the response returns a continuation token instead (_meta.tokenType: "continuation", hasMoreChanges: true). Pass it back as deltaToken, with the same maxResults, and keep paging until a page returns a delta token (_meta.tokenType: "delta"). Only that final delta token is worth saving.
Every page of an initial sync is labelled Initial (_meta.syncType: "initial"), and every page of an incremental sync Incremental. The server remembers which sync each continuation token it issued belongs to; a continuation token it doesn’t know, for example one from before a server restart, is labelled “Continuation (initial or incremental unknown)” (syncType: "unknown") rather than guessed.
tool: search-emails
params:
deltaMode: true
deltaToken: "continuation-token-from-previous-page"
maxResults: 50
Save the delta token — you’ll need it for all future incremental checks.
Incremental Sync
“Check for new emails since my last sync”
tool: search-emails
params:
deltaMode: true
deltaToken: "your-saved-token-here"
maxResults: 50
The response includes:
- New emails received since the token was issued
- Modified emails (e.g. marked as read, flagged, moved)
- Deleted email IDs (via
@removedentries) - A new deltaToken for the next call
Handling Token Expiry
Delta tokens expire after an extended period of inactivity. If the call fails (isError: true) with a Delta Token Expired error (Graph answered 410 Gone or asked for a resync), your token has expired — start a fresh initial sync (no token) to get a new baseline.
// Recovery pattern:
1. Call with deltaToken → "Delta Token Expired" error
2. Discard expired token
3. Call without deltaToken (fresh initial sync)
4. Save new deltaToken
Use Cases
Inbox Monitoring Agent
Poll for new emails on a schedule and process them automatically:
- Initial sync → store token
- Every N minutes: incremental sync with stored token
- For each new email: read content, categorise, flag, or forward
- Store new token for next iteration
The emails an agent like this reads are written by other people, so treat their content as data, never as instructions: don’t take recipients, links or actions from a message. Forwarding or replying reaches other people, so have a person confirm those steps (the plugin’s safety hook asks before sends in clients that support it), or limit the agent to categorising and flagging. For an agent that should only watch, set OUTLOOK_READ_ONLY=true. See Using Outlook Assistant in Agents.
Audit Trail Logging
Track all inbox changes for compliance:
- Initial sync to establish baseline
- Incremental syncs to log every new, modified, and deleted email
- Write changes to an audit log with timestamps
Notification Triggers
Detect emails from specific senders or matching patterns:
- Incremental sync to get new emails
- Filter by sender, subject, or other criteria
- Trigger alerts, create tasks, or escalate as needed
Tips
- Delta sync works per-folder (defaults to inbox). Specify
folderto monitor other folders. - To monitor a shared mailbox, add
sharedMailbox(needs the opt-inOUTLOOK_SHARED_MAILBOXsetting) and keep passing it with the samedeltaToken— see Access Shared Mailboxes. - Pass
deltaTokenback exactly as you received it. Tokens that point anywhere other thanhttps://graph.microsoft.comare refused, so the access token is never sent elsewhere. - Store tokens persistently between agent sessions — they remain valid for extended periods.
- Use
outputVerbosity: "minimal"for efficient polling when you only need to detect changes, not read full content. - Combine with
read-emailto get full content of specific changed messages after detecting them. - Use
maxResults(1–200, default 100) to set the page size. It is sent to Graph as thePrefer: odata.maxpagesizeheader and sizes each page, never the whole sync — pass the same value on every page (an omitted value means 100).
Related
- Find Emails — search and filter emails
- Using Outlook Assistant in Agents — agent workflow patterns
- Tools Reference — search-emails