Mirra
Mirra APIDocuments

Document Endpoints

This page documents all available operations for uploading, managing, and searching documents on the Mirra platform.

Upload Document

Upload and process a new document. The document is extracted, chunked, embedded, and stored in the specified graph.

Endpoint

POST /api/sdk/v1/documents/upload

Request Body

{
  file: "base64EncodedFileContent...",
  filename: "quarterly-report.pdf",
  mimeType: "application/pdf",
  title: "Q4 2024 Financial Report",
  author: "Finance Team",
  productTags: ["finance", "quarterly", "2024"],
  graphId: "user:abc-123"  // Optional, defaults to personal graph
}

Response

{
  "success": true,
  "data": {
    "documentId": "doc_abc123def456",
    "chunkCount": 47,
    "processingTimeMs": 2340,
    "graphIds": ["user:abc-123"]
  }
}

Get Document

Retrieve full document metadata including all chunks.

Endpoint

GET /api/sdk/v1/documents/{documentId}

Response

{
  "success": true,
  "data": {
    "document": {
      "documentId": "doc_abc123",
      "filename": "report.pdf",
      "title": "Q4 2024 Report",
      "author": "Finance Team",
      "uploadedAt": 1699876543000,
      "chunkCount": 47
    },
    "chunks": [
      {
        "chunkId": "chunk_123",
        "content": "The primary revenue drivers...",
        "position": 0,
        "pageNumber": 12
      }
    ]
  }
}

Get Document Status

Check the processing status of a document without retrieving all chunks.

Endpoint

GET /api/sdk/v1/documents/{documentId}/status

Response

{
  "success": true,
  "data": {
    "documentId": "doc_abc123",
    "status": "completed",
    "chunkCount": 47,
    "uploadedAt": 1699876543000
  }
}

Get Document Chunks

Retrieve all chunks for a document without the parent metadata.

Endpoint

GET /api/sdk/v1/documents/{documentId}/chunks

Response

{
  "success": true,
  "data": {
    "chunks": [
      {
        "chunkId": "chunk_123",
        "documentId": "doc_abc123",
        "content": "Chunk text content...",
        "position": 0,
        "pageNumber": 1,
        "charOffset": 0
      }
    ],
    "count": 47
  }
}

Delete Document

Delete a document and all its associated chunks from the knowledge graph.

Endpoint

DELETE /api/sdk/v1/documents/{documentId}

Response

{
  "success": true,
  "data": {
    "chunksDeleted": 47
  }
}

Note: Deleting a document removes it from all graphs it's shared in. This operation cannot be undone.


Share Document

Share a document to another graph (group or user contact).

Endpoint

POST /api/sdk/v1/documents/{documentId}/share

Request Body

{
  "targetGraphId": "group:team-finance",
  "shareReason": "For quarterly review meeting"
}

Response

{
  "success": true,
  "data": {
    "documentId": "doc_abc123",
    "graphIds": ["user:abc-123", "group:team-finance"],
    "shareEvent": {
      "sharedAt": 1699876543000,
      "sharedBy": "user:abc-123",
      "reason": "For quarterly review meeting"
    }
  }
}

Unshare Document

Remove document access from a specific graph.

Endpoint

DELETE /api/sdk/v1/documents/{documentId}/share/{graphId}

Response

{
  "success": true,
  "data": {
    "documentId": "doc_abc123",
    "graphIds": ["user:abc-123"]
  }
}

Note: You cannot unshare a document from its primary graph (the graph it was originally uploaded to).


List Document Graphs

List all graphs a document is shared in, with metadata about each share event.

Endpoint

GET /api/sdk/v1/documents/{documentId}/graphs

Response

{
  "success": true,
  "data": {
    "documentId": "doc_abc123",
    "graphs": [
      {
        "graphId": "user:abc-123",
        "graphType": "personal",
        "graphName": "Personal Graph",
        "isPrimary": true,
        "sharedAt": 1699876543000,
        "sharedByUserId": "user:abc-123"
      },
      {
        "graphId": "group:team-finance",
        "graphType": "group",
        "graphName": "Finance Team",
        "isPrimary": false,
        "sharedAt": 1699877000000,
        "sharedByUserId": "user:abc-123",
        "shareReason": "For quarterly review meeting"
      }
    ]
  }
}

Search Documents

Perform semantic search across document chunks within a specific graph.

Endpoint

POST /api/sdk/v1/documents/search

Request Body

{
  "query": "quarterly revenue growth analysis",
  "graphId": "user:abc-123",  // Optional, defaults to personal graph
  "limit": 10,                // Optional, default: 10
  "threshold": 0.7           // Optional, default: 0.7
}

Response

{
  "success": true,
  "data": {
    "results": [
      {
        "chunkId": "chunk_123",
        "documentId": "doc_abc123",
        "documentName": "q4-2024.pdf",
        "content": "The primary revenue drivers for Q4...",
        "score": 0.892,
        "position": 23,
        "pageNumber": 12
      }
    ],
    "count": 5
  }
}

The threshold parameter filters results below a minimum similarity score. Lower thresholds return more results but may include less relevant chunks.


List Documents

List all documents accessible in a specific graph with pagination support.

Endpoint

GET /api/sdk/v1/documents

Query Parameters

  • graphId (string, optional) - Graph to list documents from (defaults to personal graph)
  • limit (number, optional) - Results per page (default: 10)
  • offset (number, optional) - Pagination offset (default: 0)

Response

{
  "success": true,
  "data": {
    "documents": [
      {
        "documentId": "doc_abc123",
        "filename": "report.pdf",
        "title": "Q4 2024 Report",
        "author": "Finance Team",
        "chunkCount": 47,
        "uploadedAt": 1699876543000,
        "productTags": ["finance", "quarterly"]
      }
    ],
    "count": 15
  }
}

See Also

  • Overview - Document concepts and processing pipeline
  • Examples - Practical code examples
  • Technical Notes - Supported formats, embeddings, and troubleshooting

On this page