AegisAI Perspectives · 119

API-based or gateway email security: how they differ and when each one fits

API-based email security reads mail in the mailbox after delivery and can pull it back later, while a gateway holds mail first because MX points to it.

TL;DR
Answer
API-based email security removes mail after delivery and keeps mail flowing in an outage; a gateway holds mail before delivery because the MX record points to it.
Who it's for
IT and security leads choosing where email security sits in mail flow before a gateway renewal or a move to Microsoft 365 or Gmail.
Watch out for
An API design that needs full mailbox access, and a gateway that rewrites messages without ARC sealing and breaks DKIM signatures on the way in.
What AegisAI does
AegisAI works post-delivery through the Microsoft 365 or Google Workspace API. One bad email is pulled from every inbox it reached, forwards included.
Book a demo

See it on your own Google Workspace or Microsoft 365 tenant. No MX change.

Or get the Q3 2026 State of the AI Attack report (free, instant download)

Not ready for a demo? Check your domain (free, about 10 seconds).

API-based or gateway email security: how they differ and when each one fits

API-based email security has the edge on removal after delivery and on outages, and a gateway still wins on holding mail before any mailbox sees it71. AegisAI reads mail through the Microsoft 365 or Google Workspace API after delivery19, so it works after the mailbox receives a message. API-based email security reads mail in the mailbox after delivery, where Microsoft's own purge reaches back only 48 hours11. A gateway sits in front of the mailbox, because the MX record must point to the gateway.

No design is complete: Microsoft says total protection never reaches 100 percent9.

What you can do by the end

  • Trace one message through a gateway and an API-based design, from the MX record to removal.
  • Name what fails in each design during an outage, a throttling event or revoked consent.
  • Decide which design fits a mail policy that must hold, or must never delay, inbound mail.

Where does API-based email security sit in the path of one email?

API-based email security sits after delivery, and a gateway sits before it. Follow one inbound message through both designs in seven steps.

  1. The sender looks up your MX record.

    With a gateway, your domain's MX record must point to the gateway. With an API-based design, the MX record keeps pointing at Microsoft 365 or Gmail.

  2. The gateway screens and passes the message on.

    Microsoft tells you to lock down Exchange Online to accept mail only from that service2. Mail smart-host routed straight to Exchange Online is then rejected.

  3. The platform reads the gateway's address, not the sender's.

    The message adopts the source IP of the last hop in front of Microsoft 3654. Turn on Enhanced Filtering for Connectors to preserve the source IP and sender information.

  4. A gateway that modifies messages without ARC sealing invalidates their DKIM signatures6.

  5. The message lands in the mailbox.

    A service using the Microsoft Graph API scans messages after delivery and can also remove them7.

  6. Zero-hour auto purge (ZAP) searches only the last 48 hours of delivered email, and users are not notified when it moves a message12.

  7. The API service pulls the message back.

    That integration typically needs full access to mailboxes8. Microsoft Graph allows 10,000 API requests in a 10-minute period per app and mailbox13.

Draw these seven steps for your own tenant and mark which product acts at each one.

Short on time? Watch the explainer, or book a demo.

What can API-based email security do after delivery?

API-based email security can remove a message from mailboxes after delivery, which a gateway in front of the platform cannot reach. Using the Graph API to scan after delivery lets the service remove messages it judges malicious or unwanted. A gateway's verdict is final once it passes the message on.

ZAP acts on messages already in a mailbox, within a 48 hour search window. Users are not told when ZAP moves a message, so the help desk needs its own record of what was pulled.

The Outlook service allows four concurrent requests per app and mailbox14, within the 10,000 requests per 10 minutes. Exceeding the limit for one mailbox does not affect the app's access to another mailbox.

Ask every candidate how many mailboxes it can clear in one hour, and where that number is recorded.

What happens when each design fails?

A gateway failure delays inbound mail, and an API failure delays detection. The difference follows from where the MX record points.

When a gateway stops. Senders cannot hand mail to it, so their servers queue the message. RFC 5321 says the retry interval should be at least 30 minutes15, and the give-up time generally needs to be at least 4-5 days. Mail cannot route around the gateway, because Exchange Online rejects mail that did not come through it.

When an API service stops. Delivery continues, because the MX record still points at the platform. Detection and removal wait until the service returns, and messages sit in mailboxes unscanned by it in that time. The platform's own purge still runs inside its 48 hour window.

When the API is throttled or consent is revoked. Requests above the Graph limit wait. An admin who removes the app's mailbox access ends its ability to remove mail.

When authentication breaks. A gateway that rewrites messages without ARC breaks DKIM, and Microsoft 365 sees the gateway's IP unless Enhanced Filtering is on. Read the full outage question set in what happens to my mail flow if you go down.

Write one line per failure mode in your runbook: who notices, and what the user sees.

Compare API-based and gateway email security on the mail path

The table scores both designs on architecture only; the gateway wins one row.

CriterionGateway in the MX pathAPI-based email security after delivery
Where the MX record pointsTo the gatewayTo Microsoft 365 or Gmail, unchanged
Holding mail before any mailbox receives itGateway wins. It scans first, because the MX record points to itNo hold. It scans after delivery
Removal after deliveryNo reach into the mailbox; the platform's purge covers 48 hoursRemoves messages through the Graph API
Sender IP the platform seesThe gateway's, unless Enhanced Filtering is onThe last hop in front of the platform, with no gateway added
If the service stopsSenders queue and retry at least every 30 minutesDelivery continues; detection waits
Access it needsDNS and connector controlFull mailbox access, typically
Volume ceilingSet by the vendor10,000 requests per 10 minutes per app and mailbox

Pick the gateway where a policy says mail must never reach a mailbox before a verdict. Pick API-based email security where a security outage must never stop mail, and where messages must be pulled back after delivery. Running both adds a layer: in-and-out routing counts messages twice in most reporting tools10.

The detection side, AI against rules, is covered in secure email gateway or AI-native email security. The four deployment models, journaling and hybrid included, are in cloud-native email security deployment options. Score your current setup on all seven rows before the next renewal.

How AegisAI handles this

AegisAI works post-delivery through the Microsoft 365 or Google Workspace API26. Mail keeps flowing21. Detection pauses until the service returns. One bad email is pulled from every inbox it reached, forwards included. Removal needs write access your admin grants and can revoke.

Book a demoSee inbound email security

See your own records: Check your domain.

How does the choice play out for one company?

Illustrative example, figures are fictional: Northgate Freight (fictional) has 1,400 mailboxes on Microsoft 365 and a gateway in the MX path. On a Tuesday the gateway is unreachable for 3 hours. Senders queue inbound mail and retry, so 2,100 messages arrive late and none route around it, because Exchange Online accepts mail only from the gateway. Two weeks later a phishing message reaches 220 mailboxes at 09:10 and is identified as malicious at 11:40 the next day. The gateway's verdict was final, so the admin team relies on the platform's 48 hour purge and finds 37 users opened it. In a 30-day trial of an API-based layer in monitoring mode, the same tenant records 0 delayed messages during a 2 hour outage of the API service, and 14 messages flagged after delivery that the gateway had passed.

Rebuild this timeline with your own outage hours and post-delivery detections before you choose.

How to measure it in 30 days

Track three numbers, each in a system you already run.

  • Inbound messages delayed or rejected at the connector. It lives in message trace, filtered to the gateway's inbound connector.
  • Messages removed after delivery, and how long each sat in mailboxes. It lives in Threat Explorer for ZAP actions, and in the API service's removal log.
  • Throttled API requests. It lives in the API service's own log, against the 10,000 requests per 10 minutes limit.

Compare the three numbers for each design on day 30, and keep the one whose failures you can live with.

Questions people ask

Why does API-based email security have the edge over gateway-based approaches?

It has the edge on removal after delivery and on outages. A Graph API service can remove messages after delivery, and its outage does not stop mail, because the MX record still points at the platform. A gateway still wins on holding mail before delivery.

Does API-based email security need an MX record change?

No. A gateway needs the MX record pointed to it. An API-based service reads the mailbox through the platform's API after delivery, so the MX record stays as it is.

What happens to my mail if the gateway goes down?

Senders queue and retry, at intervals of at least 30 minutes, for at least 4-5 days. Mail cannot bypass the gateway while Exchange Online accepts mail only from it.

What access does an API-based email security tool need?

Microsoft says a Graph API integration typically requires full access to mailboxes. Review the vendor's security and support practices before you grant it.

Does a gateway break email authentication?

It can. A gateway that modifies messages without ARC sealing invalidates DKIM signatures, and Microsoft 365 sees the gateway's IP as the source unless Enhanced Filtering is on.

Is Microsoft's own purge enough after delivery?

ZAP covers the last 48 hours of delivered email and does not notify users. Check whether your threats are found within that window.

Sources

  1. (Microsoft Learn, Manage mail flow using a third-party cloud service with Exchange Online)
  2. (Microsoft Learn, Enhanced filtering for connectors in Exchange Online)
  3. (Microsoft Learn, Integrate non-Microsoft security services with Microsoft 365)
  4. (Microsoft Learn, Zero-hour auto purge in Microsoft Defender for Office 365)
  5. (Microsoft Learn, Microsoft Graph service-specific throttling limits)
  6. (IETF, RFC 5321 Simple Mail Transfer Protocol)
  7. (AegisAI, Inbound email security)
  8. (AegisAI, What happens to my mail flow if you go down?)
  9. (AegisAI, Secure email gateway or AI-native email security?)
  10. (AegisAI, Cloud-native email security deployment options)

Recent posts

Every email, investigated.