SDK
The Unlayer SDK is the official typed client for the Unlayer Cloud REST API. It wraps every endpoint with TypeScript types, automatic retries, configurable timeouts, and a clean async/await surface — so server-side code can talk to Unlayer without hand-rolling HTTP requests.
unlayer/unlayer-typescript is open sourceAvailable packages
Published to npm:
| npm package | Language | Requirements | Status |
|---|---|---|---|
@unlayer/sdk | TypeScript / JavaScript | Node.js 20+ | Available |
Python, Go, and Ruby SDKs may follow. The docs are structured so each gets its own subsection.
The TypeScript SDK is generated directly from the same OpenAPI spec that backs the Cloud API reference — so it stays in sync with the API as endpoints change.
Install
npm install @unlayer/sdk
Quick start
import Unlayer from '@unlayer/sdk';
const client = new Unlayer({
apiKey: process.env['UNLAYER_API_KEY'],
});
const page = await client.templates.list({
limit: 10,
projectId: 'your-project-id',
});
console.log(page.data[0].id);
The SDK reads UNLAYER_API_KEY from the environment by default — see Authentication for how to get an API Key or Personal Access Token from Console.
Available methods
The SDK groups every endpoint under a resource on the client. The full list:
All methods hang off the client you instantiate at the top of Quick start — so Templates becomes client.templates.list() in code.
| 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() | Look up a project by ID |
| Workspaces | workspaces.list() · workspaces.retrieve() | Browse the workspaces you have access to and fetch one by ID |
| Convert | convert.fullToSimple.create() · convert.simpleToFull.create() | Round-trip designs between the Full and Simple schema forms |
Every method is fully typed — request params and response shapes have TypeScript definitions, so IDE autocomplete walks you through what each endpoint accepts and returns. See the corresponding entries in the Cloud API reference for per-field detail.
Highlights
- Typed everywhere — request params 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 give coding agents (Claude Code, Cursor, Codex) everything they need to call Unlayer endpoints correctly on the first try. Combine it with Skills for even better results.
- Built-in retries — connection errors, 408, 409, 429, and 5xx are automatically retried with exponential backoff (configurable per-client or per-request).
- Configurable timeouts — default 1 minute, override per client or per call.
- Error subclasses —
APIErrorand friends (BadRequestError,AuthenticationError,RateLimitError, …) maketry/catchbranching clean. - 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.
- Data Structures — the design JSON shape the SDK accepts and returns.
- CLI — terminal tool for the same account (login/init/pull/diff).