Skip to main content

Storage overview

Mastra storage is organized into domains. Each domain owns a set of tables or collections. Depending on your adapter and configuration, you may use all domains or only a subset.

Storage domains
Direct link to Storage domains

MastraCompositeStore can route the following domain keys:

Not every storage adapter implements every domain. Composite storage lets you mix adapters per domain when the adapter packages export the corresponding domain classes.

DomainDescription
memoryConversation persistence: messages, threads, and resources (including working memory).
workflowsWorkflow run snapshots used for suspend and resume.
scoresEvaluation score records from eval runs.
observabilityTraces and spans used by observability exporters and Studio.
datasetsDataset records, versioned items, and dataset versions used by experiments.
experimentsExperiment runs and per-item experiment results.

The schema definitions below cover the built-in database-backed tables documented for memory, workflows, scores, and observability. Other domains, and non-database adapters, use implementation-specific storage structures.

Core schema
Direct link to Core schema

Stores conversation messages and their metadata. Each message belongs to a thread and contains the actual content along with metadata about the sender role and message type.

id
uuidv4
PRIMARYKEY
NOT NULL
Unique identifier for the message (format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
thread_id
uuidv4
FK → threads.id
NOT NULL
Parent thread reference
resourceId
uuidv4
CAN BE NULL
ID of the resource that owns this message
content
text
NOT NULL
JSON of the message content in V2 format. Example: { format: 2, parts: [...] }
role
text
NOT NULL
Enum of user | assistant
createdAt
timestamp
NOT NULL
Used for thread message ordering

The message content column contains a JSON object conforming to the MastraMessageContentV2 type, which is designed to align closely with the AI SDK UIMessage message shape.

format
integer
NOT NULL
Message format version (currently 2)
parts
array (JSON)
NOT NULL
Array of message parts (text, tool-invocation, file, reasoning, etc.). The structure of items in this array varies by type.
experimental_attachments
array (JSON)
CAN BE NULL
Optional array of file attachments
content
text
CAN BE NULL
Optional main text content of the message
toolInvocations
array (JSON)
CAN BE NULL
Optional array summarizing tool calls and results
reasoning
object (JSON)
CAN BE NULL
Optional information about the reasoning process behind the assistant's response
annotations
object (JSON)
CAN BE NULL
Optional additional metadata or annotations
On this page