Getting Started
Step-by-step tutorial for writing semantic domain templates by hand or programmatically
Semantic domains can be built through the UI or by writing YAML/JSON templates directly. This guide walks you through building a complete domain template from scratch, one concept at a time.
When to use template editing:
- Bulk configuration of many fields or datasets
- Version-controlled domains stored in Git
- CI/CD pipelines that deploy domain changes automatically
- Copying configurations between environments
- AI agents or scripts generating domains programmatically
How to open the template:
- Open your domain in the Domain Editor
- Click the Template tab
- Toggle between YAML and JSON format
- Edit the template and click Save
Minimal Template
The smallest valid domain template:
schemaVersion: "2.1"
datasets: []All other top-level fields are optional and default to empty. The full skeleton:
schemaVersion: "2.1"
aiContext: "Fiscal years start in February." # Context for agents (optional)
datasets: [] # Datasets with identifiers, facts, and dimensions
relationships: [] # How datasets join
metrics: [] # Every metric: dataset metrics and composed metrics
composedDimensions: [] # Domain-level row expressions over inputs
grainMappings: [] # Columns a composed dimension uses in other datasetsA template has four building blocks:
- Facts and dimensions live on a dataset. Both work row by row. A fact is a quantity you aggregate (like
amount); a dimension is an attribute you group and filter by (likeregion). - Metrics aggregate rows. A dataset metric aggregates one dataset (
SUM(amount)onorders). A composed metric combines named inputs, often from several datasets (net revenue from orders and returns). - Relationships join datasets.
fromis the many side;tois the side whose fields identify one row. - Context (
aiContext) tells agents and natural-language questions how to read any of the above.
Templates saved in the 2.0 shape
Domains saved before version 2.1 keep working. They read as 2.1, and they are stored as 2.1 the next time you save. The API still accepts 2.0 bodies (calculatedMetrics, fields.metrics, sourceDataset/targetDataset) and upgrades them on save. Write new templates in 2.1.
Guide Sections
Datasets & Fields
Define datasets (table or SQL), keys, fields (identifiers, facts, dimensions), and context
Relationships
Configure joins between datasets for automatic multi-table queries
Inline Expressions
Define row-level expressions on facts and dimensions, and display formatting
Calculated Fields
Create dataset metrics, composed metrics, and groupings, and learn where each one goes
SQL Generation
Understand how templates translate to executable SQL queries
Validation & Examples
Complete domain example and validation error reference