TypeScript client SDK
Build custom apps on top of Lunnoa Automate with @lunnoa/client.
@lunnoa/client is the official TypeScript SDK for the Lunnoa Automate Public API. Use it to build portals, internal tools, chat UIs, and backends that talk to your deployment's agents, workflows, entities, queues, and knowledge.
The SDK is presentation-free: no components, hooks, or widgets. You bring your own UI framework and design system; the SDK provides typed data access, SSE agent chat streaming, and deployment-specific codegen.
Requirements
Before you install, make sure you have:
- Node.js 20 or newer (or any runtime with
fetchand web streams) - A Lunnoa Automate deployment URL
- Either a workspace API key (
lna_…) or a user JWT
Install
Add the package to your app:
Quickstart
Create a client against your deployment, then list entities. Expansion fields are optional extras: responses are minimal by default, so request what you plan to render.
A SuperAdmin creates API keys in Admin Space → API Keys, choosing the workspace and an RBAC role for the key's service account. Prefer a minimal custom role over Admin. See API authentication for key creation and security notes.
Authentication
Pick one pattern before you write UI code. Mixing them usually means a leaked key or broken permissions.
| Pattern | Credential | Where |
|---|---|---|
| A. Backend holds the key | apiKey: 'lna_…' | Your server, background jobs, server-rendered pages |
| B. End users are Lunnoa users | accessToken: <user JWT> | Browser apps. Users log in via /api/auth or /api/sso |
Resources
Most namespaces map to the Public API surface. approvals uses the authenticated workspace API (see Approvals).
| Namespace | Purpose |
|---|---|
agents / tasks / agentChat | Agents, task history, SSE chat streaming |
workflows / executions | Trigger workflows and poll or wait for results |
entities / entityTypes | Objects and their schemas / state machines |
knowledge | Knowledge bases and documents |
queues / queueItems | Human-in-the-loop work items |
approvals | Request Approval inbox (workspace API) |
variables / connections / projects | Workspace configuration |
workflowApps | Resolve app/action IDs to labels and icons |
discovery | Feature flags for the deployment's edition |
List calls accept shared conventions: expansion (extra fields), filterBy, and pagination (page / pageSize). Many list resources also support async iteration (entities.iterate(...), queueItems.iterate(...)).
Browse every public operation on the API reference.
Guides in this section
| Guide | What you will do |
|---|---|
| Codegen | Generate typed accessors for your deployment |
| Discovery | Inspect agents, workflows, and entity schemas at runtime |
| Entities | Query, create, and change entity state |
| Workflows | Trigger runs, render executionPath, resume NEEDS_INPUT |
| Agent chat | Stream SSE chat in the AI SDK UIMessage format |
| Queues | Work through human-in-the-loop queue items |
| Approvals | List pending approvals and decide |
| Errors | Handle LunnoaApiError status helpers |
Checklist for a new custom UI
Use this as a short go-live list once the SDK is wired in.
Choose an auth pattern
Confirm base URL and pattern A or B. Keep
lna_keys server-side only.Run codegen
Run
npx @lunnoa/client codegenagainst the deployment and commit the output. See Codegen.Adapt to features
Call
discovery.enabledFeatures()and hide unsupported areas. See Discovery.Build from schemas
Drive forms and tables from
attributeSchema/customInputConfig, or from the generated types.Handle workflow UX
Render progress from
executionPath. ResumeNEEDS_INPUTwithsubmitInput. See Workflows.Wire chat carefully
Stream via SSE, handle resume and stop, load history from the task. See Agent chat.
Handle API errors
Map 401 to re-auth, 403 to hide the capability, and 429 to back off. See Errors.
Related
- API authentication: creating keys, JWT login, security notes
- API reference: full public OpenAPI operation list
- npm: @lunnoa/client: package page and release history