Output
A comprehensive guide to structuring workflow outputs, including API responses, UI displays, metrics. Learn how to format and customize outputs using markdown, structured displays, diagrams and metric blocks.
Basic Output Structure
The last code step’s output determines what gets returned in API responses and displayed in the UI. Here’s the complete structure with all possible properties:
Result Property
The result
property is special and serves multiple purposes:
- API Response: Used as the response when running the workflow via API
- Record Access: Accessible through
record.rules.RULE_KEY.result
in the record API response when running a record via the API
Result Rules
- If the last code step includes a
result
property, it becomes the API response - If no
result
property exists, the entire output becomes the API response - Earlier steps’ results are overridden by the last code step
If you are only building workflows and running them via API, the result
property discussed above is all you need to understand for handling workflow
outputs. The following sections about display types and blocks are
specifically for showing outputs in record and rule contexts within Cortex.
If you’re not familiar with records and rules in Cortex, we recommend understanding those concepts first before proceeding to the next sections.
Understanding Rule and Record Output Properties
Properties related to rules and records are displayed in different contexts on the record page:
Record and rule properties serve different purposes in displaying results:
- Record properties (like
record_display
andrecord_blocks
) appear at the top level of the record page, showing the overall results and key metrics for the entire record - Rule properties (like
rule_display
andrule_blocks
) appear within their specific rule section on the record page, showing results specific to that individual rule
You can elevate important results to be more prominent by using record properties, which will display them at the top of the record page for better visibility.
Display Types
Display properties allow you to show information in different formats and contexts. You can use markdown for rich text formatting or structured arrays/objects for more complex layouts.
Markdown
All display properties support markdown formatting:
Structured Display
You can use arrays and objects for structured displays. Cortex will render them as beautiful, readable UI content. Each array can optionally include a configuration object as its first element:
Tables in Structured Display
Tables can be created using objects in structured displays. Each object represents a row, with keys as columns:
Display Configuration
In structured displays, any nested array can include a configuration object as its first element. However, this configuration object cannot be used at the root level of the display:
Mermaid Diagrams
Cortex supports Mermaid diagrams in display properties to output diagrams in the result UI. You can create various types of diagrams using Mermaid syntax, including:
- XY Charts
- Mindmaps
- Pie Charts
- C4 Diagrams
Basic Mermaid Usage
Dynamic Diagrams with Data
You can create diagrams dynamically using workflow data:
Metric Blocks
Blocks display key metrics with optional formatting and styling. All properties except label
and value
are optional.
Record Blocks
Rule Blocks
Block Properties
-
Required Properties:
label
: Identifies the metricvalue
: The actual value to display
-
Optional Properties:
description
: Tooltip text explaining the metricvalue_color
: Color styling for the valueformat
: How to format the valueorder
: Display order (numeric)
Available Formats
date
: Formats timestamps as datesdatetime
: Formats timestamps with date and timenumber
: Formats numerical valuescurrency
: Formats monetary valuespercent
: Formats percentage values
Available Colors
The following colors can be used to style values and variants in blocks and display UIs. Choose colors that effectively communicate the meaning and importance of the data being displayed.
Standard Colors
Available for variants and value colors:
status
- Special dynamic color based on statusinfo
- Informational bluesuccess
- Positive greendanger
- Critical redwarning
- Cautionary yelloworange
- Orange highlightyellow
- Yellow highlightgreen
- Green highlightred
- Red highlightblue
- Blue highlight
Special Status Color
The status
color is dynamic and changes based on the workflow or rule status:
Was this page helpful?