Docs
Reference

Output Artifact Reference

Reference tables for final output viewers, Markdown breyta-resource embeds,
table queries, aggregates, charts, downloads, media, and structured output.

For the authoring model and examples in context, start with
Output Artifacts.

Complete Report Pattern

Use this as the reference pattern when you need to combine the full output
authoring surface in one report:

Report sectionWhat it demonstrates
Daily retail operations briefSingle canonical Markdown output envelope.
Open orders needing follow-upEmbedded table resource with selected columns, filters, sorting, formatting, and bounded snapshot page.
Fulfillment status mixAggregate query and bar chart from the same table resource.
Order value trendLine chart from table rows using :type :line.
Visual contextInline SVG image and video resource embeds.
Supporting resourcesResource-ref table cells and direct Markdown res:// links that drill into the Breyta resource viewer.
Embedded detailsNested Markdown, text, and JSON resources rendered inline.
AttachmentsThe same resources rendered as compact :view :download affordances at the bottom of the report.

Minimal authoring shape:

(let [orders-table (flow/step :function :persist-orders
                              {:persist {:type :table
                                         :rows-path [:rows]}})
      nested-report (flow/step :function :persist-nested-report
                               {:persist {:type :blob
                                          :content-type "text/markdown"}})
      image (flow/step :function :persist-image
                       {:persist {:type :blob
                                  :content-type "image/svg+xml"}})
      video (flow/step :function :persist-video
                       {:persist {:type :blob
                                  :content-type "video/mp4"}})
      table-uri (:uri orders-table)
      report (str "# Daily retail operations brief\n\n"
                  "```breyta-resource\n"
                  (pr-str {:resource table-uri
                           :view :table
                           :mode :snapshot
                           :title "Filtered open orders"
                           :table {:query {:select [:order-id :customer :amount]
                                           :where [[:status := "open"]]
                                           :sort [[:created-at :desc]]
                                           :page {:mode :offset :limit 25}}
                                   :row-transform "(fn [row]\n  (assoc row :customer (str (:customer row) \" - review\")))"
                                   :columns {"amount" {:label "Amount"
                                                       :format {:display "currency"
                                                                :currency "USD"}}}}})
                  "\n```\n\n"
                  "```breyta-resource\n"
                  (pr-str {:resource table-uri
                           :view :table
                           :mode :snapshot
                           :title "Orders by status"
                           :table {:aggregate {:group-by ["status"]
                                               :metrics [{:op :count :as "orders"}]}
                                   :chart {:x "status"
                                           :series [{:field "orders"
                                                     :type :bar}]}}})
                  "\n```\n\n"
                  "```breyta-resource\n"
                  (pr-str {:resource table-uri
                           :view :table
                           :mode :snapshot
                           :title "Order value trend"
                           :table {:query {:select [:created-at :amount]
                                           :sort [[:created-at :asc]]
                                           :page {:mode :offset :limit 25}}
                                   :columns {"created-at" {:label "Created"
                                                           :format {:display "timestamp"}}
                                             "amount" {:label "Order value"
                                                       :format {:display "currency"
                                                                :currency "USD"}}}
                                   :chart {:x "created-at"
                                           :series [{:field "amount"
                                                     :label "Order value"
                                                     :type :line}]}}})
                  "\n```\n\n"
                  "See [Analyst note](" (:uri nested-report) ").\n\n"
                  "```breyta-resource\n"
                  (pr-str {:resource (:uri image)
                           :view :image
                           :alt "Fulfillment lane dashboard snapshot"})
                  "\n```\n\n"
                  "## Attachments\n\n"
                  "```breyta-resource\n"
                  (pr-str {:resource table-uri
                           :view :download
                           :title "Orders source CSV"
                           :format :csv})
                  "\n```\n\n"
                  "```breyta-resource\n"
                  (pr-str {:resource (:uri video)
                           :view :download
                           :title "Packing station clip video"})
                  "\n```")]
  {:breyta.viewer/kind :markdown
   :breyta.viewer/options {:title "Markdown resource output"}
   :breyta.viewer/value report})

The complete pattern can include one example of every current embed adapter:
:table, table :aggregate, bar and line table :chart, :download, :markdown,
:text, :json, :image, and :video.

Viewer Envelope

Return a viewer envelope when you want predictable rendering:

{:breyta.viewer/kind :markdown
 :breyta.viewer/options {:title "Summary"}
 :breyta.viewer/value "# Summary\n\nDone."}
KeyRequiredMeaning
:breyta.viewer/kindYesViewer type.
:breyta.viewer/valueYesPayload rendered by the viewer.
:breyta.viewer/optionsNoViewer metadata such as title, alt text, and output metadata.
:breyta.viewer/itemsFor :groupOrdered child viewer envelopes.

:breyta.viewer/options {:title ...} provides viewer metadata and can label
grouped child artifacts. It does not rename the canonical flow-output resource
or the single final output page/panel chrome. Recent-run row titles are
configured separately on the run form with :title.

Viewer Kinds

KindUse whenValue shape
:markdownHuman-readable report or narrative output.Markdown string.
:rawStructured map/vector/scalar is the intended product output.Any EDN/JSON-compatible value.
:textPlain text should preserve line breaks.String.
:tableA persisted Breyta table resource is the primary artifact.Resource ref from :persist {:type :table ...}.
:imageDedicated image viewer is best.URL, signed URL, or persisted blob result.
:audioDedicated audio viewer is best.URL, signed URL, or persisted blob result.
:videoDedicated video viewer is best.URL, signed URL, or persisted blob result.
:downloadCompact file/table download affordance.Map with :download-url and optional metadata.
:groupMultiple top-level artifacts are needed.:breyta.viewer/items vector.

Markdown Resource Directive

Inside a Markdown viewer, embed resources with a fenced block:

```breyta-resource
{:resource "res://v1/ws/ws-123/result/table/tbl_orders"
 :view :table
 :mode :snapshot
 :title "Open orders"
 :table {:query {:select ["order-id" "customer" "amount"]
                 :where [["status" := "open"]]
                 :page {:mode :offset :limit 25}}}}
```
FieldRequiredApplies toMeaning
:resourceYesAll embedsAbsolute res://... URI in the current workspace.
:viewNoAll embeds:auto, :table, :markdown, :text, :json, :image, :audio, :video, or :download. Defaults to :auto.
:modeNoAll embeds:snapshot in v1. Snapshot is the default. :live is reserved and not supported.
:titleNoAll embedsDisplay title/caption where the adapter renders one. For embedded tables, use Markdown headings for visible titles.
:label, :nameNoAll embedsAlternate display-name fields when :title is absent.
:altNoImage embedsImage alt text.
:formatNoDownload embedsDownload/export format, for example :csv.
:partition-keyNoTable/download embedsSingle table-family partition key.
:partition-keysNoTable/download embedsMultiple table-family partition keys when supported.
:partitionsNoTable/download embedsExplicit partition target shape when supported by the table service.
:tableNoTable embedsQuery, aggregate, chart, columns, and partition options.
:row-transformNoTable embedsSnapshot-time sandboxed Clojure function that maps each resolved row to a display row.

Embed Pattern Matrix

PatternDirective shapeNotes
Auto{:resource uri :view :auto}Uses content type and resource metadata. Prefer explicit views for public outputs.
Table query{:resource uri :view :table :table {:query query}}Bounded row snapshot.
Table aggregate{:resource uri :view :table :table {:aggregate aggregate}}Grouped metric snapshot.
Table chart{:resource uri :view :table :table {:query query :chart chart}}Chart uses the same query/aggregate rows as the table.
Download{:resource uri :view :download}Table resources default to CSV.
Markdown{:resource uri :view :markdown}Renders persisted Markdown inline.
Text{:resource uri :view :text}Renders plain text.
JSON{:resource uri :view :json}Renders persisted JSON as formatted raw output.
Image{:resource uri :view :image :alt "..."}Uses signed resource content URLs.
Audio{:resource uri :view :audio}Uses signed resource content URLs.
Video{:resource uri :view :video}Uses signed resource content URLs.

Snapshot And Live Mode

Markdown resource embeds are resolved as snapshots. The resource is read or
queried by the output resolver, converted into viewer metadata, and rendered
from that snapshot in document order.

ModeSupportedBehavior
:snapshotYesDefault. Resolve the resource into a stable viewer snapshot for the run output.
omitted :modeYesSame as :snapshot.
:liveNoReserved for a future contract. Current renderer returns an inline unsupported-mode fallback.

V1 does not support live resource-backed pagination, arbitrary re-querying from
the browser, or client-side resource fetches from Markdown embeds. Use bounded
query/aggregate options in the directive so the report output is stable.

Directive blocks are intentionally bounded authoring data. Keep each
breyta-resource block small, use the documented enum-like values for fields
such as :view, :mode, and :format, and put large row shaping logic in flow
functions before persisting the resource. The renderer rejects oversized
directives and unsupported values with an inline fallback.

Table Query Options

Static Markdown tables and Breyta table resource embeds are separate output
patterns. Use normal Markdown table syntax for fixed explanatory rows inside a
report. Use :view :table when the output should render a persisted table
resource with bounded query, aggregate, chart, download, or drilldown behavior.

{:query {:select [:order-id :customer :amount :created-at]
         :where [[:status := "open"]]
         :sort [[:created-at :desc]]
         :page {:mode :offset :limit 25}}}

Field names in :select, :where, :sort, :group-by, :order-by, and
metric :field / :as values may be strings or keywords.

FieldRequiredMeaning
:selectNoOrdered fields to show. Omit only when the table default preview is intended.
:whereNoFilter clauses, for example [["status" := "open"]].
:sortNoSort clauses, for example [["created-at" :desc]].
:pageYes for stable public outputBounded page options. Use {:mode :offset :limit N} in v1 Markdown embeds.
Predicate opMeaning
:=Equal.
:!=Not equal.
:>Greater than.
:>=Greater than or equal.
:<Less than.
:<=Less than or equal.
:containsContains text/value where supported.
Sort directionMeaning
:ascAscending.
:descDescending.

Table Aggregate Options

{:aggregate {:where [["created-at" :>= "2026-05-01T00:00:00Z"]]
             :group-by ["status"]
             :metrics [{:op :count :as "orders"}
                       {:op :sum :field "amount" :as "total-amount"}]
             :having [["orders" :>= 1]]
             :order-by [["status" :asc]]
             :limit 10}}
FieldRequiredMeaning
:whereNoFilters applied before grouping.
:group-byYesFields to group rows by.
:metricsYesMetric maps with :op, optional :field, and :as.
:havingNoFilters applied after grouping; can reference group keys and metric aliases.
:order-byNoSort clauses for aggregate result rows.
:limitNoBounded aggregate result size. Defaults to 25 rows and is capped at 100 rows.
Metric :opRequires :fieldMeaning
:countNoCount rows in the group.
:sumYesSum numeric field values.
:avgYesAverage numeric field values.
:minYesMinimum field value.
:maxYesMaximum field value.
:count-distinctYesCount distinct field values.
:arg-maxYesReturn :field from the row with the largest :order-field.
:arg-minYesReturn :field from the row with the smallest :order-field.
:collect-setYesReturn a bounded deterministic set of distinct field values; include :limit.
:percentileYesNumeric percentile; include :p in 0.0..1.0.
:medianYesMedian numeric field value.

Metric-local filters are supported:

{:op :count
 :where [["status" := "open"]]
 :as "open-orders"}

Argument metric example:

{:op :arg-max
 :field "order-id"
 :order-field "amount"
 :as "largest-order-id"}

Bucketed group-by examples:

{:group-by [{:field "created-at"
             :bucket {:op :date-trunc :unit :month}
             :as "created-month"}]
 :metrics [{:op :count :as "orders"}]
 :limit 12}
{:group-by [{:field "amount"
             :bucket {:op :numeric-bin :size 10}
             :as "amount-bin"}]
 :metrics [{:op :count :as "orders"}
           {:op :percentile :field "amount" :p 0.95 :as "p95-amount"}]
 :limit 20}

Table Column Presentation

{:columns {"amount" {:label "Amount"
                     :format {:display "currency" :currency "USD"}}
           "created-at" {:label "Created"
                         :format {:display "timestamp"}}}}
FieldMeaning
:labelHuman column heading.
:formatDisplay format metadata.
:semantic-typeOptional semantic hint.
:type-hintOptional type hint.
FormatExample
Currency{:display "currency" :currency "USD"}
Timestamp{:display "timestamp"}
Relative time{:display "relative-time"}
Email{:display "email"}
URL/link{:display "url"}

Table Row Transform

Use :row-transform when column labels and built-in formats are not enough for
the final display row. The transform runs once while the Markdown resource
snapshot is produced, after query/aggregate/selection and before the output is
stored. It is not re-run on every page read.

{:resource "res://v1/ws/ws-123/result/table/tbl_orders"
 :view :table
 :mode :snapshot
 :table {:query {:select [:order-id :customer :amount]
                 :where [[:status := "open"]]
                 :page {:mode :offset :limit 25}}
         :row-transform "(fn [row]\n  (assoc row :customer\n         (str (:customer row) \" - \"\n              (if (< (:amount row) 10)\n                \"batch pickup\"\n                \"monitor cutoff\"))))"}}
RuleMeaning
InputEach function call receives one row map from the bounded snapshot.
OutputReturn one row map. The renderer preserves row count and order.
TimingRuns at snapshot creation time, not in the browser.
SandboxUses the same bounded Clojure sandbox used for flow data transforms. See the :function sandbox helper reference for available breyta.sandbox/*, json/*, string, regex, collection, and limited Java time helpers.
ScopePresentation-only. Use flow steps for durable data normalization.
SizeKeep transform source small. Oversized transform forms are rejected before sandbox evaluation.

Table Chart Options

{:chart {:title "Order count by status"
         :x "status"
         :series [{:field "orders"
                   :label "Orders"
                   :type :bar}]
         :height 220}}

Line chart:

{:chart {:title "Order value trend"
         :x "created-at"
         :series [{:field "amount"
                   :label "Order value"
                   :type :line}]
         :height 220}}
FieldRequiredMeaning
:titleNoChart title metadata. Markdown embeds do not render this as extra card chrome.
:xNoCategory/label field. Defaults to the first visible field.
:seriesYesSeries maps with :field, optional :label, and optional :type.
:heightNoChart height in pixels. Defaults to 220 and is clamped to 120-480.
:y-min, :y-maxNoOptional y-domain overrides. Defaults include zero.
Series fieldMeaning
:fieldNumeric field to plot.
:labelLegend/display label.
:type:bar or :line.

Chart x-axis and hover labels reuse the table column display formatting for the
:x field. For timestamp/date period fields, set the column :format so the
chart shows compact labels instead of raw ISO strings:

{:query {:select [:created-at :amount]
         :page {:mode :offset :limit 25}}
 :columns {"created-at" {:label "Created"
                         :format {:display "timestamp"}}}
 :chart {:x "created-at"
         :series [{:field "amount" :type :line}]}}

Charts include zero in the y-domain by default. Use explicit :y-min and
:y-max chart options when a custom y-domain is required.

Table Family Partitions

FieldUse when
:partition-keyRendering one explicit partition.
:partition-keysRendering several explicit partitions where supported.
:partitionsPassing the table service's explicit partition target shape.

Pin partitioned table families for stable snapshots:

{:resource "res://v1/ws/ws-123/result/table/tbl_orders_by_year"
 :view :table
 :table {:partition-key "2026"
         :query {:select ["order-id" "amount"]
                 :page {:mode :offset :limit 25}}}}

Download Options

FieldApplies toMeaning
:format :csvTable resourcesExport/download table snapshot as CSV.
:partition-keyTable familiesExport one partition.
:titleAll downloadsUser-facing download card title.
{:resource "res://v1/ws/ws-123/result/table/tbl_orders"
 :view :download
 :title "Orders source CSV"
 :format :csv}

In the rendered Breyta UI this becomes a compact source/download affordance.
When a user copies the whole Markdown output, the same embed becomes a normal
Markdown link with an absolute Breyta app deep link to the resource viewer:

[Orders source CSV](https://flows.breyta.ai/ws-123/resources/panel?uri=...)

Use this when a report should show a table snapshot inline but also expose the
underlying source/export as a portable link.

Resource Links In Tables

Table cells can point at other resources by storing canonical resource refs in
row data:

{:resource "Analyst note"
 :type "Markdown"
 :open {:type :resource-ref
        :uri "res://v1/ws/ws-123/file/blob/.../analyst-note.md"
        :label "Analyst note"}}

The web table renderer displays these cells as clickable resource links. In a
run Output panel, clicking the link opens the target resource in the same panel
and shows a compact Output return link. CLI/API table reads and CSV export
keep the canonical raw resource-ref value. Copied Markdown table output uses the
rendered label for the cell.

Structured Map Output

Do not paste maps into Markdown paragraphs. Use one of these:

NeedShape
Structured value is the product output{:breyta.viewer/kind :raw :breyta.viewer/value data}
Persisted JSON inside a report{:resource uri :view :json} inside a breyta-resource fence
Supporting detail in a reportFenced clojure, edn, or json code block
Human summaryConvert the data to prose, bullets, or a Markdown table

Copy Markdown Export

The floating copy action on a Markdown output exports portable Markdown where
resolved resource embeds are converted when possible.

Resolved embedCopied Markdown output
Table query/aggregate snapshotMarkdown table.
Markdown resourceMarkdown content.
Text resourceFenced text code block.
JSON/raw resourceFenced clojure code block, pretty-printed when the value is EDN/JSON-like.
Image resourceMarkdown image link using an absolute Breyta content URL, wrapped in an absolute Breyta resource-viewer link when the resource URI is known.
Audio/video/download resourceMarkdown link to the absolute Breyta resource viewer when the resource URI is known; otherwise the direct content/download URL.
Unsupported conversionOriginal breyta-resource fence is preserved.

Absolute links are built from the current Breyta request host. Resource-backed
links prefer Breyta app deep links so clicking them opens the resource output in
Breyta. Normal Breyta access controls still apply when the linked resource is
opened.

As of Jun 9, 2026