SOLEN

SDK - solen-sdk

A deliberately small TypeScript client for the platform: one class, one method, typed errors, zero dependencies. Node 18+ (native fetch).

Installation

npm install solen-sdk

EmailClient

import { EmailClient } from "solen-sdk";

const mail = new EmailClient({
  apiKey: process.env.SOLEN_API_KEY!, // required
  baseUrl: "http://localhost:4000",  // optional - your platform URL
  timeoutMs: 15_000,                 // optional - default 15s
});
OptionTypeNotes
apiKeystringProject API key from the dashboard.
baseUrlstringPlatform origin. Defaults to http://localhost:4000.
timeoutMsnumberAbort the request after this long.

send()

const result = await mail.send({
  template: "welcome-email",           // template slug
  to: "student@example.com",           // recipient
  variables: { name: "Priya" },        // optional
});

// result: { id: string; status: "SUCCESS"; messageId?: string }

Resolves on success. The idis the platform log id - every send, either way, is visible under the project's Logs.

Error handling

import { EmailClient, EmailError } from "solen-sdk";

try {
  await mail.send({ template: "otp-code", to: "user@example.com" });
} catch (err) {
  if (err instanceof EmailError) {
    err.code;    // "TEMPLATE_NOT_FOUND", "UNAUTHORIZED", …
    err.status;  // HTTP status (0 for network/timeout)
    err.logId;   // platform log id, when the attempt was logged
  }
}
CodeMeaning
UNAUTHORIZEDMissing, invalid, or revoked API key.
TEMPLATE_NOT_FOUNDNo template with that slug in the key's project.
TEMPLATE_DISABLEDTemplate exists but is toggled off.
INVALID_PAYLOADMalformed request - bad email address, missing template.
PROVIDER_ERRORThe upstream provider rejected the send; details in message and the log.
NETWORK_ERROR / TIMEOUTCould not reach the platform; nothing was logged.

Design principles

  • The SDK validates the payload shape locally and fails fast - bad requests never leave your process.
  • It never retries on its own; retries are a platform roadmap feature, so behavior stays predictable.
  • No HTML, no templating, no provider types - those concepts don't exist client-side by design.