Docs
Reference for building on Caleana.
The Web SDK builds plugins. The Integration SDK connects an existing system. The CLI starts and packages either one.
npm install @caleana-ai/web-sdk react react-domGetting started
There are two things to build: a plugin, or an integration.
A plugin is built with the Web SDK and an integration with the Integration SDK. The CLI starts either from a template.
A React app, built with the Web SDK, that shows an interactive output in a session, such as a chart, a 3D view or a form.
Build a pluginA connection, built with the Integration SDK, that brings an existing system's data into the session and receives finished documents.
Build an integrationStarts a plugin or an integration from a template, and runs its build.
CLI commandsWeb SDK
Quick start
A plugin is a React component inside the SDK’s provider.
The component reads its data with hooks. The provider runs the lifecycle: init when Caleana sends the config, onDataUpdate when new data arrives and cleanup when the output closes.
import React from "react"import { usePluginData, useAutoResize } from "@caleana-ai/web-sdk" const MyPlugin = () => { const pluginData = usePluginData() useAutoResize() // resize the iframe to fit the content if (!pluginData) return <div>Loading…</div> return ( <div> <h1>{pluginData.templateName}</h1> <pre>{JSON.stringify(pluginData.transformerOutput, null, 2)}</pre> </div> )} export default MyPlugin
import React from "react"import { createRoot } from "react-dom/client"import { PluginProvider, type PluginLifecycle } from "@caleana-ai/web-sdk"import MyPlugin from "./MyPlugin" const lifecycle: PluginLifecycle = { init: async (config) => { /* Caleana sent the config */ }, onDataUpdate: async (data) => { /* new data to render */ }, cleanup: async () => { /* the output closed */ },} createRoot(document.getElementById("root")!).render( <PluginProvider lifecycle={lifecycle}> <MyPlugin /> </PluginProvider>)
Hooks
Hooks give the plugin its data, its settings, its theme and its size.
Every hook works inside PluginProvider. The types ship with the package.
usePluginData()The data Caleana sends: the template, and the output generated against the plugin’s schema. Returns null until it arrives.
usePluginConfig()The plugin’s config: its name, version, input schema and display options.
usePluginContext()The config, the data and the ready state together.
usePluginReady()Whether the plugin has initialised and rendered.
useHostTheme()The theme Caleana is showing, light or dark. The SDK also sets it on document.documentElement.dataset.theme, so a plugin can theme in CSS.
useAutoResize(deps?)Resizes the iframe whenever the content changes.
usePluginResize()Returns a function that resizes the iframe to a height, or to fit its content.
useExportRequest(handler)Handles an export Caleana asks for, and reports its progress.
Manifest
The manifest sets how Caleana generates the plugin’s data.
With "hostGeneration": "transformer", the default, Caleana generates the output against the plugin’s schema and sends it as PluginData. With "none", the plugin owns its data. Template parameters are inputs a person fills in when the output is added to a session: text, multiline, date or select.
{ "hostGeneration": "transformer", "parameters": [ { "key": "document_tone", "label": "Document tone", "required": true, "control": { "component": "select", "options": { "source": "static", "items": [ { "label": "Concise", "value": "concise" }, { "label": "Detailed", "value": "detailed" } ] } } } ]}
| Field | Required | Values |
|---|---|---|
name | Yes | A string |
version | Yes | A string |
generationMode | Yes | regenerate-only or supports-update |
nativeOutputs | Yes | An array of { format, mimeType, description? } |
exports | Yes | An array of { format, label, source } |
hostGeneration | No | transformer (the default) or none |
inputSchema | No | { schemaId, schemaVersion, jsonSchema }: what Caleana extracts from the session |
parameters | No | An array of { key, label, description?, required, control }; a control is text, multiline, date or select, with options that are static or from an integration |
layoutMode | No | content-height or viewport |
editableOutput | No | true or false |
author, description | No | Strings |
Protocol
Caleana and the plugin exchange typed messages over postMessage.
Each message is { type, payload }, and both sides validate it before handling it. The wire schemas and their types are in @caleana-ai/web-sdk/protocol.
Caleana to the plugin
PLUGIN_CONFIGStarts the plugin; later messages update its display options.DATA_STREAMDelivers the output generated against the plugin’s schema.RESIZE_REQUESTAsks the plugin to report its height.REQUEST_EXPORTAsks for an export, with a request ID and the formats.
The plugin to Caleana
READYThe plugin has initialised.RESIZEReports the iframe’s height.ERRORReports a failure to initialise or update.OUTPUT_CHANGEDReports an edited output.EXPORT_READYReturns the export as a Blob.EXPORT_PROGRESSReports export progress.EXPORT_ERRORReports a failed export.
Build and upload
The CLI starts a plugin, and Caleana builds it once it is uploaded.
The build writes dist/, with index.html, its assets and manifest.json. The project is zipped and uploaded, built by Caleana in an isolated runner without network access, and turned on per workspace.
# start a web plugincaleana-plugin new my-plugin --type web # build it, then zip the project to uploadcd my-plugincaleana-plugin build
Security
Plugins run in a sandbox, and the SDK talks only to Caleana’s origin.
The SDK accepts messages from the parent frame at the host’s origin and sends payloads only to that origin. Caleana sets the iframe’s sandbox permissions and network rules, outside the SDK.
Integration SDK
Overview
The Integration SDK connects an existing system to each session.
The package is @caleana-ai/integration-sdk, version 0.3.0, in TypeScript. An integration is a small service you run beside your system: it handles four events, adds your system’s data to sessions, answers lookups and delivers finished documents back. It connects outbound, so your system hosts no endpoint.
Created in Settings under API keys. It begins api_ and is sent as a bearer token.
The workspace integration the listener speaks for, a UUID. Each workspace turns its integrations on.
A Node service beside your system, with an outbound connection to Caleana.
Quick start
Create a client, listen for events and set the session’s values.
The client takes the API key, and an apiUrl that defaults to https://api.caleana.ai/graphql. The listener handles the events you list. Until the package is on npm, talk to us for access.
# the packagenpm install @caleana-ai/integration-sdk # what the integration needsCALEANA_API_KEY=api_... # Settings, API keysCALEANA_INTEGRATION_ID=... # the workspace integration
import { CaleanaClient } from "@caleana-ai/integration-sdk" const client = new CaleanaClient({ apiKey: process.env.CALEANA_API_KEY, // begins api_}) const listener = client.createEventListener({ integrationId: process.env.CALEANA_INTEGRATION_ID, eventTypes: ["session-created", "data-update-requested", "writeback-requested"],}) listener.on("session-created", async (session) => { const record = await findRecord(session.subjectIds) // your system await session.setValues({ details: record.details, history: record.history })}) listener.on("error", (error) => console.error(error)) listener.start()
Connection
The listener connects outbound, and events are pushed to it.
listener.start() registers the integration and opens the connection; stop() and destroy() close it.
| Part | How it works |
|---|---|
| Registration | On start, the listener registers the integration and the event types it handles. |
| Credentials | Short-lived credentials, valid for 15 minutes, renewed before they expire without dropping events. |
| Transport | An outbound connection over TLS to Caleana’s message broker. Your system opens no port and hosts no endpoint. |
| Delivery | A message carries only the event’s ID. The listener accepts the event and reads it in full from the API. |
| Deadlines | An event must be handled within 5 minutes, and a lookup answered within 30 seconds. |
| Concurrency | Up to 8 events at a time; any more are answered as failed. |
| Reconnects | If the connection drops, the listener registers again after a short backoff, up to about 20 seconds. |
| Retries | Events are not retried automatically. If a handler throws, the outcome is reported as unknown and the error goes to the error handler. |
Events
An integration handles up to four events.
Subscribe with eventTypes, then register a handler for each with listener.on(). Template sets are called collections in code.
| Event type | Handler | Receives | When |
|---|---|---|---|
session-created | "session-created" | session | A session has started. Add your system’s data with setValues(). |
data-update-requested | "data-update-requested" | session | The session’s data needs refreshing. Send it again. |
collection-invoked | "collection-invoked" | session, invocation | A template set has been used. invocation.collection has its name, description and context hints. |
writeback-requested | "document-writeback-requested" | owner, writeback | A person has asked to send a finished document to your system. See write-back, below. |
"error" | error | A handler threw, or the connection failed. |
Sessions
A session carries the values your integration sets.
A Session has id, workspaceId, title, createdAt, updatedAt, context, values, dataUpdateRequestedAt and subjectIds, the records it belongs to. An integration sets values; it cannot write the plain-text context.
| Call | What it does |
|---|---|
session.setValues(values) | Merges values into the session. A value can be a string, number, boolean, array, object or null; a key set to null is removed. |
session.requestDataUpdate(at?) | Marks the session as needing fresh data. |
session.clearDataUpdateRequest() | Clears the mark once the data is sent. |
client.workspaces.find(id) | Reads a workspace. workspace.createSession({ subjectIds, values }) opens a session from your system. |
client.sessions.get(id) | Reads one session. |
client.documents | Uploads files (plain text, PDF or Word, up to 25 MiB) and generates documents from them. |
Lookups
Lookups let a person pick a value from your system.
A template parameter can take its options from an integration, with source: "integration". Register lookup sources with client.registerLookupSources() and pass their handlers to the listener as sources. A lookup is answered within 30 seconds, and each person can make 30 a minute in a workspace.
Write-back
A finished document goes back as the exact bytes Caleana prepared.
Your integration declares the places your system accepts documents, and the formats for each. An admin ties each template to one. When a person sends a finished document, your integration receives a fixed copy of that version and saves it to the record.
- 1Declare destinations with the GraphQL mutation
registerIntegrationDocumentDestinations: akey, alabel, atargetRequirement(noneorgoverned-subject) and 1 to 32 accepted formats. - 2A person sends a document, and the listener receives
writeback-requested. - 3
writeback.loadDeliveryClaim()returns the artifact: its bytes in base64, its media type, a SHA-256 digest and its size, up to 1 MiB, with the record’s context. - 4
writeback.beginSubmission(state)is called once, before the first write to your system, with the state you need to check it later. - 5Report the outcome with
markSuccess(),markFailed()ormarkIndeterminate().
Each send is claimed for 2 minutes. If a claim lapses after the document was submitted, it comes back with claim.submitted set: check your system and record the outcome, but never send it again. The formats Caleana prepares are plain text, RTF, PDF and Word.
listener.on("document-writeback-requested", async (owner, writeback) => { const claim = await writeback.loadDeliveryClaim() if (claim.submitted) { // sent before: check your system, never send again return reconcile(writeback, claim.submissionState) } const ref = newReference() // your own reference await writeback.beginSubmission({ ref }) // once, before the first write const bytes = Buffer.from(claim.artifact.bytesBase64, "base64") await saveToRecord(owner, bytes, claim.artifact.mediaType, ref) await writeback.markSuccess({ ref })})
{ "key": "letters", "label": "Letters", "targetRequirement": "governed-subject", "acceptedArtifacts": [ { "representationKey": "rtf", "representationVersion": "1", "mediaType": "application/rtf" } ]}
Launch links
A launch link opens a new session for a record.
Your product links to the address below on your Caleana deployment, with the record’s ID. The person signs in, with single sign-on through SAML or OIDC or with email and Google, and the session opens for that record. It is created straight away unless its template set needs inputs first. The link carries IDs only.
/dashboard/workspace/{workspaceId}/newSession?subjectIds={recordId}Tools
CLI
The CLI starts a plugin or an integration from a template, and runs its build.
The package is @caleana-ai/cli, version 1.2.1, with one command, caleana-plugin.
| Command | Options | What it does |
|---|---|---|
caleana-plugin new <name> | -t, --type web|integration (default web)-d, --dir <dir> (default .) | Copies the template into a new folder and names the package @caleana-ai/<name>. A web plugin starts with a manifest, a React component and a Vite build. |
caleana-plugin build | -o, --output <path> (default ./dist) | Runs the project’s npm run build. |
# start a plugin, or an integrationcaleana-plugin new my-plugin --type webcaleana-plugin new my-integration --type integration --dir ./integrations # run the project's buildcd my-plugincaleana-plugin build
To upload a plugin, zip the project and upload it in Caleana. The platform checks it has a manifest.json at its root, a build script and dependencies from the npm registry only; installs them with install scripts turned off; builds it without network access; and takes dist/manifest.json, index.html and its assets. For an integration, start from the Integration SDK’s quick start: the CLI’s integration template is being updated for SDK 0.3.
GraphQL API
One GraphQL endpoint, authenticated with an API key.
Requests go to https://api.caleana.ai/graphql with Authorization: Bearer api_…. A key belongs to a person, a service account or a workspace, and is managed in Settings under API keys. Records are called subjects in the API. Authenticated requests can be up to 50 MiB.
curl https://api.caleana.ai/graphql \ -H "Authorization: Bearer api_..." \ -H "Content-Type: application/json" \ -d '{ "query": "...", "variables": { } }'
| Area | Queries | Mutations |
|---|---|---|
| Sessions | workspaceSession, workspaceSessions | createWorkspaceSessionWithInputs, updateWorkspaceSession, resumeWorkspaceSession, linkSessionSubject |
| Records | subject, subjects | createSubject, ensureImportedSubject |
| Documents | document, documents, resourceDocuments | saveDocumentRevision |
| Templates | templates, templateVersions, workspaceCollections | |
| Workspaces and integrations | workspace, workspaces, workspaceIntegrations | createWorkspaceIntegration, grantWorkspaceIntegrationConsumer, registerIntegrationLookupSources |
| Write-back | documentDeliveryClaim, documentDeliveryDispatch | registerIntegrationDocumentDestinations, createDocumentDestinationWriteback, beginDocumentDeliverySubmission, completeDocumentDestinationWriteback |
| Webhooks | createWorkspaceWebhook, updateWorkspaceWebhook, deleteWorkspaceWebhook |
Webhooks
Webhooks tell your system when a session is created or resumed.
Each workspace can have one webhook for each event type, set in Settings under Webhooks or with createWorkspaceWebhook. Caleana sends a JSON POST with the session’s IDs; read the session through the API with your key.
| Event type | Sent when |
|---|---|
session_created | A session is created in the workspace. |
session_resumed | A session is resumed. |
POST https://your-system.example/caleanaContent-Type: application/json { "type": "session_created", "sessionId": "...", "workspaceId": "...", "createdAt": "2026-10-09T09:30:00Z", "updatedAt": "2026-10-09T09:30:00Z"}
Your endpoint has 15 seconds to answer. A response outside 2xx is retried. Webhooks are sent only while they are turned on, and only for sessions inside the workspace’s retention. Treat the body as a notice and read the session through the API.
Guides
Build a plugin with the AI assistant you already use.
Hand it the build prompt, and it builds, tests and packages the plugin with the Web SDK. Get the prompt
Build on your advantage.
Tell us about your platform and the workflows you’re looking to introduce. Let’s explore how Caleana can help bring them to life.
Talk integrations