Docs

Objects

sixb.objects(Type) is the typed runtime API for reading and writing object instances: create and update, fetch by id, query the latest-state graph, follow links, append telemetry, and request actions. It is the main surface your application code uses to talk to your data.

Object types are declared in the ontology (see object types). This page covers the runtime API you use to operate on the instances of those types.

Mental model

An object is the current state of one entity — one Customer, one Invoice, one Project — keyed by its primary property. sixb.objects(Type) returns an ObjectSet: a type-safe collection bound to that type, with signatures inferred from the ontology definition.

From an ObjectSet you reach three things:

Entry pointReturnsUse for
collection methodsthe set itselfupsert, get, list, batch telemetry, set-level link/action helpers
.query()a query buildergraph-aware reads: filter, search, sort, follow links, page
.byId(id)an object handleoperations on one instance: links, telemetry, actions
TS
const invoices = sixb.objects(Invoice)

const invoice = await invoices.get("inv-001")
const handle = invoices.byId("inv-001")

A fetched object is a TwinObject: read .primaryId and .properties.<name>.

Collection methods

Called directly on sixb.objects(Type). All methods are async — await them.

MethodSignatureNotes
upsertupsert({ properties }) => TwinObjectCreate or update by primary id — the given properties are merged over any existing ones. The primary property must be inside properties.
getget(id) => TwinObject | nullFetch one object by primary id.
listlist(input?) => { objects, hasMore, total }Browse by id prefix/suffix or timestamps, with limit/offset/orderBy/order.
queryquery() => QueryBuilderStart a graph-aware query. See querying.
byIdbyId(id) => ObjectByIdHandleBind operations to one instance.
appendTelemetryBatchappendTelemetryBatch(items) => voidAppend telemetry across many objects in one call. See telemetry.
upsertLinkupsertLink({ sourceId, linkId, targetTypeId, targetId, properties? }) => voidCreate or update a link by string ids.
removeLinkremoveLink({ sourceId, linkId, targetTypeId, targetId }) => voidRemove a link by string ids.
requestActionrequestAction({ id, actionId, params?, runId? }) => …Request an action against one object.
requestActionAndWaitrequestActionAndWait({ id, actionId, params?, timeoutMs?, signal? }) => …Request and await the run.
TS
const invoices = sixb.objects(Invoice)

// Create or update by primary id
await invoices.upsert({
  properties: { id: "inv-001", number: "2026-001", amount: 4200, currency: "EUR", status: "sent" },
})

// Read one
const invoice = await invoices.get("inv-001")

// Browse the type
const page = await invoices.list({ limit: 25, orderBy: "updatedAt", order: "desc" })

.byId(id) handle

byId(id) returns an ObjectByIdHandle scoped to a single object.

MethodSignatureNotes
getget() => TwinObject | nullFetch this object.
linklink(token, target, options?) => voidAdd a link via a typed token (Type.l.<name>).
unlinkunlink(token, target) => voidRemove a link.
listLinkslistLinks(token?) => linksList this object's links, optionally for one token.
telemetrytelemetry(token) => { append }Per-property telemetry appender (Type.p.<name>).
requestActionrequestAction({ actionId, params?, runId? }) => …Request an action on this object.
requestActionAndWaitrequestActionAndWait({ actionId, params?, timeoutMs?, signal? }) => …Request and await the run.
TS
const handle = sixb.objects(Invoice).byId("inv-001")

// Append telemetry to a project's progress series
await sixb.objects(Project).byId("proj-001").telemetry(Project.p.progress).append({
  value: 60,
  at: new Date(),
})

// Request an action on the invoice
await handle.requestAction({
  actionId: "sendReminder",
})

Links connect objects in the latest-state graph. Define them on an object type with link(...) (see links), then operate on them at runtime two ways:

  • Typed tokens via the handle: byId(id).link(Type.l.<name>, target), unlink(...), and listLinks(...). The token is checked at compile time against the source type.
  • String ids via the set: upsertLink({ ... }) and removeLink({ ... }) when you only have raw ids.
TS
const invoices = sixb.objects(Invoice)

// Typed token form
await invoices.byId("inv-001").link(Invoice.l.customer, {
  objectTypeId: "Customer",
  primaryId: "cust-001",
})

// String-id form
await invoices.upsertLink({
  sourceId: "inv-001",
  linkId: "customer",
  targetTypeId: "Customer",
  targetId: "cust-001",
})

Traverse links in reads with the query builder, and read raw link rows with byId(id).listLinks(...). Links are also exposed over HTTP — see the HTTP reference.

End to end

A scheduled function that flags sent invoices past their due date — read, inspect properties, write back:

TS
export const checkOverdueInvoices = defineFunction("check-overdue-invoices")
  .cron("0 8 * * *")
  .run(async ({ sixb }) => {
    const { objects } = await sixb.objects(Invoice).list({ limit: 500 })
    const today = new Date().toISOString().slice(0, 10)

    for (const invoice of objects) {
      const { number, amount, status, dueDate } = invoice.properties
      if (status !== "sent" || !dueDate || dueDate >= today) continue

      await sixb.objects(Invoice).upsert({
        properties: { id: invoice.primaryId, number, amount, status: "overdue" },
      })
    }
  })

Footgun: runtime objects() vs action objects()

Two objects(Type) APIs look almost identical. Picking the wrong one is the most common mistake.

sixb.objects(Type) (runtime)objects(Type) (action .edits())
Wherefunctions, syncs, schedules, app codeinside an action's .edits(...) handler
Timingasync, immediate — writes apply nowsync, staged — applied atomically on commit
awaitevery method returns a promiseedit calls are synchronous
Createupsert({ properties })create(properties)
Updateupsert(...) (merge over existing)byId(id).update({ ... })
Readsget / query / listread.objects(Type)
TS
// Runtime — async, immediate
await sixb.objects(Invoice).upsert({
  properties: { id: "inv-001", status: "paid" },
})

// Action .edits() — synchronous, staged, no await
objects(Invoice).byId(subject.primaryId).update({ status: "paid" })

If you wrote sixb.objects(...) you are in the runtime API. If you destructured objects from an action handler argument, you are staging edits. See actions for the EditBatch model.

In this section

  • CRUD — create, read, update, delete with upsert/get/list.
  • Querying — filter, search, sort, follow links, and page.
  • Telemetry — append and read per-property timeseries.
  • HTTP reference — the REST/WebSocket surface.
  • Object types — declaring the types these APIs operate on.
  • Links — modeling relationships.
  • Actions — staged edits and writebacks.
  • Eventsobject.upserted, telemetry.appended, link.upserted, link.removed.

Search docs

Search the documentation