Node.js SDK
Install the published prerelease matching these examples:
npm install @yopiesuryadi/mailbot-sdk@0.1.0-beta.3
The SDK is a prerelease package. Its version suffix describes the SDK, not the status of the hosted service. The registry's latest tag points to an older release, so use the explicit version above.
The idempotencyKey / idempotency_key parameters exist in the repository source but have not been published. The pinned prerelease above 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 { MailBot } from '@yopiesuryadi/mailbot-sdk';
const client = new MailBot({
apiKey: process.env.MAILBOT_API_KEY!,
baseUrl: 'https://getmail.bot',
});
const inbox = await client.inboxes.create({
username: 'support-bot',
idempotencyKey: 'onboarding-inbox-001',
});
console.log(inbox.id, inbox.address);
The Node client appends /v1 to its configured host. Python takes the full versioned URL instead.
Methods that create something or start a delivery (inboxes.create, messages.send, messages.reply, domains.create, webhooks.create, events.replay) require a caller-supplied idempotencyKey, 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 throws a MailBotError (or AuthError, RateLimitError, NotFoundError, ComplianceError) with status, code and requestId set. Branch on code and quote requestId to support. The SDK retries only a dropped connection or a 5xx, never a 4xx. See Reading a Send Failure.
Use inbox.id for API calls and the returned inbox.address for email. Shared-domain addresses contain an account suffix.
SDK methods do not cover every API feature. Use the REST reference for operations not exposed by this version. See Quick Start for a send example.