Skip to main content Switch to mobile version faivelo 0.4.1 Official Faivelo SDK for Python: email inboxes for your code and your AI agents. Send, receive, drafts, labels, threads, domains, DNS and webhooks.
pip install faivelo Copy PIP instructions
The official Faivelo SDK for Python. Give your code, or your AI agent, a real email inbox on your own domain: send and receive, drafts a person can review, labels, threads, attachments, domains and DNS, and signed webhooks.
Every inbox is a full mailbox, so a person can open the same inbox in Faivelo webmail (or any IMAP client) and see exactly what the agent sees.
pip install faivelo Requires Python 3.9 or newer. Fully typed; the only dependency is httpx.
Create an API key in your Faivelo dashboard under Settings → Developers, then:
from faivelo import Faivelo faivelo = Faivelo("fvl_live_xxxxxxxx") # or set FAIVELO_API_KEY and call Faivelo() For asyncio, AsyncFaivelo has the same methods:
from faivelo import AsyncFaivelo async with AsyncFaivelo() as faivelo: usage = await faivelo.usage.get() Each key carries scopes (mail:read, mail:send, mailboxes:write, ...). A call fails with a 403 if the key lacks the scope it needs; the required scope is noted in every method's docstring.
Responses are plain dicts with the API's own keys (message["messageId"]). faivelo.types describes them for your editor and type checker.
mailbox = faivelo.mailboxes.create(domain="acme.com", local_part="agent", display_name="Acme Agent") print(mailbox["fullAddress"]) # agent@acme.com print(mailbox["credentials"]["password"]) # shown once: also works over IMAP/SMTP Send
sent = faivelo.mailboxes.send( "agent@acme.com", to="user@example.com", subject="Your order has shipped", text="Tracking number 1Z999...", idempotency_key="order-4812-shipped", ) The message lands in the mailbox's Sent folder. The From name is the mailbox's display_name (else the domain default); from_name sets another for one message, and a send with no name at all returns a hint. idempotency_key makes a retry safe: a repeat with the same key within 24 hours returns the first result with replayed: True instead of sending again, which matters when an agent loop retries a step.
Attachments take bytes and are encoded for you. Leave out content_type and it is guessed from the file name (application/octet-stream when the name says nothing):
faivelo.mailboxes.send( "agent@acme.com", to="user@example.com", subject="Invoice", text="Attached.", attachments=[{"filename": "invoice.pdf", "content": open("invoice.pdf", "rb").read()}], ) A request body is capped at 4.5 MB and base64 adds a third, so inline files top out around 3 MB. For a bigger file (up to 25 MB per message), upload it first and send it by upload_id:
import httpx data = open("deck.pdf", "rb").read() slot = faivelo.mailboxes.create_attachment_upload("agent@acme.com", content_type="application/pdf", size_bytes=len(data)) httpx.put(slot["upload"]["url"], content=data, headers=slot["upload"]["headers"]).raise_for_status() faivelo.mailboxes.send( "agent@acme.com", to="user@example.com", subject="The deck", text="Attached.", attachments=[{"filename": "deck.pdf", "upload_id": slot["uploadId"]}], ) emails.send takes inline files only: up to 10, 10 MB in total.
To send the same email to many people, use one batch call:
batch = faivelo.mailboxes.send_batch( "updates@acme.com", subject="Hi {{first_name}}, the beta opens Monday", text="Hi {{first_name}}, your invite code is {{code}}.", recipients=[ {"email": "ada@example.com", "fields": {"first_name": "Ada", "code": "ADA-1"}}, {"email": "linus@example.com", "fields": {"first_name": "Linus", "code": "LIN-2"}}, ], idempotency_key="beta-invites-2026-10", ) status = faivelo.mailboxes.get_batch("updates@acme.com", batch["id"]) # queued/sent/delivered/bounced per recipient One templated email to many recipients in a single call: Faivelo queues it, sends at your plan's pace and tracks each recipient. The per-call cap depends on the plan; a batch over it, or over the remaining monthly allowance, is refused whole.
inbox = faivelo.messages.list("agent@acme.com", limit=20) for summary in inbox["messages"]: if summary["seen"]: continue message = faivelo.messages.get("agent@acme.com", summary["uid"]) faivelo.mailboxes.send( "agent@acme.com", to=message["from"], subject="Re: " + message["subject"], text="Thanks, we are on it.", in_reply_to=message.get("messageId"), ) The whole conversation a message belongs to, the mailbox's own replies included:
thread = faivelo.messages.thread("agent@acme.com", uid) for item in thread["messages"]: # oldest first print(item["date"], item["from"], item["subject"]) Search, and download attachments:
results = faivelo.messages.search("agent@acme.com", from_="billing@supplier.com", date_after="2026-09-01") pdf = faivelo.messages.download_attachment("agent@acme.com", uid, "invoice.pdf") open("invoice.pdf", "wb").write(pdf["content"]) Drafts: let a person approve before it sends
A draft is a real message in the mailbox's Drafts folder. Your agent writes it, a person opens it in webmail and edits or sends it, or your code sends it once it has the go-ahead.
draft = faivelo.drafts.create( "agent@acme.com", to="customer@example.com", subject="Refund approved", text="We have refunded your order in full.", ) current = faivelo.drafts.get("agent@acme.com", draft["uid"]) # includes edits a person made faivelo.drafts.send("agent@acme.com", draft["uid"]) drafts.update replaces a draft's content and returns it under a new uid. drafts.list and drafts.delete do what they say.
Add send_at to schedule a send. The message waits in the mailbox's Drafts folder until its time, where a person can read it; deleting it there cancels the send.
from datetime import datetime, timedelta, timezone result = faivelo.mailboxes.send( "agent@acme.com", to="customer@example.com", subject="Following up", text="Checking in on your order.", send_at=datetime.now(timezone.utc) + timedelta(days=1), # or "2026-10-05T09:00:00-04:00" ) scheduled = result["scheduled"] faivelo.drafts.send("agent@acme.com", uid, send_at="2026-10-05T09:00:00Z") # schedule an existing draft waiting = faivelo.scheduled.list("agent@acme.com")["scheduled"] faivelo.scheduled.cancel("agent@acme.com", scheduled["id"]) # the draft stays in Drafts A datetime must carry a timezone. The send goes through the same checks at its time as a send made then, with the API key that scheduled it. scheduled.list also shows the last week's finished sends: sent, cancelled, or failed with a reason.
Guardrails for software using a mailbox. An entry is an address or a domain (which covers its subdomains); a block entry always wins, and once an allow list has any entry, only what it names gets through.
faivelo.lists.replace("agent@acme.com", { "send": {"allow": ["acme.com", "customer.com"]}, # the API and MCP may only send here "receive": {"block": ["spammer.com"]}, # filed in Junk, never the inbox }) faivelo.lists.add("agent@acme.com", {"receive": {"allow": ["newcustomer.com"]}}) faivelo.lists.remove("agent@acme.com", {"send": {"allow": ["customer.com"]}}) lists = faivelo.lists.get("agent@acme.com") Send lists are checked on every API and MCP send (a refused recipient is a 403; nothing is sent). Receive lists are enforced by the mail server at delivery. Changing lists needs an account key with mailboxes:write: an agent key can read its lists but not loosen them.
Labels: keep state on the message
Labels are free-form lowercase tags. Use them to track where each message is in your agent's workflow, with no database of your own.
faivelo.messages.label("agent@acme.com", uid, add=["needs-reply"]) todo = faivelo.messages.list("agent@acme.com", label="needs-reply") faivelo.messages.label("agent@acme.com", uid, add=["answered"], remove=["needs-reply"]) Transactional email
Send from any address on one of your verified domains, no mailbox required:
email = faivelo.emails.send( from_="Acme ", to="user@example.com", subject="hello world", html=" it works!
", ) status = faivelo.emails.get(email["id"]) # delivery status and events Templates designed in the dashboard are sent by alias: template_alias="receipt", variables={"name": "Ada"}.
usage = faivelo.usage.get() print(usage["plan"], usage["sends"]["remaining"], "sends left until", usage["resetsAt"]) Webhooks
Faivelo signs every webhook. Verify the raw request body before trusting it:
from faivelo import FaiveloWebhookError, verify_webhook @app.post("/webhooks/faivelo") async def faivelo_webhook(request): try: event = verify_webhook(await request.body(), request.headers.get("x-faivelo-signature"), WEBHOOK_SECRET) except FaiveloWebhookError: return Response(status_code=400) if event["type"] == "message.received": ... return Response(status_code=200) Pass the body exactly as received (bytes or str), not parsed JSON. Signatures older than five minutes are refused; change that with tolerance_seconds.
Approved partners resell mailboxes under their own brand. A partner key acts on your end customers, never on your own account:
customer = faivelo.partner.customers.create( email="owner@smiledental.example", company_name="Smile Dental", attestation={"firstPartyListsOnly": True, "termsAcceptedOnBehalf": True}, ) domain = faivelo.partner.domains.add(customer["id"], domain="smiledental.example", brand_name="Smile Dental") status = faivelo.partner.domains.get(customer["id"], "smiledental.example", verify=True) if status["verified"]: inbox = faivelo.partner.mailboxes.create(customer["id"], "smiledental.example", local_part="hello") print(inbox["credentials"]) # shown once # Storage (bytes; None restores the default), a one-time webmail sign-in link, and their old address book faivelo.partner.domains.set_storage(customer["id"], "smiledental.example", 50 * 1024**3) faivelo.partner.mailboxes.set_storage(customer["id"], "smiledental.example", "hello@smiledental.example", 5 * 1024**3) link = faivelo.partner.mailboxes.create_webmail_session(customer["id"], "smiledental.example", "hello@smiledental.example") report = faivelo.partner.mailboxes.import_contacts(customer["id"], "smiledental.example", "hello@smiledental.example", open("contacts.vcf", "rb").read(), dry_run=True) # Migrate a domain off your own IMAP server: test, create, poll, sync after the MX switch, finish source = {"host": "mail.oldhost.example", "port": 993, "tls": True} csv = "email,password\nhello@smiledental.example,their-current-password" test = faivelo.partner.migrations.test(customer["id"], "smiledental.example", source=source, csv=csv) created = faivelo.partner.migrations.create(customer["id"], "smiledental.example", source=source, csv=csv) faivelo.partner.migrations.get(customer["id"], "smiledental.example", created["migration"]["id"]) faivelo.partner.migrations.sync(customer["id"], "smiledental.example", created["migration"]["id"]) # after the MX switch faivelo.partner.migrations.finish(customer["id"], "smiledental.example", created["migration"]["id"]) # Your hostname in every customer's mail settings, the emails sent about them, and the monthly usage report faivelo.partner.mail_hosts.add("mail.yourcompany.com") # $19/month per name once live emails = faivelo.partner.outbox.list(customer=customer["id"]) usage = faivelo.partner.reports.usage(month="2026-09") csv_file = faivelo.partner.reports.usage_csv(month="2026-09") Mint a mailbox key with faivelo.partner.api_keys.create(customer_id, name="My app") to read and send a customer's mail from your product through mailboxes and messages.
Any non-2xx response raises FaiveloError with the API's message and the HTTP status, plus the error body's fields: code (stable, branch on it), fix (what to change), docs (a link to the code's entry) and param (the field at fault, on validation errors). They are None when the request never reached Faivelo.
from faivelo import FaiveloError try: faivelo.mailboxes.send("agent@acme.com", to="user@example.com", subject="hi", text="hello") except FaiveloError as error: print(error.status_code, error) # 0 means the request never reached Faivelo if error.code == "CLAIM_REQUIRED": print(error.fix) Every code is listed at https://faivelo.com/docs/developers/errors.
Faivelo( api_key, base_url="https://faivelo.com/api/v1", timeout=30.0, # seconds http_client=httpx.Client(), # your own client, for proxies or retries ) Developing
The async client (src/faivelo/_async_client.py) is the one edited by hand. The sync client is generated from it:
python scripts/gen_sync.py python -m unittest discover -s tests License
MIT View SPDX License List
ai agents email faivelo imap inbox mailbox smtp transactional
Development Status 4 - Beta
Intended Audience Developers
Programming Language Python :: 3
Topic Communications :: Email
Release files for faivelo 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 94.1 kB
Release files / faivelo-0.4.1.tar.gz
Release files / faivelo-0.4.1-py3-none-any.whl
Security for faivelo 0.4.1
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Nov 23, 2026 2 release files No provenance
Oct 4, 2026 2 release files No provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




