Guides · Wayletter

Wayletter: example clients

Copy-paste send + event stream. You call our host; you keep your stats. No Python.

Wayletter Go Node curl PowerShell MCP

Env

VarExample
WAYLETTER_BASEExample (customer): https://wayletter.waryway.com (no trailing slash).
Operator / local-dev only: http://127.0.0.1:8080 if running the binary locally (WAYLETTER_HTTP_ADDR).
WAYLETTER_API_KEYBearer key from the dashboard Keys tab (shown once). Dashboard: https://wayletter.waryway.com/wayletter/

Send: POST {WAYLETTER_BASE}/v1/send (process root on the dedicated host).

Stats: GET {WAYLETTER_BASE}/wayletter/v1/events/stream NDJSON. Ignore kind=heartbeat. No HTML/MIME. Persist on your side.

Repo copies: apps/wayletter/examples/

Go

From the stack repo: go run ./apps/wayletter/examples/go -mode=send or default -mode=stream.

c := wayletter.NewClient(os.Getenv("WAYLETTER_BASE"), os.Getenv("WAYLETTER_API_KEY"))

// send
id, err := c.Send(ctx, body) // JSON from / personalizations / content, 202 + message_id

// stream (your stats)
ch, err := c.StreamEvents(ctx)
for ev := range ch {
    if ev.Kind == "heartbeat" { continue }
    // persist ev (kind, message_id, from, to, subject)
}

Node 18+

Built-in fetch. No npm. node apps/wayletter/examples/node/wayletter-client.mjs send|stream

await fetch(`${base}/v1/send`, {
  method: "POST",
  headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
  body: JSON.stringify({ from: { email: "from@example.test" },
    personalizations: [{ to: [{ email: "you@example.test" }] }],
    subject: "Hello", content: [{ type: "text/plain", value: "Hello" }] })
});

const res = await fetch(`${base}/wayletter/v1/events/stream`, {
  headers: { Authorization: `Bearer ${key}`, Accept: "application/x-ndjson" }
});
// read res.body line-by-line; skip kind === "heartbeat"

curl

curl -sS -X POST "$WAYLETTER_BASE/v1/send" \
  -H "Authorization: Bearer $WAYLETTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":{"email":"from@example.test"},"personalizations":[{"to":[{"email":"you@example.test"}]}],"subject":"Hello","content":[{"type":"text/plain","value":"Hello"}]}'

curl -sSN "$WAYLETTER_BASE/wayletter/v1/events/stream" \
  -H "Authorization: Bearer $WAYLETTER_API_KEY" \
  -H "Accept: application/x-ndjson"

PowerShell

Same as curl via curl.exe (do not use Invoke-WebRequest aliases for the stream).

curl.exe -sS -X POST "$base/v1/send" -H "Authorization: Bearer $env:WAYLETTER_API_KEY" -H "Content-Type: application/json" -d $body
curl.exe -sSN "$base/wayletter/v1/events/stream" -H "Authorization: Bearer $env:WAYLETTER_API_KEY" -H "Accept: application/x-ndjson"

MCP / agents

We do not ship a Wayletter MCP process. Paste apps/wayletter/examples/mcp/wayletter.tools.json into your MCP/agent and implement the two tools as HTTP calls (curl/Go/Node above).

Env for the MCP host: WAYLETTER_BASE, WAYLETTER_API_KEY. Do not put keys in the JSON file.