Tables
Read and upsert reference and lookup tables with @lunnoa/client.
Tables hold small, slowly changing reference data: cost centres, country codes, approval limits, product mappings. Each table has columns ({ key, label }) and rows keyed by column key. Read them from your app, deploy them from code, and let workflows look values up with the Lookup action of the Tables app.
Objects or tables?
| Use | When |
|---|---|
| Object (entity) | A business record with identity and a lifecycle: states and history, linked to executions, agents, and queues. Grows with every transaction (invoices, cases, onboarding requests). |
| Table | Reference or lookup data that changes rarely and stays small (practical limit around 10,000 rows). |
Rule of thumb: if a record needs a state, an audit trail, or a human to act on it, make it an object. If it only answers "what is the value for this key?", make it a table.
Rules
- Table slugs are unique per workspace. Entity type slugs, by contrast, are unique across the whole deployment.
- Rows are stored as one JSON document per table, so keep tables to roughly 10,000 rows. Larger or fast-growing data belongs in objects.
- Permissions: reading needs
tables:read; upsert needstables:createandtables:update.
Read tables
list returns tables without columns and rows (including slug and managedByCode). get and getBySlug return the full table.
const tables = await lunnoa.tables.list();
const limits = await lunnoa.tables.getBySlug('approval-limits');
const limit = limits.rows?.find((row) => row.costCentre === 'CC-100');
const same = await lunnoa.tables.get(limits.id);Upsert from code
upsertBySlug creates or updates a table by workspace and slug. Omitted columns or rows keep their current value, so you can update metadata without resending the data. managedByCode defaults to true. Content is validated on the server.
import type { UpsertTableBySlugInput } from '@lunnoa/client';
const input: UpsertTableBySlugInput = {
slug: 'approval-limits',
name: 'Approval limits',
description: 'Maximum amount each cost centre may approve without escalation.',
columns: [
{ key: 'costCentre', label: 'Cost centre' },
{ key: 'limit', label: 'Limit (CHF)' },
],
rows: [
{ costCentre: 'CC-100', limit: 5000 },
{ costCentre: 'CC-200', limit: 20000 },
],
};
const table = await lunnoa.tables.upsertBySlug(input);The description matters: agents use it to choose the right table.
CLI
tables get accepts a slug or an ID (a UUID is treated as an ID, anything else as a slug).
npx @lunnoa/client tables list --json
npx @lunnoa/client tables get approval-limits --jsonPublic API
| Operation | Endpoint |
|---|---|
| List (without rows) | GET /api/tables |
| Get by slug (with columns and rows) | GET /api/tables/slug/{slug} |
| Get by ID | GET /api/tables/{tableId} |
| Upsert by slug | POST /api/tables/upsert |
See the API reference for request and response schemas.