Mirra
SDK ReferenceDocuments

Documents

SDK reference for documents operations

Overview

Document upload, processing, and management with multi-graph sharing

  • Category: storage
  • Auth Required: No
  • Supported Modes: standard, delegated, service

Operations

upload

Upload and process a document (PDF, DOCX, TXT, MD). Returns normalized flat structure.

Arguments:

  • file (string, required): Base64 encoded file content
  • filename (string, required): Original filename with extension
  • mimeType (string, required): MIME type (application/pdf, text/plain, etc.)
  • graphId (string, optional): Target graph ID (defaults to user's personal graph)
  • title (string, optional): Custom document title
  • productTags (array, optional): Array of product tags for categorization

Returns:

AdapterOperationResult - Returns FLAT structure with: documentId, chunkCount, graphIds[], primaryGraphId, processingTimeMs. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringCreated document ID
chunkCountnumberNumber of chunks created
graphIdsstring[]Array of graph IDs
primaryGraphIdstringPrimary/owner graph ID
processingTimeMsnumberProcessing time in milliseconds

Example:

const result = await mirra.document.upload({
  file: "example",
  filename: "example",
  mimeType: "example"
});

get

Get document metadata and content. Returns normalized flat structure.

Arguments:

  • documentId (string, required): Document ID to retrieve

Returns:

AdapterOperationResult - Returns FLAT structure with: documentId, title, filename, mimeType, fileSize, processingStatus, chunkCount, graphIds[], primaryGraphId, createdAt, createdByUserId, hasMultipleGraphs, chunks[]. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDocument ID
titlestringDocument title
filenamestringOriginal filename
mimeTypestringMIME type
fileSizenumberFile size in bytes
processingStatusstringProcessing status
chunkCountnumberNumber of chunks
graphIdsstring[]Graph IDs document is in
primaryGraphIdstringPrimary graph ID
createdAtnumberCreation timestamp
createdByUserIdstringCreator user ID
hasMultipleGraphsbooleanWhether shared to multiple graphs
chunksDocumentChunk[]Document chunks
chunks item fields (DocumentChunk)
FieldTypeDescription
chunkIdstringUnique chunk ID
documentIdstringParent document ID
contentstringChunk text content
positionnumberPosition/order in document

Example:

const result = await mirra.document.get({
  documentId: "abc123"
});

getStatus

Get document processing status. Returns normalized flat structure.

Arguments:

  • documentId (string, required): Document ID to check

Returns:

AdapterOperationResult - Returns FLAT structure with: documentId, processingStatus, processingError, chunkCount, extractedAt, processingCompletedAt. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDocument ID
processingStatusstringStatus: processing, completed, failed
processingError`stringnull`
chunkCountnumberNumber of chunks
extractedAt`numbernull`
processingCompletedAt`numbernull`

Example:

const result = await mirra.document.getStatus({
  documentId: "abc123"
});

getChunks

Get all chunks for a document. Returns normalized flat chunk structures.

Arguments:

  • documentId (string, required): Document ID

Returns:

AdapterOperationResult - Returns { documentId, count, chunks[] }. Each chunk has FLAT fields: chunkId, documentId, content, position. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDocument ID
countnumberNumber of chunks
chunksDocumentChunk[]Document chunks
chunks item fields (DocumentChunk)
FieldTypeDescription
chunkIdstringUnique chunk ID
documentIdstringParent document ID
contentstringChunk text content
positionnumberPosition/order in document

Example:

const result = await mirra.document.getChunks({
  documentId: "abc123"
});

delete

Delete a document and all its chunks. Returns normalized flat structure.

Arguments:

  • documentId (string, required): Document ID to delete

Returns:

AdapterOperationResult - Returns FLAT structure with: documentId, deleted, chunksDeleted. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDeleted document ID
deletedbooleanWhether deletion succeeded
chunksDeletednumberNumber of chunks deleted

Example:

const result = await mirra.document.delete({
  documentId: "abc123"
});

share

Share a document to another graph (group or user-contact). Returns normalized flat structure.

Arguments:

  • documentId (string, required): Document ID to share
  • targetGraphId (string, required): Target graph ID to share to
  • shareReason (string, optional): Optional reason for sharing

Returns:

AdapterOperationResult - Returns FLAT structure with: documentId, graphIds[], sharedToGraphId, sharedByUserId, sharedAt. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDocument ID
graphIdsstring[]Updated graph IDs
sharedToGraphIdstringTarget graph ID
sharedByUserIdstringUser who shared
sharedAtnumberShare timestamp

Example:

const result = await mirra.document.share({
  documentId: "abc123",
  targetGraphId: "abc123"
});

unshare

Remove document access from a graph. Returns normalized flat structure.

Arguments:

  • documentId (string, required): Document ID
  • graphId (string, required): Graph ID to remove access from

Returns:

AdapterOperationResult - Returns FLAT structure with: documentId, graphIds[], removedGraphId. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDocument ID
graphIdsstring[]Updated graph IDs
removedGraphIdstringRemoved graph ID

Example:

const result = await mirra.document.unshare({
  documentId: "abc123",
  graphId: "abc123"
});

listGraphs

List all graphs a document is shared in. Returns normalized flat graph structures.

Arguments:

  • documentId (string, required): Document ID

Returns:

AdapterOperationResult - Returns { documentId, count, graphs[] }. Each graph has FLAT fields: graphId, isPrimary, sharedAt, sharedByUserId, shareReason. No nested objects.

Response Fields:

FieldTypeDescription
documentIdstringDocument ID
countnumberNumber of graphs
graphsDocumentGraphInfo[]Graph information
graphs item fields (DocumentGraphInfo)
FieldTypeDescription
graphIdstringGraph ID
isPrimarybooleanWhether this is the primary/original graph
sharedAtnumberUnix timestamp when shared
sharedByUserId`stringnull`
shareReason`stringnull`

Example:

const result = await mirra.document.listGraphs({
  documentId: "abc123"
});

Semantic search across document chunks. Returns normalized flat chunk structures.

Arguments:

  • query (string, required): Search query
  • graphId (string, optional): Graph ID to search in (defaults to user's graph)
  • limit (number, optional): Maximum results (default: 10)
  • threshold (number, optional): Similarity threshold 0-1 (default: 0.7)

Returns:

AdapterOperationResult - Returns { graphId, count, results[] }. Each result has FLAT fields: chunkId, documentId, content, score, position. No nested objects.

Response Fields:

FieldTypeDescription
graphIdstringSearched graph ID
countnumberNumber of results
resultsDocumentSearchResult[]Search results
results item fields (DocumentSearchResult)
FieldTypeDescription
chunkIdstringUnique chunk ID
documentIdstringParent document ID
contentstringChunk text content
positionnumberPosition/order in document
scorenumberSimilarity score 0-1

Example:

const result = await mirra.document.search({
  query: "example"
});

list

List documents in a graph. Returns normalized flat document structures.

Arguments:

  • graphId (string, optional): Graph ID to list documents from (defaults to user's graph)
  • limit (number, optional): Maximum results (default: 50)
  • offset (number, optional): Pagination offset (default: 0)

Returns:

AdapterOperationResult - Returns { graphId, count, documents[] }. Each document has FLAT fields: documentId, title, filename, mimeType, fileSize, processingStatus, chunkCount, graphIds[], createdAt, createdByUserId. No nested objects.

Response Fields:

FieldTypeDescription
graphIdstringListed graph ID
countnumberNumber of documents
documentsDocumentSummary[]Document summaries
documents item fields (DocumentSummary)
FieldTypeDescription
documentIdstringUnique document ID
titlestringDocument title
filenamestringOriginal filename
mimeTypestringMIME type of document
fileSizenumberFile size in bytes
processingStatusstringProcessing status: processing, completed, failed
chunkCountnumberNumber of chunks document was split into
graphIdsstring[]Array of graph IDs document is shared in
createdAtnumberUnix timestamp of creation
createdByUserIdstringUser ID who created document

Example:

const result = await mirra.document.list({});

On this page