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 holds the primary key value of an instance of another object. It is metadata only — there is no database-level foreign key. If Company.owner points at Person, whose primary key is id, then owner holds a Person’s id.
  • relationship must reference exactly one related object.
  • The field’s type must be str, int, or date. A str field can hold any key type; an int or date field must match the type of the key field it holds.
  • If the related object has a composite primary key, declare one field per key field, each with relationship.field set to the key field it holds. Together they form one link, and each key field must be covered once.
  • On create and update, the value must match an existing instance of the related object, or the write returns 400. A composite link must be set completely or left empty.
A composite key, where Shipment points at an OrderLine keyed by (order_id, line_no):
If the related object is not deployed on the branch, or the field does not match one of its primary key fields, the relationship is marked broken on deploy and the reason is shown on the object. 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 related object’s instances, using its label_column for display (or the key value when it has none).
Relationship fields used to store the related instance key (_key). They now store the primary key value, and existing values were converted.

Source fields (backed objects)

On a backed object, a field with source_column reads that column of the source. A field without it is a custom property, stored by Datazone and editable.
  • db_type is required and must equal the column’s ClickHouse type. type and optional are derived from it (Nullable(Int64) → optional int); a type with no field type, such as Array(String), becomes other.
  • Source fields are always read-only (mutable is forced to false) and cannot set default or db_column.
  • Each source_column can be used once. Primary key fields must be source fields, and cannot be other.
  • Custom properties must be optional or have a default.
  • source_column is only allowed on backed objects.

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. It is on by default. With it off, old versions may be compacted away over time (history becomes best-effort). On a backed object, it keeps the edits of custom properties.
  • source points a backed object at a dataset or view of the same project. It cannot be changed after the object is created, and neither can object_type.

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.