Skip to main content

Python SDK

Full API reference for zerodrop — the ZeroDrop Python SDK.

Installation

No dependencies. Python 3.8+. On Python 3.8 to 3.10, use zerodrop 0.3.0 or later: earlier versions raise a ValueError on every email, because they can’t parse its timestamp there.

ZeroDrop class

Parameters

Without an API key, anyone who knows an inbox’s name can read it, one sender can reach only 5 different inboxes a day (past that, the inbox gets a notice from notice@zerodrop.dev instead of the email), and each inbox expires 30 minutes after its latest email, on a shared domain. With a free key (zerodrop 0.2.0 or later), generate_inbox() starts names with your key’s prefix, only your key can read those inboxes, and mail to them isn’t limited. mail.prefix holds the prefix ("k7x2"), or None without a key.

generate_inbox()

Generates a unique inbox address instantly. No network request. With a key, the name starts with your prefix.

wait_for_latest()

Polls until an email arrives in the inbox. Raises ZeroDropTimeoutError if no email arrives within the timeout, and ZeroDropHeldError at once if ZeroDrop held the email (see Error types).

Parameters


fetch_latest()

Fetches the latest email without waiting. Returns None if the inbox is empty or no email matches the filter. Raises ZeroDropHeldError if nothing matches and the inbox holds a notice that ZeroDrop held an email.

Email Filtering

Filter emails by sender, subject, body, or extracted fields. Useful when multiple emails land in the same inbox.
All string filters are case-insensitive partial matches.

ZeroDropEmail type

otp

4-8 digit numeric code extracted from the email body. Detected near labels like code, otp, pin, verification. None if not detected.
Verification or reset URL extracted from the email body. Detected for URLs containing verify, confirm, reset, token, activate, or auth. None if not detected.

ZeroDropFilter type


Error types

ZeroDropTimeoutError

Raised when no email arrives within the timeout.

ZeroDropHeldError

Raised when ZeroDrop held the email. Without an API key, one sender can reach only 5 different inboxes a day. Past that, the email isn’t stored, and the inbox gets a notice from notice@zerodrop.dev instead. wait_for_latest() raises at once rather than waiting for the timeout, and the message is the server’s reason. A free key from zerodrop.dev/keys lifts the limit for inboxes under your key’s prefix.
ZeroDropHeldError is new in zerodrop 0.3.0. Older versions treat the notice as an email: without a filter, wait_for_latest returns it (its otp is None), and a filter such as ZeroDropFilter(has_otp=True) skips it, so the wait ends in ZeroDropTimeoutError.

ZeroDropNetworkError

Raised when the API is unreachable. Includes a link to the status page.

ZeroDropAuthError

Raised on a 401: the inbox belongs to an account’s prefix and the request had no key or the wrong one. The message carries the server’s reason.

pytest example


Parallel test runs

generate_inbox() runs locally — no network request, no throttling. Without an API key, though, one sender can reach only 5 different inboxes a day; with a free key, inboxes under your prefix aren’t counted:

Workspace domain

A Workspace receives mail on a domain of its own, such as yourcompany-qa.com, so sign-up forms that block disposable domains accept it, and every inbox on it can be read only with your key. Set the domain as ZERODROP_DOMAIN, or pass it as domain= (zerodrop 0.4.0 or later), next to your key:
Any address on the domain works, including one you name yourself: mail.wait_for_latest("qa@yourcompany-qa.com") reads the inbox k7x2-qa, where ZeroDrop files that mail. mail.domain holds the domain in use. Use the domain as your API keys page shows it. See Workspaces for how mail on it is filed.

Free vs Workspace

Get a Workspace at zerodrop.dev/pricing

Zero telemetry

The SDK does not send analytics, usage metrics, or environment data to any server. The only network requests made are explicit inbox polls to zerodrop.dev/api/inbox/{name}. Your CI pipeline is your business.