TypeScript client
A typed client generated from the OpenAPI contract: every path, parameter and response typed, idempotent writes, cursor pagination as an async iterator.
Last updated
npm install @kommio/api-clientimport { createKommioClient, paginate } from "@kommio/api-client";
export const api = createKommioClient({ baseUrl: process.env.KOMMIO_URL!, apiKey: process.env.KOMMIO_KEY! });
// Reads: typed paths, params and responses (openapi-fetch underneath).
const { data: conv, error } = await api.GET("/conversations/{id}", { params: { path: { id: 4821 } } });
if (error) throw new Error(error.detail); // problem details, typed
// Writes carry an Idempotency-Key automatically; retries are safe.
await api.POST("/conversations/{id}/messages", { params: { path: { id: 4821 } }, body: { content: "On its way.", kind: "reply" } });
// Cursor pagination.
for await (const c of paginate((cursor) => api.GET("/conversations", { params: { query: { category: "open", cursor } } })))
console.log(c.display_id, c.subject);In the browser
The agent app uses the same package with the session cookie (credentials: "include", no key). A panel page should not: it talks to your server, which holds the token.
Regenerating
The package lives in the repository under web/packages/api-client; pnpm run generate reads contracts/openapi.json. The agent app is built against it, so a breaking API change breaks the UI build first.
Other languages
Any OpenAPI 3.1 generator works against /api/openapi. Keep two behaviours whatever the language: send Idempotency-Key on writes you might retry, and follow next_cursor rather than page numbers.
Every claim on these pages is covered by a test in the repository, and the API reference is generated from the same contract every server serves at /api/openapi. Corrections to [email protected].