Entities

Query, create, and change entity state with @lunnoa/client.

Entities (Objects) are typed records defined by your deployment's entity types. Load the schema, create records with attributes keyed by field ID, then iterate or change state as needed.

Prefer codegen when you can: lunnoa.entities.invoice.create({ ... }) is compile-time checked. Without it, use the generic entities / entityTypes namespaces and discovery.

Query and create

entities.ts
const invoiceType = await lunnoa.entityTypes.getBySlug('invoice', {  expansion: ['attributeSchema', 'stateSchema'],});const created = await lunnoa.entities.create({  name: 'INV-2026-0042',  objectTypeId: invoiceType.id,  attributes: { amount: 1250.5, currency: 'CHF' }, // keyed by field ID});for await (const invoice of lunnoa.entities.iterate({  objectTypeSlug: 'invoice',})) {  // pages fetched lazily}await lunnoa.entities.changeState(created.id, {  newState: 'approved',  reason: 'Matches purchase order',});

List conventions

  • One page: entities.list({ objectTypeSlug, state, search, page, pageSize, expansion }) (default page size 20, max 100)
  • Everything: entities.iterate(...) fetches pages lazily for exports or aggregations
  • State changes are validated against the type's state machine
  • Prefer entities.getStateTransitions(id) for transitions valid now, not the full schema

Next