Mirra
REST API ReferenceStructured Data

Structured Data Types

TypeScript type definitions for structured data

This page documents all TypeScript types used for structured data. These types are exported from @mirra-messenger/shared-types.

These types are auto-generated from the source code. Changes to the source types will be reflected here after regeneration.


StructuredDisplayType

Display types that determine how structured data is rendered.

type StructuredDisplayType =
  | 'list'           // List of items (contacts, chats, files, etc.)
  | 'card'           // Single card with rich details
  | 'table'          // Tabular data with rows/columns
  | 'grid'           // Grid layout (e.g., photo grid)
  | 'summary'        // Summary/stats view with aggregated info
  | 'conversation'   // Message thread or conversation view
  | 'media_grid'     // Grid of images/videos
  | 'custom';        // Custom component (requires special handling)

Currently, only list and card are fully supported in the mobile app.


StructuredData

Main container for structured data. Include this in the structuredData array when sending messages.

interface StructuredData {
  displayType: StructuredDisplayType;
  templateId: string;
  data: {
    // For 'list' display type
    items?: StructuredDisplayItem[];
 
    // For 'card' display type
    title?: string;
    subtitle?: string;
    icon?: string;
    badges?: StructuredCardBadge[];
    steps?: StructuredCardStep[];
    summary?: Record<string, string | number>;
    defaultExpanded?: boolean;
  };
  metadata?: {
    totalCount?: number;
    query?: string;
    source?: string;
    timestamp?: string | Date;
    [key: string]: any;
  };
  interactions?: StructuredDataInteractions;
  targets?: StructuredDataTarget[];
}
PropertyTypeRequiredDescription
displayTypeStructuredDisplayTypeYesHow this data should be rendered
templateIdstringYesTemplate identifier for specific rendering logic
dataobjectYesThe actual data to display (structure varies by displayType)
metadataobjectNoMetadata about the result (counts, source, etc.)
interactionsStructuredDataInteractionsNoAvailable user interactions
targetsStructuredDataTarget[]NoTarget entities for actions

StructuredDisplayItem

Core display item structure used in lists. Each item represents a selectable row.

interface StructuredDisplayItem {
  id: string;
  title: string;
  subtitle?: string;
  icon?: string;
  iconUrl?: string;
  badge?: string;
  badgeVariant?: 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
  imageUrl?: string;
  metadata?: Record<string, any>;
}
PropertyTypeRequiredDescription
idstringYesUnique identifier for the item
titlestringYesPrimary display text
subtitlestringNoSecondary display text
iconstringNoIcon identifier (e.g., 'person', 'document')
iconUrlstringNoCustom icon image URL (overrides icon)
badgestringNoBadge text (e.g., count, status)
badgeVariantstringNoBadge color variant
imageUrlstringNoOptional image URL
metadataobjectNoAdditional item-specific metadata

StructuredCardStep

A step/item within a card display. Used for showing execution progress or sequential items.

interface StructuredCardStep {
  id: string;
  title: string;
  description?: string;
  status?: 'success' | 'error' | 'pending' | 'skipped';
  icon?: string;
  detail?: string;
  timestamp?: string;
  durationMs?: number;
}
PropertyTypeRequiredDescription
idstringYesUnique identifier for the step
titlestringYesPrimary text for the step
descriptionstringNoSecondary description
statusstringNoStatus indicator (affects icon and color)
iconstringNoIcon identifier
detailstringNoExpandable detail content (code, output)
timestampstringNoWhen this step occurred
durationMsnumberNoDuration in milliseconds

StructuredCardBadge

Badge displayed in card headers. Shows counts, status indicators, or labels.

interface StructuredCardBadge {
  label: string;
  variant?: 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
}
PropertyTypeRequiredDescription
labelstringYesBadge text
variantstringNoColor variant (affects background and text color)

StructuredDataInteractions

Defines what interactions users can have with the structured data.

interface StructuredDataInteractions {
  primaryAction?: string;
  secondaryActions?: string[];
  allowSelection?: boolean;
  allowMultiSelect?: boolean;
  customActions?: Array<{
    id: string;
    label: string;
    icon?: string;
    variant?: 'default' | 'primary' | 'destructive';
  }>;
}
PropertyTypeRequiredDescription
primaryActionstringNoPrimary action (e.g., 'view', 'edit')
secondaryActionsstring[]NoAdditional available actions
allowSelectionbooleanNoWhether items are selectable
allowMultiSelectbooleanNoWhether multiple items can be selected
customActionsarrayNoCustom action buttons

StructuredDataTarget

Target entity for an action. Used to show what will be affected by an action.

interface StructuredDataTarget {
  friendlyName: string;
  technicalName: string;
  username?: string;
  type?: 'person' | 'chat' | 'group' | 'channel' | 'email' | 'file' | 'calendar' | 'other';
  icon?: string;
  iconUrl?: string;
  metadata?: Record<string, any>;
}
PropertyTypeRequiredDescription
friendlyNamestringYesUser-recognizable name
technicalNamestringYesTechnical identifier (ID, email, etc.)
usernamestringNoUsername or handle
typestringNoType of target entity
iconstringNoIcon name
iconUrlstringNoCustom icon URL
metadataobjectNoAdditional target metadata

On this page