@emailux/api-client package calls the EmailUX HTTP API: render (HTML by template) and deliver (render + send via a provider).
Installation
Default base URL
All requests use:https://render.emailux.com
Override with baseUrl in the client options if you use a custom deployment.
OpenAPI (Swagger): The live spec for your deployment is at {baseUrl}/swagger.json (for example https://render.emailux.com/swagger.json). Use it for the latest paths, headers, bodies, and response codes.
Client options
| Option | Description |
|---|---|
apiKey | Required. Sent as x-api-key. |
baseUrl | Optional. Defaults to https://render.emailux.com (trailing slash is stripped). |
defaultLocale | Optional. Default en-US; used when locale is omitted on deliver / render. |
fetchImplementation | Optional. Custom fetch (e.g. for tests or edge runtimes). |
timeoutMs | Optional. Request timeout via AbortSignal. |
provider | One of sendgrid, gmail, or smtp. Affects deliver defaults (see below). |
sendgridDomain | Required when using SendGrid (default provider). Your SendGrid-authenticated domain identifier. |
sendgridDomain is required for render()). Delivery can use SendGrid, Gmail, or SMTP via provider and optional per-call overrides.
HTTP mapping: The client sends your domain as the x-sendgrid-domain header on render/deliver. The public API may also document this as x-domain; behavior depends on your EmailUX API version.
render() — HTML only
Calls POST /v1/render with a JSON body:
experience_id(required)version(optional)locale(optional; falls back todefaultLocale)data(object; defaults to{})
Response codes (/v1/render)
| Status | Meaning |
|---|---|
200 | Success. JSON includes ok, html, subject. |
400 | Validation error |
401 | Unauthorized |
404 | Not found |
{ ok: true, status, html?, subject? }. On failure, { ok: false, status, error } with error.message and optional error.body.
Example (SendGrid domain — required for render)
deliver() — render and queue send
Calls POST /v1/deliver with a JSON body:
experience_id(required)tenant— not set by this client; use API keys and headers if your backend requires it whenx-domainis omitted (seeswagger.jsonfor your deployment).version,locale(optional)channel_data(required):toEmail,fromEmail, optionaltoEmailName,fromEmailNamedata(object; defaults to{})
x-provider:gmailorsmtpwhen using those providers (SendGrid uses the domain header path, sox-provideris omitted for SendGrid).
Response codes (/v1/deliver)
| Status | Meaning |
|---|---|
200 | Success. JSON includes ok, message. |
400 | Validation error |
401 | Unauthorized |
404 | Not found |
502 | Provider error |
SendGrid
Default provider is SendGrid;sendgridDomain is required on the client.
provider: 'sendgrid'; the client still requires sendgridDomain for that configuration.
Gmail
SMTP
Errors and non-HTTP failures
- HTTP
4xx/5xxresponses setok: falseand includestatusanderror(with parsed body when JSON). - Network timeouts, aborts, or other thrown errors surface as
ok: false,status: 0, anderror.messagefrom the thrown error.
Requirements
Node.js >= 18 (nativefetch).
Source and license
Package source lives underpackages/api-client in the EmailUX monorepo. License: MIT.