Skip to content

The SDK

@sypnia/app: the App API from TypeScript, with streaming sessions.

Applies to EngineCloud
View as Markdown
On this page
  1. A session, streamed
  2. Credits
  3. Errors
  4. In the browser
Terminal
npm install @sypnia/app
board.ts
import { createApp } from '@sypnia/app';

const app = createApp({ token: process.env.SYPNIA_APP_TOKEN });

const board = await app.projects.board('laespiga');
console.log(board.health.state);      // 'healthy'
console.log(board.domain.renewsOn);   // '2027-11-18'

A session, streamed

ask.ts
const session = await app.sessions.create({ project: 'laespiga', title: 'Morning check' });

for await (const event of app.sessions.send(session.id, 'How is it going?')) {
  if (event.type === 'text') process.stdout.write(event.text);
  if (event.type === 'question') console.log('\n', event.question, event.options);
}

Events: text, question, approval, panel (what the side panel would open), task (a task started, progressed or ended) and done. An approval can be read, but only a person can answer it, in App.

Credits

TypeScript
const { balance, held } = await app.credits.balance();
const rows = await app.credits.ledger({ project: 'laespiga', group: 'case', from: '2026-11-01' });
const { approvalUrl } = await app.credits.topUp({ amount: 20 }); // USD, at least 5; a person opens it and pays with PayPal

Errors

Every error is an AppError with code, status and message, the same codes as the API.

In the browser

In a browser, the SDK uses the person’s Sypnia session and never needs a token. Never put a token in code that reaches a browser.

  1. A session, streamed
  2. Credits
  3. Errors
  4. In the browser

    Search pages, sections and terms