# Recipe schema

> The 13 top-level keys of a recipe, the minimal example, and what the engine supports and does not — from the schema it serves to agents.

Section: Reference · Type: reference · Last updated: 2026-09-13

A recipe is one JSON file with 13 top-level keys. Entities hold fields, fields have a type, relationships and scenarios sit at the top. This page is generated from the same schema the MCP server hands an agent (contract v3), so it cannot describe an engine that no longer exists.

## The top-level keys

- $schema — https://theworklens.com/schema/recipe/v1.json
- version — 1
- project — string (required) — kebab-case project name
- region — string (optional), e.g. 'GB', 'IN', 'AU'. Needed for names, companies, emails or addresses, which come from that region's locale pack.
- manifest — { name, version, requires, pack, assumptions } (optional)
- run_date — 'YYYY-MM-DD' (optional), for pack expiry
- categories — [] (optional), studio legend
- seed — number | "today" | "now" (optional). A number pins the bytes (same recipe, seed, engine). "today" changes daily, "now" every run; the receipt records the number used. Left out: one fixed internal seed (not 42).
- discovery — object (expected when you read a repository): what you found in the code. { sealed: [ids, written BEFORE drafting], observed: [{ evidence, where, note }], considered_and_skipped: [{ evidence, why }] }; ids from task_discovery.evidence[].id. validate_recipe checks each observation is modelled and each…
- entities — [{"name":"string (required, unique) — PascalCase entity/table name","rows":"number (optional, default 50). No cap; above 10,000 is slow in a browser and is warned","fields":[{"name":"string (required, unique within entity) — snake_case","type":"string — one of engine_field_types below","type_def":"object,…
- relationships — [{"from":"'ChildEntity.fk_field' — the scalar FK column on the many side","to":"'ParentEntity.id_field' — the referenced id on the one side","kind":"'fk'; also 'after', 'aggregate', 'polymorphic', 'unique'"}]
- scenarios — [] — optional named variations (may be empty). Each: { name, rows? (EVERY table's rows in this run), null_rate?, chaos rates (shares of rows, 0 to 1; named in reference.keys.scenario), defects? }. defects = PLANTED defects: [{ row, field, kind, entity? }] — exact rows made wrong EVERY run (row 1 = first…
- output — {"format":"REQUIRED. 'csv' writes one file per table and needs nothing else. 'fixed' writes a byte layout: fetch sections ['fixed_width'] for skeleton_def, overlay and totals."}

## Supported features

- relationships, constraints, conditional_weights, aggregates, rollups, hierarchies, graphs, flows
- scenarios, chaos, distribution_shapes, month_weights, patterns, fixed_width_output, packs, proof_reports
- determinism, range_conditions, multi_condition_branches, conditional_presence, planted_defects, numeric_conditional_distributions, cross_entity_scope, temporal_ordering
- polymorphic_references, correlated_row_draw, same_row_derivation, logical_conditions, date_arithmetic, joint_uniqueness, fanout_control, exact_cardinality
- role_binding, interval_non_overlap

## Not supported

- cross_entity_conditioning — For cross-entity AGREEMENT use scope — it filters the parent candidate set before the pick, so the data is coherent by construction. after orders dates across a link. Only if you need a parent attribute inside a weights_when CONDITION, FK-copy it onto the child.
- per_step_history — flows set the END state + ordered timestamps; a history TABLE per step is not generated
- time_series — none — flag to the user

## The smallest useful recipe

```json
{
  "$schema": "https://theworklens.com/schema/recipe/v1.json",
  "version": 1,
  "project": "bookstore",
  "region": "AU",
  "seed": 42,
  "entities": [
    {
      "name": "Customer",
      "rows": 100,
      "fields": [
        {
          "name": "customer_id",
          "type": "id",
          "unique": true
        },
        {
          "name": "full_name",
          "type": "person.fullName"
        },
        {
          "name": "email",
          "type": "internet.email"
        },
        {
          "name": "joined",
          "type": "date"
        },
        {
          "name": "lifetime_value",
          "aggregate": "sum(Order.total)"
        }
      ]
    },
    {
      "name": "Order",
      "rows": 300,
      "fields": [
        {
          "name": "order_id",
          "type": "id",
          "unique": true
        },
        {
          "name": "customer_id",
          "type": "id",
          "ref": "Customer.customer_id"
        },
        {
          "name": "total",
          "type": "finance.amount",
          "min": 1,
          "max": 500,
          "shape": "long_tail"
        },
        {
          "name": "status",
          "type": "enum",
          "values": [
            "placed",
            "shipped",
            "delivered",
            "cancelled"
          ]
        },
        {
          "name": "placed_at",
          "type": "date"
        },
        {
          "name": "delivered_at",
          "type": "date"
        }
      ],
      "constraints": [
        "delivered_at >= placed_at"
      ],
      "flow": {
        "field": "status",
        "transitions": {
          "placed": [
            "shipped",
            "cancelled"
          ],
          "shipped": [
            "delivered"
          ]
        },
        "weights": {
          "shipped": 8,
          "cancelled": 1
        },
        "timestamps": {
          "placed": "placed_at",
          "delivered": "delivered_at"
        }
      }
    }
  ],
  "relationships": [
    {
      "from": "Order.customer_id",
      "to": "Customer.customer_id",
      "kind": "fk"
    }
  ],
  "scenarios": [],
  "output": {
    "format": "csv"
  }
}
```

From the schema payload’s own minimal example.

## Common questions

**What is the smallest recipe that works?**

A project, a seed, an output format and one entity with one field. The minimal example below is the one the schema payload itself carries; validate it with validate_recipe or worklens check before generating.

## Related

- [Recipe keys](https://theworklens.com/docs/reference/recipe-keys): Every key a WorkLens recipe can declare, grouped the way the engine groups them, with a plain-English line for each.
- [Fields & types](https://theworklens.com/docs/recipes/fields): Every field key a recipe accepts, the 20 value types the engine generates, and how a field declares a checksum-valid identifier.
- [Entities](https://theworklens.com/docs/recipes/entities): How a recipe declares its tables — name, row count, fields, and the table-level constructs that shape whole rows.
- [Best practices](https://theworklens.com/docs/guides/best-practices): The 21 rules the engine gives an AI agent before it drafts a recipe — 6 of them critical — as useful to a person as to a model.

_← Previous: [Recipe keys](https://theworklens.com/docs/reference/recipe-keys) · Next: [SDK API](https://theworklens.com/docs/reference/sdk-api) →_

_Generated from the schema payload the MCP server returns. Regenerated whenever that contract changes. Source: get_recipe_schema (contract v3)._

_Canonical: https://theworklens.com/docs/reference/recipe-schema · This copy: https://theworklens.com/docs/reference/recipe-schema.md_
