SDKs & OpenAPI
Eight official typed libraries for Node.js, Python, Go, Rust, PHP, C#/.NET, Java, and Ruby — plus an OpenAPI 3.1 specification.
Official SDKs
MTAKit ships eight official, zero-or-minimal dependency SDKs inside the repository under packages/. Every client enforces the same wire contract: automatic Idempotency-Key generation, exponential backoff with Retry-After, quota_exceeded protection, constant-time HMAC-SHA256 webhook verification, and coverage across all 12 API v1 namespaces.
| Language | Package | Path | Runtime | Version |
|---|---|---|---|---|
| Node.js & TypeScript | @mtakit/node | packages/sdk-node | Node 18.17+ / Bun / Deno / Edge | v0.3.0 |
| Python | mtakit | packages/sdk-python | Python 3.9+ (Sync & AsyncIO) | v0.3.0 |
| Go | github.com/mtakit/mtakit-go | packages/sdk-go | Go 1.22+ (Context-aware) | v0.1.0 |
| Rust | mtakit | packages/sdk-rust | Rust 2021 · Tokio + Rustls | v0.1.0 |
| PHP | mtakit/mtakit-php | packages/sdk-php | PHP 8.1+ (PSR-4 · Laravel / Symfony) | v0.1.0 |
| C# / .NET | MTAKit | packages/sdk-dotnet | .NET 8.0+ (ASP.NET Core DI ready) | v0.1.0 |
| Java | com.mtakit:mtakit | packages/sdk-java | Java 17+ / 21 LTS (Spring Boot ready) | v0.1.0 |
| Ruby | mtakit | packages/sdk-ruby | Ruby 3.1+ (Rails / Sidekiq ready) | v0.1.0 |
Install
npm install ./packages/sdk-nodeSend an email
Pass your API key and your MTAKit base URL, or set MTAKIT_API_KEY and MTAKIT_BASE_URL in the environment (legacy MAILFORGE_* variables are also read automatically).
import { MTAKit } from "@mtakit/node";
const mtakit = new MTAKit(process.env.MTAKIT_API_KEY, {
baseUrl: "https://mail.example.com"
});
const { data, error } = await mtakit.emails.send({
from: "Vektor <orders@vektor.io>",
to: "customer@example.com",
subject: "Order 94821 confirmed",
html: "<p>Your shipment is scheduled for tomorrow.</p>"
});Templates
Send stored templates by UUID or URL-safe alias with typed variables and automatic idempotency keys.
const { data, error } = await mtakit.templates.send("order-confirmed", {
from: "Vektor <orders@vektor.io>",
to: "customer@example.com",
variables: { orderId: "94821", carrier: "DHL Express" }
}, {
idempotencyKey: "order-94821-confirm"
});Errors
In Node.js/TypeScript, methods resolve to { data, error } and never throw. All other SDKs raise or return structured error objects carrying the stable machine code, HTTP statusCode, finer-grained apiCode, and field-level details.
const { data, error } = await mtakit.emails.send({
from: "Vektor <orders@vektor.io>",
to: "not-an-address",
subject: "Hi",
text: "Hello"
});
if (error) {
console.log(error.code); // "validation_error"
console.log(error.statusCode); // 422
console.log(error.details); // { to: ["Invalid email address"] }
}| Code | HTTP status | Meaning |
|---|---|---|
missing_api_key | — | No key passed and MTAKIT_API_KEY is unset |
validation_error | 422 | Invalid payload or missing required fields |
unauthorized | 401 | Missing, unknown or revoked API key |
forbidden | 403 | Key lacks the required capability or domain unverified |
not_found | 404 | Resource does not exist in this workspace |
conflict | 409 | Conflict such as version_conflict or not_cancelable |
rate_limited | 429 | Rate limit or quota_exceeded |
server_error | 5xx | Server error after all idempotent retries |
network_error | — | Connection failed |
timeout | — | Per-attempt timeout exceeded |
Retries and idempotency
Every SDK retries up to 2 times by default with exponential backoff (250 ms to 8 s with jitter), honoring Retry-After headers. Calls with apiCode === "quota_exceeded" are never retried, and non-idempotent mutations (resource creation, deletion, email cancellation, version-locked template updates) are only retried on rate limits.
await mtakit.emails.send(email, {
idempotencyKey: `order-${order.id}-receipt`
});
// Client-wide settings
new MTAKit(key, { baseUrl: "https://mail.example.com", timeout: 10_000, maxRetries: 5 });Verify webhooks
Every SDK includes built-in constant-time HMAC-SHA256 helpers to verify the x-mtakit-signature header against the raw request body without external dependencies.
import type { WebhookEvent } from "@mtakit/node";
const event = await mtakit.webhooks.constructEvent<WebhookEvent>({
payload: await request.text(),
signature: request.headers.get("x-mtakit-signature"),
secret: process.env.MTAKIT_WEBHOOK_SECRET!
});
if (event.type === "email.bounced") {
console.log("Bounced:", event.data.email_id);
}Atomic batch sending
batch.send submits up to 100 emails in one atomic request to POST /api/v1/emails/batch. Every item receives a deterministic <prefix>-<index> idempotency key so retries never duplicate a send.
const { data, error } = await mtakit.batch.send(
users.map((user) => ({
from: "Vektor <orders@vektor.io>",
to: user.email,
subject: "Your weekly summary",
text: `Hi ${user.name}, here is your summary.`
})),
{ idempotencyKeyPrefix: "weekly-2026-47" }
);
if (error) console.error(error.details);
else console.log(data.map((item) => item.id));React Email
In @mtakit/node, pass a JSX element as react. The SDK renders both HTML and plain text before sending using @react-email/render.
npm install @react-email/render @react-email/componentsimport { Button, Html } from "@react-email/components";
function WelcomeEmail({ name }: { name: string }) {
return (
<Html>
<h1>Welcome, {name}</h1>
<Button href="https://vektor.io/start">Get started</Button>
</Html>
);
}
await mtakit.emails.send({
from: "Vektor <orders@vektor.io>",
to: "customer@example.com",
subject: "Welcome",
react: <WelcomeEmail name="Ada" />
});OpenAPI 3.1 spec
Every running MTAKit instance serves a machine-readable OpenAPI 3.1.0 document at /api/openapi.json. Import it into Postman, Insomnia, Swagger UI, or your own code generator.
curl -s https://mail.example.com/api/openapi.json | jq '.info, (.paths | keys)'Resource coverage
100% v1 parity across all 8 SDKs
| Namespace | Operations | Node.js / Python / Go / Rust / PHP / .NET / Java / Ruby |
|---|---|---|
| Emails | send, list (+ iterator in Node/Python), get, cancel | emails |
| Batch | atomic send (up to 100 emails) | batch |
| Templates | create, list, get, update, remove, render, send | templates |
| Domains | create, list, get, remove, verify, getTracking, updateTracking | domains |
| Webhooks | create, list, get, update, remove, test, deliveries, secret, retryDelivery + sign/verify/constructEvent | webhooks |
| Suppressions | list, add, remove | suppressions |
| Providers | create, list, get, update, remove, test | providers |
| API keys | create, list, remove | apiKeys / api_keys |
| Inbound | list, get | inbound |
| Automations | create, list, remove | automations |
| Analytics | get (workspace report), domains, email | analytics |
| Deliverability | spamCheck, complaints, auditDomain, listWarmup, createWarmup, updateWarmup, removeWarmup | deliverability |