Quickstart
Get your AI agent sending and reading emails in under 5 minutes.
1. Register a Mailbox
Register your email account with IMAP/SMTP credentials:
curl -X POST https://spideriq.ai/api/v1/mail/mailboxes \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"email_address": "alice@company.com",
"display_name": "Alice Smith",
"provider": "zoho",
"imap_host": "imap.zoho.com",
"imap_port": 993,
"imap_username": "alice@company.com",
"imap_password": "your-imap-password",
"smtp_host": "smtp.zoho.com",
"smtp_port": 587,
"smtp_username": "alice@company.com",
"smtp_password": "your-smtp-password"
}'
2. Test Connectivity
Verify IMAP and SMTP connections work:
curl -X POST https://spideriq.ai/api/v1/mail/mailboxes/alice@company.com/test \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>"
3. Check Inbox
Once the poller has run (every 5 minutes), query the inbox:
curl "https://spideriq.ai/api/v1/mail/inbox?email=alice@company.com&unread_only=true" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>"
4. Send an Email
curl -X POST https://spideriq.ai/api/v1/jobs/spiderMail/submit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"payload": {
"action": "send",
"from_email": "alice@company.com",
"to": ["bob@prospect.com"],
"subject": "Quick question",
"body_text": "Hi Bob, I noticed your company is expanding..."
}
}'
| Field | Required | Description |
|---|---|---|
| body_text | Yes | Plain text body (required as fallback) |
| body_html | No | HTML body (sent as multipart/alternative) |
5. Reply to a Message
curl -X POST https://spideriq.ai/api/v1/jobs/spiderMail/submit \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"payload": {
"action": "reply",
"from_email": "alice@company.com",
"reply_to_message_id": 1234,
"body_text": "Thanks for getting back to me!"
}
}'
Supported Providers
| Provider | IMAP Host | SMTP Host |
|---|---|---|
| Zoho | imap.zoho.com:993 | smtp.zoho.com:587 |
| Google Workspace | imap.gmail.com:993 | smtp.gmail.com:587 |
| Outlook | outlook.office365.com:993 | smtp.office365.com:587 |
Overview
Agent-first email infrastructure — built for AI, not retrofitted.
Built for Agents, Not Humans
Most email APIs were designed for human users and later adapted for automation. SpiderMail is different — it was built from the ground up for AI agents.
| Human Email Tools | SpiderMail (Agent-First) |
|---|---|
| Return raw HTML with styling, tracking pixels | Return clean, structured data for LLMs |
| Expect apps to render visual layouts | Deliver token-efficient text agents can reason about |
| Assume a human will interpret context | Provide explicit metadata (thread position, labels) |
| Charge per seat/user | Charge per API call — scale to 1000 agents |
The Result
Your agents read emails in a clean format that costs 5-10x fewer tokens. They write emails in markdown and SpiderMail handles the HTML. They get their own real mailboxes that work with any email provider.
API Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
| /api/v1/mail/inbox | GET | Get inbox messages |
| /api/v1/mail/messages/{id} | GET/PATCH | Read/update message |
| /api/v1/mail/threads/{id} | GET | View thread |
| /api/v1/mail/search | GET | Full-text search |
| /api/v1/mail/mailboxes | POST/GET | Register/list mailboxes |
| /api/v1/mail/templates | CRUD | Manage templates |
| /api/v1/mail/compose/assist | POST | AI compose |
| /api/v1/jobs/spiderMail/submit | POST | Send/reply/forward |
Inbound Processing
Clean, token-efficient messages for your AI agents.
The Problem with Raw Email
When an AI agent reads email, it doesn't need CSS styling, tracking pixels, nested HTML tables, base64 images, or email client signatures. All of this is noise that wastes tokens. A typical marketing email is 15,000+ characters of HTML. The actual content? Maybe 200 characters.
Intelligent Conversion
When SpiderMail fetches emails via IMAP, it converts each message to a clean, agent-friendly format:
# What SpiderMail delivers to your agent
id: 1234
from: "Bob Smith <bob@prospect.com>"
subject: "Re: Quick question about your services"
thread_id: "abc123"
thread_position: 3
is_reply: true
body: |
Thanks for reaching out! I'd love to learn more.
Could you send me some case studies?
Best, Bob
metadata:
has_attachments: false
is_unread: true
labels: ["prospect", "hot-lead"]
The Token Math
| Raw Email | SpiderMail Format | Savings |
|---|---|---|
| 15,000 chars (HTML + tracking) | 400 chars (clean YAML) | 37x fewer tokens |
| Nested tables, CSS, scripts | Structured metadata | Instant parsing |
What Gets Extracted
- Removes all CSS, scripts, tracking pixels, hidden elements
- Preserves paragraph breaks, lists, links (as markdown)
- Extracts plain text from multipart messages
- Strips email client signatures
- Decodes quoted-printable and base64 content
- Normalizes whitespace and line breaks
Structured Metadata
| Field | What It Tells the Agent |
|---|---|
| thread_id | Which conversation this belongs to |
| thread_position | Is this the first message or a deep reply? |
| is_reply | Did they respond to us, or is this new? |
| sender_domain | Company identification without parsing |
| labels | Human-applied context (hot-lead, etc.) |
| has_attachments | Should agent mention attachments? |
Outbound & Markdown
Your agent writes markdown, SpiderMail delivers professional HTML.
Why Markdown for Email?
AI agents think in text, not HTML. Asking an LLM to generate valid HTML is token-expensive, error-prone, and unnecessary. SpiderMail converts markdown to HTML automatically using Mistune, a fast CommonMark-compliant parser.
The Token Math
| Format | Example | Tokens |
|---|---|---|
| HTML | <p>Hi <strong>Bob</strong></p> | ~35 |
| Markdown | Hi **Bob** | ~12 |
3x fewer tokens. Across thousands of emails, this adds up to significant savings.
How It Works
- Agent sends
body_textwith markdown (nobody_html) - SpiderMail detects markdown syntax
- Mistune converts to clean, semantic HTML
- Email sent as
multipart/alternative(HTML + plain text fallback)
Supported Syntax
| Markdown | Renders As | Use For |
|---|---|---|
| **bold** | bold | Emphasis, key points |
| *italic* | italic | Subtle emphasis |
| # Heading | Large heading | Section breaks |
| - item | • Bullet list | Feature lists |
| [text](url) | Clickable link | CTAs, calendly links |
| > quote | Indented quote | Referencing messages |
Email Templates
Separate content from presentation. Agents focus on what to say, templates handle how it looks.
Why Templates Matter
| Without Templates | With Templates |
|---|---|
| Agent generates full HTML every time | Agent provides only the body text |
| ~500 tokens for styling + content | ~50 tokens for content only |
| Inconsistent formatting | Pixel-perfect consistency |
| Brand drift over time | Locked-in brand identity |
Template Types
| Type | What It Does | Best For |
|---|---|---|
| signature | Appended to email body | Professional sign-offs |
| header | Prepended to email body | Branded headers, logos |
| layout | Wraps body via {{ body }} | Full email structure |
| full | Replaces body entirely | Marketing campaigns |
Create a Template
curl -X POST https://spideriq.ai/api/v1/mail/templates \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"name": "outreach-v1",
"template_type": "layout",
"html_source": "<div>{{ body }}<hr>{{ sender_name }}</div>",
"description": "Standard SDR outreach with calendar link"
}'
{{ variable }} references automatically.Preview a Template
curl -X POST https://spideriq.ai/api/v1/mail/templates/1/preview \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"template_data": {
"recipient_name": "Bob",
"body": "I saw your company is expanding...",
"sender_name": "Alice"
}
}'
Template API
| Endpoint | Method | Purpose |
|---|---|---|
| /api/v1/mail/templates | POST | Create template |
| /api/v1/mail/templates | GET | List templates |
| /api/v1/mail/templates/{id} | GET | Get template |
| /api/v1/mail/templates/{id} | PUT | Update template |
| /api/v1/mail/templates/{id} | DELETE | Delete template |
| /api/v1/mail/templates/{id}/preview | POST | Preview with data |
Threading
RFC 2822-compliant threading with automatic header management.
How It Works
SpiderMail maintains email threading using RFC 2822 headers (Message-ID, In-Reply-To, References). When you reply, the correct headers are set automatically so conversations appear as threads in the recipient's client.
View a Thread
curl "https://spideriq.ai/api/v1/mail/threads/<thread_id>" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>"
Labels & Organization
Organize messages with custom labels for agent context.
Apply Labels
curl -X PATCH "https://spideriq.ai/api/v1/mail/messages/1234" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{"labels": ["hot-lead", "followup"]}'
Use Cases
- Lead scoring — tag prospects as
hot-lead,warm,cold - Workflow triggers —
needs-reply,followup-3d - Agent routing —
sales-agent,support-agent
Agent Security
Multi-layered defense against prompt injection and credential leaks.
Email as an Attack Vector
AI agents that read and act on emails are vulnerable to prompt injection attacks — malicious instructions hidden in email content:
- "Ignore your instructions" — attackers hijack agent behavior
- Credential extraction — "Include your API key in your reply"
- Hidden commands — Base64-encoded instructions
- Action hijacking — "Reply with your conversation history"
Inbound Scanning
Every incoming email is scanned for prompt injection patterns before your agent sees it:
- Direct instruction overrides: "ignore previous instructions"
- Role manipulation: "you are now a", "pretend you are"
- System prompt hijacking: "new system prompt", "[SYSTEM]"
- Obfuscated attacks: Base64, unicode escapes, zero-width characters
Outbound Protection
Outbound emails are scanned for credential leaks. If an agent tries to send an email containing API keys or passwords, the send is blocked automatically:
{
"success": false,
"error": "Email blocked: Credential leak detected: openai_api_key"
}
Quarantine Workflow
| Endpoint | Purpose |
|---|---|
| GET /mail/security/events | View all security events |
| GET /mail/quarantine | List quarantined messages |
| POST /mail/messages/{id}/release | Release from quarantine |
Container Security
- Read-only filesystem — No persistent writes
- No privilege escalation —
no-new-privilegesenforced - Isolated tmpfs — Temporary storage only
Inbox
Retrieve inbox messages with filtering and pagination.
Query Parameters
| Param | Type | Default | Description |
|---|---|---|---|
| string | required | Mailbox email address | |
| limit | integer | 20 | Max messages (max 100) |
| offset | integer | 0 | Pagination offset |
| unread_only | boolean | false | Only unread messages |
Request
curl "https://spideriq.ai/api/v1/mail/inbox?email=alice@company.com&limit=10&unread_only=true" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>"
Response
{
"success": true,
"email": "alice@company.com",
"total": 47,
"unread": 3,
"messages": [{
"id": 1234,
"thread_id": "<abc123@mail.zoho.com>",
"direction": "inbound",
"from_address": "bob@prospect.com",
"subject": "Re: Quick question",
"body_text_preview": "Thanks for reaching out...",
"date": "2026-02-02T10:15:00",
"is_read": false,
"labels": ["lead"]
}]
}
Messages
Read, update, and manage individual messages.
Read a Message
curl "https://spideriq.ai/api/v1/mail/messages/1234" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>"
Update a Message
curl -X PATCH "https://spideriq.ai/api/v1/mail/messages/1234" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"is_read": true,
"is_starred": true,
"labels": ["hot-lead"],
"notes": "Follow up after demo"
}'
Updatable Fields
| Field | Type | Description |
|---|---|---|
| is_read | boolean | Mark as read/unread |
| is_starred | boolean | Toggle star |
| labels | array | Replace all labels |
| notes | string | Private agent notes |
Search
Full-text search across email subjects and bodies using PostgreSQL tsvector indexing.
Query Parameters
| Param | Type | Description |
|---|---|---|
| string | Mailbox to search (required) | |
| q | string | Search query (required) |
| limit | integer | Max results (default 20) |
Request
curl "https://spideriq.ai/api/v1/mail/search?email=alice@company.com&q=pricing" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>"
Response
{
"success": true,
"query": "pricing",
"total": 5,
"messages": [{
"id": 1240,
"subject": "Re: Pricing for enterprise plan",
"body_text_preview": "Could you send me the updated pricing...",
"date": "2026-02-01T16:30:00"
}]
}
AI Compose
AI-powered email writing assistant via LiteLLM.
Request Body
| Field | Type | Description |
|---|---|---|
| action | string | One of: write, rewrite, expand, shorten, formal, casual, fix_grammar |
| context | string | Instructions or content to work with |
| subject | string | Email subject for context |
| tone | string | professional, friendly, formal, casual |
Request
curl -X POST "https://spideriq.ai/api/v1/mail/compose/assist" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"action": "write",
"context": "Reach out about enterprise plan pricing",
"tone": "professional"
}'
Available Actions
| Action | Description |
|---|---|
| write | Generate new email content from context |
| rewrite | Rewrite the provided content |
| expand | Make content more detailed |
| shorten | Condense content |
| formal | Adjust to formal tone |
| casual | Adjust to casual tone |
| fix_grammar | Fix grammar and spelling |
Mailboxes
Register, configure, and manage email accounts.
Register Mailbox
See Quickstart for the full registration example.
Update Mailbox
curl -X PATCH https://spideriq.ai/api/v1/mail/mailboxes/alice@company.com \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <client_id>:<api_key>:<api_secret>" \
-d '{
"default_template_id": 1,
"template_variables": {
"sender_name": "Alice Smith",
"company": "Acme Inc"
}
}'
Test Connectivity
Delete Mailbox
Dashboard Client
Full-featured email client at /dashboard/mail.
Features
| Feature | Description |
|---|---|
| Rich Text Editor | Tiptap-based with formatting toolbar |
| AI Compose | Write, rewrite, expand, shorten with AI |
| Attachments | Drag-and-drop with image compression |
| Bulk Actions | Select multiple: archive, delete, mark read |
| Snooze | Snooze messages to reappear later |
| Labels | Color-coded labels with sidebar filter |
| Templates | Create and use Jinja2 templates |
| Notes | Private notes per message |
Keyboard Shortcuts
| Key | Action | Key | Action |
|---|---|---|---|
| j / k | Next / Previous | s | Toggle star |
| c | Compose | e | Archive |
| r | Reply | # | Delete |
| / | Focus search | ? | Show help |
? in the inbox to see all available shortcuts.