Every Agent Account has a real mailbox with a real address — something like [email protected] or [email protected]. It sends outbound mail, receives inbound mail, maintains folders, and has its own deliverability reputation. To anyone interacting with it over SMTP, it’s indistinguishable from a human-operated mailbox.
This page walks through what actually happens when an Agent Account sends a message, what happens when mail arrives, and how the mailbox surface maps onto Nylas’s existing Email API. If you’re looking for the complete endpoint list, see Supported endpoints.
The mailbox at a glance
Section titled “The mailbox at a glance”When you provision an Agent Account, Nylas creates a hosted mailbox on one of your registered domains and returns a grant_id. That grant ID is the only identifier you need — the existing Messages, Threads, Folders, Drafts, and Attachments endpoints all work against /v3/grants/{grant_id}/... the same way they do for any other grant.
Every mailbox comes with:
- A primary email address on a domain you’ve verified, or on a Nylas-provided
*.nylas.emailtrial domain. - Six system folders provisioned automatically:
inbox,sent,drafts,trash,junk, andarchive. You can create custom folders alongside them withPOST /folders. System folder names are reserved. - A thread index built from standard RFC 5322 headers so replies group into conversations. See Email threading for agents for the full treatment.
- An optional
app_passwordon the grant for IMAP and SMTP submission, so end users can connect Outlook or Apple Mail alongside the API. See Mail client access.
Inbound and outbound mail use the same Nylas-hosted infrastructure whether you drive the mailbox through the API, through IMAP/SMTP, or through both at once. Anything sent via IMAP/SMTP appears as a message in the API; anything sent via the API appears in the Sent folder in the mail client.
Receiving email
Section titled “Receiving email”An inbound message goes through this lifecycle:
- The remote sender delivers to Nylas over SMTP. The sending server looks up the MX record for the Agent Account’s domain and opens an SMTP connection to Nylas’s inbound infrastructure.
- Nylas runs policy checks. If the grant has a policy attached, any rules that match inbound conditions run here —
blockrejects the message at the SMTP layer,mark_as_spamroutes it tojunk,assign_to_folderroutes it to a named folder, and so on. Rule evaluations are logged for audit. - The message is stored and delivered to a folder. Default destination is
inbox; rules or the sender’s address can route it elsewhere. - The webhook fires. Any subscription matching
message.createdon the grant receives a payload identical in shape tomessage.createdfor any other provider. If the body exceeds ~1 MB, the trigger name becomesmessage.created.truncatedand the body is omitted — fetch the full message withGET /messages/{id}in that case. - The thread is indexed. Nylas reads
In-Reply-ToandReferencesheaders to attach the message to an existing thread, or creates a new thread if it’s a conversation starter. The webhook payload’sthread_idis the key your agent uses to reconstruct conversation state.
Inbound attachments count against the limits set by your plan and the grant’s policy — limit_attachment_size_limit, limit_attachment_count_limit, and limit_attachment_allowed_types control what’s accepted. Messages that exceed these caps are rejected at the policy stage before message.created fires.
If you’d rather poll than subscribe to webhooks, GET /messages with received_after works fine for batch workflows. Webhooks are preferred for near-real-time agent loops because delivery typically lands within seconds of the SMTP handoff.
Sending email
Section titled “Sending email”Outbound from the API uses POST /v3/grants/{grant_id}/messages/send. The body is JSON, or multipart for attachments, and takes the same shape as sending from any other grant — to, cc, bcc, subject, body, and optional reply_to_message_id, tracking_options, and custom_headers.
curl --request POST \ --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/messages/send" \ --header "Authorization: Bearer <NYLAS_API_KEY>" \ --header "Content-Type: application/json" \ --data '{ "to": [{ "email": "[email protected]" }], "subject": "Following up on your demo request", "body": "Hi Alice, thanks for your interest..." }'A few things to know about how sends work:
- Send happens from the Agent Account’s address. Nylas stamps the
Fromheader with the grant’s primary address. Agent Accounts can’t spoof other identities. - Threading is automatic on replies. Pass
reply_to_message_idand Nylas populatesMessage-ID,In-Reply-To, andReferencesso the reply threads in every recipient’s mail client. Details in Email threading for agents. - Policy rules can block or rewrite outbound. If the grant’s policy has rules with
outbound.typeor recipient matchers, they run before the message hits SMTP. See Policies, Rules, and Lists. - Send quota is tracked per account. The default soft limit is 100 messages per account per day; paid plans go higher. Sends over the limit return an error on the API call.
- Attachments are capped by standard email sizes. Messages over the recipient server’s size limit (typically ~25 MB) will be rejected by the remote MX.
After Nylas hands the message to the recipient’s server, deliverability signals come back as webhooks:
| Trigger | When it fires |
|---|---|
message.send_success | The recipient server accepted the message. |
message.send_failed | The send failed before the message reached the recipient — typically a policy block, deliverability gate, or spam complaint from the recipient. |
message.bounce_detected | Hard or soft bounce returned by the remote server. |
Because Nylas owns the SMTP path end-to-end for Agent Accounts, these triggers give you send-side visibility on every outbound message. Sender reputation is shared across every Agent Account on a given domain, so treat outbound hygiene as a domain-level concern. See Domain warming when you’re rolling out a new custom domain at scale.
Drafts
Section titled “Drafts”Drafts are supported with full CRUD at /v3/grants/{grant_id}/drafts. Create one, update it, then POST to /drafts/{draft_id} to send — the send action on an existing draft behaves the same as POST /messages/send. This is useful for human-in-the-loop flows where an agent proposes a reply and a reviewer approves it before delivery.
Threading replies
Section titled “Threading replies”Replies group into conversations using the standard Message-ID, In-Reply-To, and References headers. Every message.created webhook payload includes a thread_id — fetch the thread to reconstruct what’s been said before your agent decides how to respond:
curl --request GET \ --url "https://api.us.nylas.com/v3/grants/<GRANT_ID>/threads/<THREAD_ID>" \ --header "Authorization: Bearer <NYLAS_API_KEY>"To send a reply that threads correctly, pass reply_to_message_id on POST /messages/send. Nylas sets the threading headers on the outbound message automatically.
For the full protocol-level explanation and the state-mapping pattern for multi-turn conversations, see Email threading for agents.
Keep in mind
Section titled “Keep in mind”- Fetch the thread before responding. An agent that drafts replies needs the full thread history to avoid repeating itself or contradicting earlier messages. Don’t reply off the single-message payload from the webhook alone.
- Inbound filtering is cheaper than reacting to noise. Use rules to drop obvious spam, loops, and mailer-daemon replies before
message.createdfires. It keeps the agent from reacting to auto-replies. - Mail clients see the same mailbox as the API. Anything sent via IMAP/SMTP appears in the Messages API; anything sent via the API appears in the Sent folder in the mail client. There’s no separation between protocol traffic and API traffic.
- Native message tracking isn’t available on API sends.
message.openedandmessage.link_clickedaren’t emitted for messages sent directly throughPOST /messages/sendon an Agent Account. Deliverability is tracked through the send and bounce triggers above.
What’s next
Section titled “What’s next”- Agent Accounts quickstart to send and receive your first message in under 5 minutes
- Email threading for agents for how replies group into threads and how to reply in-thread
- Policies, Rules, and Lists to filter inbound and outbound mail at the policy layer
- Mail client access (IMAP & SMTP) to expose the mailbox to Outlook, Apple Mail, and other clients
- Supported endpoints for the full reference of Messages, Threads, Folders, Drafts, and Attachments endpoints
- Handle email replies and multi-turn conversations for reply-loop patterns
- Messages API and Send email for the general Email API surface these endpoints share with connected grants