SDK
The Unlayer SDK is the official typed client for supported operations in the Unlayer Cloud REST API. Its request and response types and Fetch transport are generated from the public OpenAPI document, while a small allowlist keeps the public resource API intentional and stable.
unlayer/unlayer-typescript is open sourceAvailable packages
Published to npm:
| npm package | Language | Requirements | Status |
|---|---|---|---|
@unlayer/sdk | TypeScript / JavaScript | Node.js 20+ | Available |
The TypeScript SDK uses the same OpenAPI document that backs the Cloud API reference. Approved operations are regenerated when their API contracts change; a new API endpoint does not become part of the SDK automatically.
Install
npm install @unlayer/sdk
Quick start
import Unlayer from '@unlayer/sdk';
const unlayer = new Unlayer({
apiKey: process.env['UNLAYER_API_KEY'],
});
const page = await unlayer.templates.list({ limit: 10 });
console.info(page.data[0]?.id);
The SDK also reads UNLAYER_API_KEY, UNLAYER_PERSONAL_ACCESS_TOKEN, UNLAYER_PROJECT_ID, and UNLAYER_BASE_URL when the corresponding constructor option is omitted. See Authentication for how to get an API Key or Personal Access Token from Console.
The default API URL is https://api.unlayer.com. Pass baseURL only when intentionally targeting another environment.
Available methods
The SDK exposes seven allowlisted methods. All methods hang off the unlayer instance created in Quick start.
| Resource | Methods | Use for |
|---|---|---|
| Templates | templates.list() · templates.retrieve() | List templates in a project (cursor-paginated) and fetch one by ID, including its design JSON |
| Projects | projects.retrieve() | Fetch a project by ID |
| Workspaces | workspaces.list() · workspaces.retrieve() | List accessible workspaces and fetch one by ID (PAT required) |
| Convert | convert.fullToSimple.create() · convert.simpleToFull.create() | Convert designs between the Full and Simple schema forms |
Every method is fully typed, so IDE autocomplete shows the accepted parameters and response shape. For API v3 operations that are not listed here, use the Cloud API reference and call the REST endpoint directly.
Template, project, and conversion methods accept an API Key or PAT. Workspace methods require a PAT. When a PAT request targets a project, configure projectID on the client.
Highlights
- Typed everywhere — request parameters and response fields are fully typed; method signatures and field docs appear on hover in modern editors.
- Great for AI agents — the typed surface, JSDoc descriptions, and predictable error subclasses help coding agents call supported operations correctly. Combine it with Skills for editor integration guidance.
- Cursor pagination — iterate over template pages or individual templates without handling cursors yourself.
- Built-in retries — connection errors, 408, 409, 429, and 5xx responses are retried twice by default with backoff; configure
maxRetriesper client or request. - Configurable timeouts — each HTTP attempt times out after one minute by default; retries can make the complete operation take longer. Configure
timeoutper client or request. - Error subclasses —
APIErrorand status-specific subclasses expose the response status, headers, and parsed error body. - Server-side use — API keys belong on your server; the SDK is built for backend / serverless / CI use, never the browser.
Related
- Cloud API reference — the REST surface this SDK wraps.
- Design Schema — the design JSON shape the SDK accepts and returns.
- CLI — terminal tool for the same account (login/init/pull/diff).