I just launched Social SDK. Come check it out →
Email SDK
Reference

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.

OptionDefaultBehavior
adapters[]Literal-named adapter routes. Plugins may add routes.
defaultAdapterFirst registered adapterPrimary route for operations without an override.
fallbackNo fallbackCandidate adapters and unknown-delivery policy.
retry{ maxAttempts: 1 }Client-level retry policy.
hooksNoneBest-effort lifecycle observers.
plugins[]Synchronous route, hook, middleware, and extension composition.
telemetrytrueAnonymous 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. The SDK passes it unchanged to hooks, plugins, and adapter contexts.

By default EmailSendMetadata is EmailMetadataRecord: strings, numbers, booleans, null, undefined, Date, and arrays or plain objects of those. To give it your own shape, augment EmailMetadataRegister once in your app:

After that, send() requires that shape and hooks read event.metadata?.tenantId as a string.

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.

On this page