Skip to main content
View as Markdown

Python SDK

The published Python SDK is a prerelease. Set base_url explicitly because this package version defaults to the previous API host.

pip install mailbot-sdk==0.1.0b2
Release blocker

The idempotencyKey / idempotency_key parameters exist in the repository source but have not been published. The pinned prerelease above (0.1.0b2) predates them, so install from this repository's sdk/ directory to run these samples until a new prerelease is published. The REST API and MCP server already require the Idempotency-Key.

import os
from mailbot import MailBot

client = MailBot(
api_key=os.environ["MAILBOT_API_KEY"],
base_url="https://getmail.bot/v1",
)
inbox = client.inboxes.create(username="support-bot", idempotency_key="onboarding-inbox-001")
print(inbox["id"], inbox["address"])

Creating methods (inboxes.create, messages.send, messages.reply, domains.create, webhooks.create) require a keyword-only idempotency_key, a stable string of 8 to 255 characters. The SDK sends it as the Idempotency-Key header and does not generate one. Generate it once per logical action. Reuse it only to repeat the exact same call when no answer came back; after a server error, read the message back first. See Idempotency.

A failed call raises MailBotError (or AuthError, RateLimitError, NotFoundError, ComplianceError) with status, code and request_id set. Branch on code and quote request_id to support. The SDK retries only a 5xx, never a 4xx. See Reading a Send Failure.

Use the returned inbox ID in message operations. Do not construct shared-domain addresses yourself.

The REST API is also available directly, and the MCP server supports MCP-compatible clients. There is no published framework adapter package.