Install
bash
npm install @ewyn/client
# or
pnpm add @ewyn/client
# or
yarn add @ewyn/clientRequirements: Node.js 18+ (the SDK uses native fetch) and TypeScript 5.0+ for the type-safe features.
Create a client
typescript
import { Ewyn } from '@ewyn/client';
const client = new Ewyn({
apiKey: process.env.EWYN_API_KEY!,
});Constructor options:
| Option | Type | Default | Notes |
|---|---|---|---|
| apiKey | string | required | Your workspace API key secret |
| templates | TemplateConfig | — | Template config for name-based, type-safe sending — see Type-safe templates |
| maxRetries | number | 3 | Maximum total attempts for retryable errors, including the first |
| timeout | number | 30000 | Request timeout in milliseconds |
| debug | boolean | false | Log requests/retries to stderr. Also enabled when env DEBUG contains ewyn |
Send an email
typescript
await client.send({
to: 'user@example.com',
subject: 'Welcome!',
templateId: 'template-version-uuid',
variables: {
firstName: 'John',
lastName: 'Doe',
},
});The full option list lives in the send endpoint reference — the SDK mirrors it one-to-one.
Sender overrides
Emails default to your workspace's configured sender. Override per-send when needed:
typescript
await client.send({
to: 'user@example.com',
subject: 'Hello from a custom sender',
templateId: 'template-version-uuid',
from: 'noreply@yourdomain.com',
fromName: 'Your App',
replyTo: 'support@yourdomain.com',
});Debug logging
Pass debug: true in the client options, or set DEBUG=ewyn in the environment. Requests, retries, and timeouts are then logged to stderr — useful for working out which step a failing send died on.