The email infrastructure
for autonomous document processing.
Developers building document processing agents need primitives to receive attachments via email, read their contents, and reply with extracted data or confirmation. Mailgent provides the email API so your agent can process documents the moment they arrive in the inbox.
API Primitives used
mail.list_messagesDetect incoming documents
Monitor the inbox for new emails with attachments. Filter by sender or label to isolate document submissions.
mail.get_threadRetrieve attachments
Load the full message including attachments. Access document content for parsing and extraction.
mail.replyReturn results
Reply to the sender with extracted data, validation results, or confirmation of processing.
mail.update_labelsTrack processing status
Label threads as processing, completed, or needs-review. Keep the pipeline organized.
Documents arrive by email. Processing them should not require a human.
Contracts, invoices, tax forms, and applications still arrive as email attachments — hundreds per day in many organizations. Someone has to open each one, extract the relevant data, enter it into a system, and reply with confirmation. This manual loop is slow, error-prone, and does not scale.
Developers building document agents need email infrastructure that receives attachments, provides their content for parsing, and sends replies with results. Mailgent provides mail.list_messages for intake, mail.get_thread for attachment access, and mail.reply to close the loop with senders.
How to build it.
mail.list_messagesReceive documents
Your agent monitors the inbox with mail.list_messages, detecting new emails with attachments. It filters by label to separate document submissions from general mail.
mail.get_threadExtract and process
The agent retrieves the full message with mail.get_thread, accesses the attachment, and runs extraction logic — parsing fields, validating data, or classifying the document type.
mail.replyReply with results
The agent replies to the sender using mail.reply with the extracted data, any validation errors, or a confirmation that the document was processed successfully.
Example prompt
“Check the documents inbox for new submissions. Extract company name, amount, and date from any invoices. Reply to each sender confirming receipt and flag anything over $10,000 for manual review.”
What developers build.
Invoice data extraction
Build agents that receive invoices via email, extract line items and totals, and push structured data to your accounting system.
Application processing
Build agents that receive application forms via email, validate completeness against required fields, and reply with confirmation or a detailed list of missing information.
Contract review intake
Build agents that receive contracts via email, extract key terms, renewal dates, and liability clauses, label by urgency, and route to the appropriate legal reviewer.
Expense report processing
Build agents that receive expense receipts via email, extract amounts, categories, and merchant names, and reply with approval status based on your company's expense policy rules.
Why not use a document processing platform?
Document processing platforms require you to upload files to their portal or set up complex integrations. But your documents already arrive by email. Adding a separate upload step is friction that slows the process and confuses senders.
Mailgent meets documents where they arrive. mail.list_messages detects them, mail.get_thread retrieves them, and mail.reply closes the loop — all in the same email thread. No portals, no uploads, no extra steps for the sender.
Encrypted in transit
All email communication uses TLS encryption. Documents are never transmitted in plaintext.
Isolated processing
The document agent operates in its own identity. It cannot access other mailboxes or unrelated data.
Processing audit log
Every document received, processed, and responded to is logged with timestamps for compliance.