Skip to main content

Knowledge Object YAML Reference

This page documents every attribute available in a Knowledge Object YAML definition. Each file declares one object per YAML document; you can define multiple objects in one file by separating them with ---.

Top-level structure

A minimal object needs a name and at least one field, and at least one of those fields must be a primary key:

fields

The list of columns that make up the object. Every field is validated on deploy; an unknown attribute or an unsupported type fails the deploy.

Field types

By default each type maps to a sensible database column type. Use db_type to override the exact type.

Primary keys

At least one field must have primary_key: true. The combination of primary key fields uniquely identifies an instance, and it is used to compute the stable instance key (_key).
  • Primary key fields cannot be optional.
  • Primary key fields are immutable — attempting to change one through the API is an error. A different primary key is a different instance.

Defaults

default sets a database-level default that the database applies whenever the field is omitted from an insert. This means the default is enforced regardless of how the instance is created — through the API, or directly against the table. Because it is a database expression, you can use functional defaults:
A field with a default may be omitted when creating an instance — the database fills it in. Functional defaults such as now() can only be produced at insert time, so the client should leave the field out rather than sending a value.

Mutability

Set mutable: false to freeze a field after the instance is created. Non-primary-key fields are mutable by default.

Custom database columns and types

Use db_column and db_type to control the underlying database storage independently of the field name and logical type:

Relationships

A relationship field points at another object’s instance. It is metadata only — there is no database-level foreign key. The field itself is a plain string that stores the target instance’s key (_key).
  • The field’s type must be str.
  • relationship must reference exactly one target object, by name.
At read time you can ask the API to resolve relationships (one level deep) via the add_relationships flag — see the Instance API. In the UI, a relationship field is rendered as a picker over the target object’s instances, using the target’s label_column for display.

Options

A str field can declare a fixed set of allowed values with options. The UI renders it as a dropdown instead of a free-text input, and the API rejects any create/update whose value is outside the list.
  • options is only valid on str fields, and must not be empty.
  • Writing an instance with a value not in options returns 400.

settings

Object-level settings. All are optional.
  • label_column must name one of the object’s fields. It is used wherever an instance is shown by name — most importantly in relationship pickers.
  • icon is purely for UI presentation.
  • store_versions keeps superseded versions of an instance available in history. With it off, old versions may be compacted away over time (history becomes best-effort).
BACKED objects (object_type: BACKED, backed by a dataset) are not yet generally available. Define STANDALONE objects — the default — for managed instances.

actions

Actions bind a named operation on the object to a Python handler function in your repository.
The handler must point at a Python file and function in your repository. Changing an object’s actions does not trigger a schema migration — only field and setting changes do.
Executing actions via the API is on the roadmap; today, actions are declared and validated as part of the object definition.

Full example

objects/employee.yaml

Deploying multiple objects

To define more than one object in a single file, separate documents with ---:
objects/hr.yaml
Each object still becomes its own identity, definition, and database table. Object names must be unique within the file and within the project.

Next steps

  • Overview — concepts, branching, and the lifecycle.
  • Instance API — managing instances of your objects.