Integrate
SDKs (TypeScript / Python)
The official TypeScript and Python clients for the simail API — installation, configuration, idempotent sends and error handling.
docs.simail.ai/sdk
Both SDKs are thin, dependency-free clients over the REST API. They read the key from your
code (load it from SIMAIL_API_KEY), set the headers for you and turn problem+json errors into
exceptions with the fields an agent needs. Resource methods are generated from the OpenAPI document
at GET https://api.simail.ai/v0/openapi.json, so they always match the API reference; every client
also exposes a generic request() for any endpoint.
Installing during the beta
Section titled “Installing during the beta”The SDKs are not on npm or PyPI yet. Publishing them is still to be decided, so
npm install @simail/sdk and pip install simail do not work today. Until then:
- Call the REST API directly with
curlorfetch. Each SDK method is one HTTP request from the API reference. - If you have a checkout of the simail source repository, build the packages from it as shown below.
TypeScript
Section titled “TypeScript”Build a tarball in the simail repository (Node 22.18 or later, npm 11), then install it in your project:
# in the simail repositorynpx -y npm@11.21.1 cinpx -y npm@11.21.1 pack -w @simail/sdk # writes simail-sdk-0.0.0.tgz (compiled JavaScript + types)
# in your projectnpm install /path/to/simail-sdk-0.0.0.tgzWorks in Node 22 and later, Cloudflare Workers and other runtimes with a standard fetch. No runtime dependencies. Use it on a server, never in a browser: it needs your API key.
import { Simail, SimailApiError } from "@simail/sdk";
const simail = new Simail({ apiKey: process.env.SIMAIL_API_KEY });
// Call this first: during the private beta, sign-up is closed.const beta = await simail.beta();
// Any endpoint through request(method, path, body?, { idempotencyKey? })const inbox = await simail.request("POST", "/v0/inboxes", { username: "shop-helper", client_id: "shop-helper" }, { idempotencyKey: "create-shop-helper" });
try { await simail.request( "POST", "/v0/inboxes/shop-helper@simail.email/messages/msg_…/reply", { text: "Thanks! Your order shipped today." }, { idempotencyKey: "reply-msg_…-1" }, );} catch (e) { if (e instanceof SimailApiError && !e.retryable) { // e.status, e.code ("thread_locked", "send_blocked", …), e.requestId, e.body (full problem+json) } throw e;}new Simail() only has beta() and request() in its type. To call the generated resource methods
with types, use createSimail(), which returns the same client typed as SimailClient. Methods are
named after the OpenAPI operationId: camelCase in TypeScript (listInboxes, getInbox("inb_…")),
snake_case in Python (list_inboxes, get_inbox("inb_…")). Path parameters come first, then the
body for writes, then options (TS: { query, idempotencyKey }; Python: query= and
idempotency_key=). A list value in query (for example labels) is sent as one comma-joined value (types=a,b),
and an empty, . or .. path parameter is rejected before any request.
import { createSimail } from "@simail/sdk";
const simail = createSimail({ apiKey: process.env.SIMAIL_API_KEY });const { inboxes } = (await simail.listInboxes({ query: { limit: 10 } })) as { inboxes: unknown[] };await simail.listInboxThreads("inb_…", { query: { labels: ["urgent", "billing"] } }); // both labels (AND)| Option | Default |
|---|---|
apiKey | none (without a key only the public endpoints work: GET /v0/beta (beta()), POST /v0/waitlist, POST /v0/agent/sign-up, GET /v0/health, GET /v0/openapi.json; everything else needs an API key) |
baseUrl | https://api.simail.ai |
fetch | the global fetch (pass your own for proxies or tests) |
userAgent | simail-sdk-ts/<version> |
Python
Section titled “Python”Install from the simail repository:
# in the simail repositorypip install ./packages/sdk-pyPython 3.10 or later, standard library only.
import osfrom simail import Simail, SimailApiError
simail = Simail(api_key=os.environ["SIMAIL_API_KEY"])simail.beta()
try: simail.request( "POST", "/v0/inboxes/shop-helper@simail.email/messages/msg_…/reply", {"text": "Thanks! Your order shipped today."}, idempotency_key="reply-msg_…-1", )except SimailApiError as e: if not e.retryable: print(e.status, e.code, e.request_id) # e.body has the full problem+json raiseSimail(api_key=None, base_url="https://api.simail.ai"); requests time out after 30 seconds.
Errors
Section titled “Errors”Both SDKs raise SimailApiError for any non-2xx response:
| Field | From |
|---|---|
status | HTTP status |
code | problem+json code (see Errors) |
retryable | problem+json retryable |
requestId / request_id | request_id, also in the x-request-id header |
body | the whole problem+json object, including human_message, reasons or reason when present |
The SDKs do not retry on their own, so a send is never repeated behind your back. Retry only when
retryable is true, after Retry-After (TS: e.retryAfterSeconds, Python: e.retry_after_seconds; both read the header and fall back to the body’s retry_after_seconds), with the same idempotency key. See
Idempotency.
Never hard-code a key and never pass one through a prompt. Load it from the environment or your secret manager, and give each agent its own inbox-scoped key (Authentication).