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-sdkEmailClient
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
});| Option | Type | Notes |
|---|---|---|
apiKey | string | Project API key from the dashboard. |
baseUrl | string | Platform origin. Defaults to http://localhost:4000. |
timeoutMs | number | Abort 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
}
}| Code | Meaning |
|---|---|
UNAUTHORIZED | Missing, invalid, or revoked API key. |
TEMPLATE_NOT_FOUND | No template with that slug in the key's project. |
TEMPLATE_DISABLED | Template exists but is toggled off. |
INVALID_PAYLOAD | Malformed request - bad email address, missing template. |
PROVIDER_ERROR | The upstream provider rejected the send; details in message and the log. |
NETWORK_ERROR / TIMEOUT | Could 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.