Skip to content
You're viewing documentation for v2.0.0. It may be out of date.Go to latest
Email SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Client reference

Exact construction options, methods, routing helpers, validation results, and send results for the v1 client.

createEmailClient(options)

Construction is synchronous and requires at least one adapter after plugins register their routes.

Option Default Behavior
adapters [] Literal-named adapter routes. Plugins may add routes.
defaultAdapter First registered adapter Primary route for operations without an override.
fallback No fallback Candidate adapters and unknown-delivery policy.
retry { maxAttempts: 1 } Client-level retry policy.
hooks None Best-effort lifecycle observers.
plugins [] Synchronous route, hook, middleware, and extension composition.
telemetry true Anonymous SDK analytics unless an environment opt-out applies.

Duplicate adapter names, duplicate plugin ids, unknown default/fallback names, maxAttempts < 1, async plugin adapters, and extension-key collisions throw during construction.

Client properties

validate(message, options?)

Runs common message, route, capability, adapter-specific, schedule, and personalized checks without calling an adapter’s send method.

Built-in validation currently returns an empty warnings array on success.

send(message, options?)

Per-send retry and fallback objects replace the client objects. adapter selects the primary route. metadata is lifecycle context, separate from provider-facing message.metadata.

sendMany(items, options?)

Items run sequentially in input order. Item options shallowly override method options. The method always returns one settled result per item.

sendPersonalized(input, options?)

At least one accepted recipient resolves with accepted and rejected. Zero accepted recipients throws EmailAllRecipientsFailedError.

adapter(name)

Returns the exact adapter type for a registered literal name. Unknown runtime names throw EmailAdapterNotFoundError.

withAdapter(name)

Returns validate, send, sendMany, and sendPersonalized bound to one adapter.

flush()

Waits for in-flight opt-out telemetry and never rejects. Serverless runtimes freeze the process on response and drop those requests, so await this (or pass it to waitUntil) before a handler returns. Long-running servers do not need it, and it resolves immediately when telemetry is disabled.

Message reference

Look up every normalized message field.

Error reference

Handle the closed v1 error union.

Last updated on