SDK, OpenAPI & llms.txt
Three ways to consume the platform beyond raw curl: a typed TypeScript SDK with retries and pagination built in, a complete OpenAPI 3.1 specification for generators and tooling, and llms.txt guides designed for AI coding agents.
The TypeScript SDK
@emailflow/sdk is a zero-runtime-dependency client built on fetch — it runs on Node 18+, in browsers, and on edge runtimes. Every request and response shape is generated straight from the OpenAPI spec, so the types are the contract.
import { EmailFlow, EmailFlowApiError } from '@emailflow/sdk';
const emailflow = new EmailFlow({ apiKey: process.env.EMAILFLOW_API_KEY! });
const lists = await emailflow.lists.list();
try {
await emailflow.subscribers.create(
{ EMAIL: 'ada@example.com', FIRST_NAME: 'Ada', list_uid: lists[0]!.uid! },
{ idempotencyKey: true },
);
} catch (error) {
if (error instanceof EmailFlowApiError) {
console.error(`${error.code}: ${error.message}`, error.suggestion);
}
}
What you get over hand-rolled fetch calls:
| Feature | Behavior |
|---|---|
| Automatic retries | 429 waits for Retry-After; 5xx and network failures retry with exponential backoff. Unsafe methods (POST/PATCH/DELETE) only retry when an idempotency key makes the retry safe. |
| Idempotency | Pass { idempotencyKey: true } on any write — the SDK generates a UUID, reuses it across retries, and the server replays the original result. |
| Typed errors | Every non-2xx throws EmailFlowApiError carrying the canonical envelope: code, message, suggestion, docs, retryAfter, and HTTP status. |
| Pagination | for await over subscribers, templates, runs, and the analytics feed — no page or cursor bookkeeping. |
// Stream every click event, newest first, without cursor bookkeeping
for await (const event of emailflow.analytics.iterateEvents({ type: ['click'] })) {
console.log(event.occurred_at, event.subscriber_email, event.meta?.url);
}
The SDK ships with a cookbook of five end-to-end, type-checked recipes: bulk contact sync with idempotency, AI generate-and-send, webhook signature verification, analytics export, and building automations from graphs. Resource namespaces mirror the API one-to-one (lists, subscribers, segments, campaigns, templates, emails, automations, automationRuns, domains, webhooks, brand, usage, analytics).
OpenAPI 3.1
The entire public API is specified in one OpenAPI 3.1 document — every endpoint, parameter, scope requirement, error envelope, and response schema. A test in our suite walks the live route table and fails if any public endpoint is missing from the spec, so it cannot drift.
| Format | URL |
|---|---|
| JSON | /openapi/public-api-v1.json |
| YAML | /openapi/public-api-v1.yaml |
Feed it to any OpenAPI-aware tool: generate clients in other languages, import into Postman or Insomnia, validate requests at your edge, or wire it into contract tests. The SDK's own types are generated from this exact document.
llms.txt — docs for AI agents
If you point an AI coding agent (Cursor, Claude, Copilot, or your own) at EmailFlow AI, two plain-text endpoints give it everything it needs without scraping HTML:
| URL | Contents |
|---|---|
/llms.txt | A concise API guide: authentication, the scope table, rate-limit matrix, error catalog, and endpoint map — generated from the same source code that enforces them, so it is never stale. |
/llms-full.txt | The full documentation corpus — every docs page, including this one, as one markdown document. |
https://emailflow.ai/llms.txt into its context and it can write working integrations against the API — scopes, error handling, idempotency and all.