postaby PREVED Create a free account

posta API documentation

posta is a mailbox API: programmable mailbox hosting. Connect a domain you control, then create real IMAP/SMTP mailboxes with one API call. It is built for developers and AI agents that need to both receive and send mail. Machine-readable: /openapi.json, /llms.txt, /llms-full.txt.

Quickstart (5 minutes)

  1. Create a free account and confirm your email. Free early access: 1 domain, 1 mailbox, 500 MB, up to 25 outgoing messages a day per mailbox.
  2. In the dashboard, create an API key (scopes: domains:read, domains:write, mailboxes:read, mailboxes:write). The key (pk_live_…) is shown once. Keys can only be created in the dashboard, not with another key.
  3. Add a domain, publish the DNS records it returns, verify, then create a mailbox:
# 1. Add a domain (needs a key with domains:write)
curl -s https://posta.preved.co/v1/domains \
  -H "Authorization: Bearer $POSTA_KEY" -H "Content-Type: application/json" \
  -d '{"name": "example.com"}'
# → 201 {"id": 7, "status": "pending", "dns": {"ownership_txt": ..., "mx": ..., "dkim": null}, ...}  (DKIM key is generated at verification)

# 2. Publish the DNS records from the response, then ask posta to check them
curl -s -X POST https://posta.preved.co/v1/domains/7/verify -H "Authorization: Bearer $POSTA_KEY"
# → {"status": "verified", ...} once DNS has propagated. Then GET /v1/domains/7 returns the DKIM TXT record to publish.

# 3. Create a mailbox (needs mailboxes:write; you choose the password)
curl -s https://posta.preved.co/v1/mailboxes \
  -H "Authorization: Bearer $POSTA_KEY" -H "Content-Type: application/json" \
  -d '{"domain_id": 7, "local_part": "agent", "password": "a-long-random-passphrase"}'
# → 201 {"id": 12, "address": "agent@example.com", "quota_mb": 500, "status": ..., "created_at": ...}

# 4. Send a message from it (needs mail:send)
curl -s https://posta.preved.co/v1/mailboxes/12/send \
  -H "Authorization: Bearer $POSTA_KEY" -H "Content-Type: application/json" \
  -d '{"to": "you@example.net", "subject": "Hello", "text": "Sent by my agent."}'
# → 202 {"message_id": "<...@example.com>", "accepted": ["you@example.net"], "refused": []}

# 5. Read incoming mail (needs mail:read). First call: latest messages; then poll with since_uid
curl -s "https://posta.preved.co/v1/mailboxes/12/messages?limit=10" -H "Authorization: Bearer $POSTA_KEY"
# → 200 {"mailbox": "agent@example.com", "messages": [{"uid": 41, "from": [...], "subject": ..., "text": ..., "html": ..., "attachments": [...]}], "next_since_uid": 41, "has_more": false}
curl -s "https://posta.preved.co/v1/mailboxes/12/messages?since_uid=41" -H "Authorization: Bearer $POSTA_KEY"

Authentication

Send Authorization: Bearer pk_live_… on every request. Each endpoint requires a scope; a missing scope returns an error. Base URL: https://posta.preved.co/v1. Errors have one shape: {"error": {"code": "…", "message": "…"}}.

Endpoints

Python

import os, requests

API = "https://posta.preved.co/v1"
H = {"Authorization": f"Bearer {os.environ['POSTA_KEY']}"}

domain = requests.post(f"{API}/domains", headers=H, json={"name": "example.com"}).json()
# publish domain["dns"] records at your DNS provider, then:
requests.post(f"{API}/domains/{domain['id']}/verify", headers=H).raise_for_status()

box = requests.post(f"{API}/mailboxes", headers=H, json={
    "domain_id": domain["id"], "local_part": "agent", "password": "a-long-random-passphrase"}).json()
print(box["address"])

Node.js

const API = "https://posta.preved.co/v1";
const H = { Authorization: `Bearer ${process.env.POSTA_KEY}`, "Content-Type": "application/json" };

const domain = await (await fetch(`${API}/domains`, { method: "POST", headers: H, body: JSON.stringify({ name: "example.com" }) })).json();
// publish domain.dns records at your DNS provider, then:
await fetch(`${API}/domains/${domain.id}/verify`, { method: "POST", headers: H });

const box = await (await fetch(`${API}/mailboxes`, { method: "POST", headers: H,
  body: JSON.stringify({ domain_id: domain.id, local_part: "agent", password: "a-long-random-passphrase" }) })).json();
console.log(box.address);

Use the mailbox (IMAP and SMTP)

Connect to mail.posta.preved.co. IMAP: port 993 (SSL). SMTP: port 587 (STARTTLS) or 465 (SSL). The username is the full address; the password is the one you set when creating the mailbox.

import imaplib, smtplib
from email.message import EmailMessage

# Receive
imap = imaplib.IMAP4_SSL("mail.posta.preved.co", 993)
imap.login("agent@example.com", PASSWORD)
imap.select("INBOX")
status, data = imap.search(None, "UNSEEN")

# Send
msg = EmailMessage(); msg["From"] = "agent@example.com"; msg["To"] = "you@example.net"
msg["Subject"] = "Hello"; msg.set_content("Sent from a posta mailbox.")
with smtplib.SMTP("mail.posta.preved.co", 587) as s:
    s.starttls(); s.login("agent@example.com", PASSWORD); s.send_message(msg)

Receive with Node.js (full example with tests, contributed by GreedyC). Use the mailbox password here, not an API key:

// npm install imapflow
import { ImapFlow } from "imapflow";

const client = new ImapFlow({ host: "mail.posta.preved.co", port: 993, secure: true,
  auth: { user: "agent@example.com", pass: process.env.POSTA_MAILBOX_PASSWORD }, logger: false });
await client.connect();
const lock = await client.getMailboxLock("INBOX", { readOnly: true });   // read-only: nothing is marked read or deleted
try {
  if (client.mailbox.exists) {
    const msg = await client.fetchOne("*", { uid: true, envelope: true });   // newest message, headers only
    console.log(msg.envelope.from, msg.envelope.subject, msg.envelope.date);
  }
} finally {
  lock.release();
  await client.logout();
}

Python SDK and MCP server (for AI agents)

Python client with an IMAP helper that waits for a new message (for example a verification code), and an MCP server that gives Claude, ChatGPT or any MCP client tools to create mailboxes, send, and read mail. Both run on your machine; reading uses the mailbox password and posta never sees what you read. Source and docs: github.com/preved-co/posta/clients.

pip install "git+https://github.com/preved-co/posta.git#subdirectory=clients/python"

from posta import Posta, Inbox
p = Posta()                                             # POSTA_KEY
p.mailboxes.send(12, "you@example.net", "Hello", text="Hi from my agent")
with Inbox("agent@example.com", MAILBOX_PASSWORD) as inbox:
    msg = inbox.wait_for(subject_contains="verification code", timeout=180)
    print(msg.text)

# MCP server (tools: list_domains, list_mailboxes, create_mailbox, send_message, list_messages, read_message, wait_for_message)
pip install "git+https://github.com/preved-co/posta.git#subdirectory=clients/mcp"
# Claude Desktop / Claude Code: {"mcpServers": {"posta": {"command": "posta-mcp",
#   "env": {"POSTA_KEY": "pk_live_…", "POSTA_MAILBOX": "agent@example.com", "POSTA_MAILBOX_PASSWORD": "…"}}}}

Webhooks: get told when mail arrives

Instead of polling IMAP, set a webhook on a mailbox. When new mail arrives we POST to your https URL, usually within a minute. We don't read your mail: the event only says how many new messages arrived; fetch them with GET /v1/mailboxes/{id}/messages?since_uid=… (scope mail:read) or over IMAP with the mailbox password. Messages already in the mailbox when you set the webhook are not reported.

curl -s -X PUT https://posta.preved.co/v1/mailboxes/12/webhook \
  -H "Authorization: Bearer $POSTA_KEY" -H "Content-Type: application/json" \
  -d '{"url": "https://your-app.example.com/posta-hook"}'
# → {"url": "...", "active": true, "secret": "9f2c..."}   (the secret is shown only here; PUT again to rotate)

# What we POST to your URL:
{"event": "message.received", "mailbox": "agent@example.com", "mailbox_id": 12,
 "new_messages": 1, "total_messages": 8, "sent_at": "2026-10-11T09:30:00+00:00"}

Verify every request: the Posta-Signature header is t=<unix time>,v1=<hex>, where v1 is HMAC-SHA256 with your secret over "<t>." + raw body. Reject old timestamps (for example older than 5 minutes). Answer with any 2xx. If your endpoint fails we retry every minute; after about an hour of failures we turn the webhook off and email you. The URL must be https and resolve to a public address; redirects are not followed.

import hashlib, hmac, time

def verify(secret: str, header: str, raw_body: bytes) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    if abs(time.time() - int(parts["t"])) > 300:
        return False
    expected = hmac.new(secret.encode(), parts["t"].encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])

DNS records for a domain

Publish the records returned by the API. Required for verification: the ownership TXT (name _posta-verify.<domain>, value posta-verify=…) and MX 10 mail.posta.preved.co. Recommended for sending reputation: SPF include:spf.posta.preved.co, the DKIM TXT (returned in dns.dkim after verification), and a DMARC record (_dmarc TXT, e.g. v=DMARC1; p=none).

Errors

Limits and rules

Free early access: 1 domain, 1 mailbox, 500 MB, up to 25 outgoing messages a day. Need more? Tell us what you need by email (merhaba@preved.co) and we'll put together a plan for you. Bulk and marketing mail is not allowed (acceptable use). Delivery to Outlook/Hotmail addresses may currently be rejected. Terms: /terms, privacy: /privacy.