Skip to main content

SDK Reference

Full API reference for zerodrop-client.

Installation

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-client 0.3.0 or later), generateInbox() 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 null without a key.

generateInbox()

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

waitForLatest()

Waits for an email to arrive. Uses SSE, and falls back to polling automatically. Throws ZeroDropTimeoutError if no email arrives within the timeout, and ZeroDropHeldError at once if ZeroDrop held the email (see Error types).

Options


fetchLatest()

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

ZeroDropEmail type

otp

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

Error types

ZeroDropTimeoutError

Thrown when no email arrives within the timeout.

ZeroDropHeldError

Thrown 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. waitForLatest() throws 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-client 0.4.0. Older versions treat the notice as an email: without a filter, waitForLatest returns it (its otp is null), and a filter such as { hasOtp: true } skips it, so the wait ends in ZeroDropTimeoutError.

ZeroDropNetworkError

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

ZeroDropAuthError

Thrown 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.

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.