# MyEmailAPI > Transactional email infrastructure for developers Base URL: https://api.myemailapi.com Authentication: `Authorization: Bearer ` ## Key Blog Posts - [Why Traditional SMTP is Failing Modern Apps](https://myemailapi.com/blog/why-smtp-fails-modern-apps): SMTP was designed for a different era of the internet. Here is why stateful socket connections are bottlenecking modern serverless architectures, and why HTTP Submission APIs are the future. - [JMAP vs. IMAP: Building Next-Gen Mailbox APIs](https://myemailapi.com/blog/jmap-vs-imap-next-gen-mailbox): Why IMAP is fundamentally broken for the mobile web, and how JSON Meta Application Protocol (JMAP) is revolutionizing the way we build email clients. - [Real-Time Deliverability: Edge Webhook Loops](https://myemailapi.com/blog/real-time-deliverability-edge-webhooks): Why polling email statuses destroys performance, and how to architect self-healing mailing lists using asynchronous edge webhooks. - [Inbound Parsing at Scale: Taming the MIME Standard](https://myemailapi.com/blog/inbound-parsing-at-scale): Securely processing incoming mail via webhooks: How we transform chaotic MIME streams into structured, actionable JSON payloads. - [The Queueing Architecture Behind 1M Sends/Minute](https://myemailapi.com/blog/queueing-architecture-1m-sends): Decoupling API ingestion from SMTP delivery: A deep dive into priority queues, backoff algorithms, and distributed throughput. ## Agent Onboarding To use this or any other MyAPIHQ service as an autonomous agent, follow these steps: 1. **Register an Agent Account**: Create an agent account. Returns `account_id`, `pin`, and a `token` (JWT) in one call — no email or human required. ```bash curl -X POST https://api.myapihq.com/hq/account/agent/create \ -H "Content-Type: application/json" \ -d '{"label": "my-agent"}' ``` 2. **Create a Permanent API Key**: Use the `token` from step 1 to create a workspace-scoped API key (`hq_live_...`). ```bash curl -X POST https://api.myapihq.com/hq/account/create/key \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"name": "my-agent-key"}' ``` 3. **Authenticate**: All subsequent requests must include: `Authorization: Bearer `. The JWT token from step 1 is valid for account and billing endpoints only. All service calls (orgs, funnels, email, domains) require the API key from step 2. ## Endpoints ### POST /email/mailbox/create **Provision a Mailbox** Claim an email address on a domain you own. Costs $0.50 per address, deducted from balance. After 10 addresses on the same domain, catch-all inbox access is unlocked automatically. **Request Body (JSON):** ```json { "domain": string (Required), "username": string (Required), "display_name": string } ``` **Response (JSON):** ```json { "mailbox": string, "status": string, "created_at": string } ``` ### GET /email/mailbox/list/me **List Mailboxes** List all provisioned email addresses in this account. **Response (JSON):** ```json Array<{ "address": string, "domain": string, "display_name": string, "status": string, "sending_enabled": boolean, "emails_quota_remaining": integer, "created_at": string }> ``` ### POST /email/sending/activate **Activate Sending for an Address** Unlocks outbound sending for a claimed mailbox address. One-time cost of $2.50, which grants 500 free outbound emails. After the quota is exhausted, each additional email costs $0.01. **Request Body (JSON):** ```json { "address": string (Required) } ``` **Response (JSON):** ```json { "address": string, "sending_enabled": boolean, "emails_quota_remaining": integer } ``` ### GET /email/outbox/{address} **Read Outbox** List emails sent from a provisioned address, including automated workflow emails. **Parameters:** - `address` (path): (type: string, Required) - `limit` (query): (type: integer) - `offset` (query): (type: integer) **Response (JSON):** ```json { "data": Array<{ "id": string, "provider_message_id": string, "to": Array, "subject": string, "status": string, "is_automated": boolean, "created_at": string, "delivered_at": string }> } ``` ### GET /email/inbox/{address} **Read Inbox** List emails received at a provisioned address. Proxied via our secure mail infrastructure, filtered by recipient at query time. **Parameters:** - `address` (path): (type: string, Required) - `limit` (query): (type: integer) - `offset` (query): (type: integer) **Response (JSON):** ```json Array<{ "message_id": string, "from": string, "subject": string, "preview": string, "received_at": string, "read": boolean }> ``` ### GET /email/message/{message_id} **Get Full Message** Retrieve full email content including text and HTML body. Requires `address` query param for ownership check. **Parameters:** - `message_id` (path): (type: string, Required) - `address` (query): The address this message was received at (for ownership verification) (type: string, Required) **Response (JSON):** ```json { "message_id": string, "from": string, "to": Array, "subject": string, "text": string, "html": string, "received_at": string } ``` ### POST /email/send **Send an Email** Send a transactional email from a claimed address. Sending must be activated first via POST /email/sending/activate. Draws from the 500-email quota; once exhausted, costs $0.01 per email. **Request Body (JSON):** ```json { "from": string (Required), "to": Array (Required), "subject": string (Required), "html": string, "text": string } ``` **Response (JSON):** ```json { "message_id": string, "status": string, "emails_quota_remaining": integer, "failed_recipients": integer } ``` ### GET /email/status/{message_id} **Get Delivery Status** Check delivery status of a sent message and view the event history. **Parameters:** - `message_id` (path): (type: string, Required) **Response (JSON):** ```json { "message_id": string, "status": string (queued|delivered|bounced|failed), "delivered_at": string, "events": Array<{ "type": string, "timestamp": string }> } ``` ### POST /email/templates/generate **Generate Email Template** Generate a complete HTML email template from a natural language prompt. Automatically applies org brand config (colors, logo, font). Returns immediately with a job_id — poll `GET /funnel/jobs/{job_id}` until status is `completed`. The preview_url is public and auto-refreshes while generating. **Request Body (JSON):** ```json { "org_id": string (Required), "prompt": string (Required), "name": string } ``` **Response (JSON):** ```json { "job_id": string, "template_id": string, "status": string, "preview_url": string } ``` ### GET /email/template-jobs/{job_id} **Poll Template Generation Job** Poll the status of a background template generation job. Call repeatedly until status is `completed` or `failed`. **Parameters:** - `job_id` (path): (type: string, Required) **Response (JSON):** ```json { "id": string, "status": string (processing|completed|failed), "template_id": string, "result": { "template_id": string, "subject": string, "preview_url": string }, "error": string - Present only when status is failed } ``` ### GET /email/templates **List Templates** List all email templates for the authenticated org, ordered by most recently updated. **Response (JSON):** ```json Array<{ "id": string, "name": string, "subject": string, "preview_url": string, "created_at": string, "updated_at": string }> ``` ### POST /email/templates/{template_id}/edit **Edit Template via Prompt** Apply a natural language edit to an existing template. Gemini patches the HTML based on the prompt and overwrites the stored version. **Parameters:** - `template_id` (path): (type: string, Required) **Request Body (JSON):** ```json { "prompt": string (Required) } ``` **Response (JSON):** ```json { "template_id": string, "preview_url": string } ``` ### GET /email/templates/{template_id}/preview **Preview Template** Returns the template HTML wrapped in a Gmail-skin iframe-safe shell. Toggle desktop (600px) or mobile (375px) viewport. **Public endpoint — no auth required.** Open directly in a browser. Auto-refreshes while generation is in progress. **Parameters:** - `template_id` (path): (type: string, Required) - `viewport` (query): desktop = 600px width, mobile = 375px width (type: string) **Response:** Preview HTML page ### POST /email/templates/{template_id}/send-test **Send Test Email** Send the template to an inbox for real-client preview. No tracking is injected. Useful for testing rendering in Gmail, Outlook, Apple Mail. **Parameters:** - `template_id` (path): (type: string, Required) **Request Body (JSON):** ```json { "to": string (Required) } ``` **Response (JSON):** ```json { "ok": boolean, "message_id": string } ``` ### DELETE /email/templates/{template_id} **Delete Template** Permanently deletes the template and its associated GCS file. **Parameters:** - `template_id` (path): (type: string, Required) ### POST /hq/billing/setup-payment **Setup Payment Method** Generates a Stripe Checkout Session URL to save a card. The user must visit this URL, enter their card, and complete the setup. A webhook will automatically save the card to the account. **Response (JSON):** ```json { "success": boolean, "data": { "url": string }, "error": string, "meta": object } ``` ## Pricing $0.50 to claim an address. $2.50 to unlock sending with 500 free emails included. --- ## Ecosystem Integration This service is part of the MyAPIHQ ecosystem. You authenticate using an API Key generated from your MyAPIHQ account. To view the full list of available services (like domain registration, funnel building, transactional email, object storage, etc.), fetch [https://myapihq.com/llms.txt](https://myapihq.com/llms.txt).