DocsSDKs (Node & Python)

SDKs (Node & Python)

Official client libraries wrap the REST API with a typed, ergonomic interface. Both are dependency-light and read your API key.

Node

npm install mailhuset
import { Mailhuset } from "mailhuset";

const mh = new Mailhuset(process.env.MAILHUSET_API_KEY);

await mh.emails.send({
  from: "you@yourdomain.com",
  to: "user@example.com",
  subject: "Verify your email",
  html: "<p>Welcome 👋</p>",
});

send returns { id, status }. Also mh.emails.get(id) and mh.emails.list({ limit: 20 }). A non-2xx response throws a MailhusetError with .status and .code. Requires Node 18+ (global fetch). Point at another host with new Mailhuset(key, { baseUrl: "https://api.mailhuset.com/v1" }).

Python

pip install mailhuset
from mailhuset import Mailhuset

mh = Mailhuset("mh_live_…")

mh.emails.send(
    sender="you@yourdomain.com",
    to="user@example.com",
    subject="Verify your email",
    html="<p>Welcome 👋</p>",
)
In Python the sender field is sender= (since from is a reserved word).

send returns {"id": ..., "status": ...}. Also mh.emails.get(id) and mh.emails.list(limit=20). A non-2xx response raises MailhusetError with .status and .code. Point at another host with Mailhuset(key, base_url="https://api.mailhuset.com/v1"). No dependencies beyond the standard library.

Which to use

The SDKs are the fastest path for app code. For one-off scripts, other languages, or maximum control, call the REST API directly. Everything the SDKs do is a thin wrapper over it.


Need help? Email support@mailhuset.com.