Skip to content

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.

LanguagePackagePathRuntimeVersion
Node.js & TypeScript@mtakit/nodepackages/sdk-nodeNode 18.17+ / Bun / Deno / Edgev0.3.0
Pythonmtakitpackages/sdk-pythonPython 3.9+ (Sync & AsyncIO)v0.3.0
Gogithub.com/mtakit/mtakit-gopackages/sdk-goGo 1.22+ (Context-aware)v0.1.0
Rustmtakitpackages/sdk-rustRust 2021 · Tokio + Rustlsv0.1.0
PHPmtakit/mtakit-phppackages/sdk-phpPHP 8.1+ (PSR-4 · Laravel / Symfony)v0.1.0
C# / .NETMTAKitpackages/sdk-dotnet.NET 8.0+ (ASP.NET Core DI ready)v0.1.0
Javacom.mtakit:mtakitpackages/sdk-javaJava 17+ / 21 LTS (Spring Boot ready)v0.1.0
Rubymtakitpackages/sdk-rubyRuby 3.1+ (Rails / Sidekiq ready)v0.1.0

Install

npm install ./packages/sdk-node

Send 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"] }
}
CodeHTTP statusMeaning
missing_api_key—No key passed and MTAKIT_API_KEY is unset
validation_error422Invalid payload or missing required fields
unauthorized401Missing, unknown or revoked API key
forbidden403Key lacks the required capability or domain unverified
not_found404Resource does not exist in this workspace
conflict409Conflict such as version_conflict or not_cancelable
rate_limited429Rate limit or quota_exceeded
server_error5xxServer 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.

Terminal
npm install @react-email/render @react-email/components
welcome.tsx
import { 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.

Fetch OpenAPI 3.1 spec
curl -s https://mail.example.com/api/openapi.json | jq '.info, (.paths | keys)'

Resource coverage

100% v1 parity across all 8 SDKs

NamespaceOperationsNode.js / Python / Go / Rust / PHP / .NET / Java / Ruby
Emailssend, list (+ iterator in Node/Python), get, cancelemails
Batchatomic send (up to 100 emails)batch
Templatescreate, list, get, update, remove, render, sendtemplates
Domainscreate, list, get, remove, verify, getTracking, updateTrackingdomains
Webhookscreate, list, get, update, remove, test, deliveries, secret, retryDelivery + sign/verify/constructEventwebhooks
Suppressionslist, add, removesuppressions
Providerscreate, list, get, update, remove, testproviders
API keyscreate, list, removeapiKeys / api_keys
Inboundlist, getinbound
Automationscreate, list, removeautomations
Analyticsget (workspace report), domains, emailanalytics
DeliverabilityspamCheck, complaints, auditDomain, listWarmup, createWarmup, updateWarmup, removeWarmupdeliverability