Skip to content

Uploading Documentation

The upload_docs tool uploads documentation files to the Cyborg backend for processing and indexing.

Basic Usage

Upload my documentation files from ./cyborg-docs

Or with explicit parameters:

json
upload_docs({
  "filePaths": ["./cyborg-docs/**/*.md"],
  "docsDir": "./cyborg-docs",
  "documentType": "markdown"
})

Parameters

ParameterTypeRequiredDefaultDescription
publishableKeystringNoenv varCyborg publishable key
filePathsstring[]Yes-Glob patterns for files to upload
docsDirstringNo./cyborg-docsBase directory for state file
documentType'markdown' | 'text'NomarkdownDocument type for processing

What Happens

  1. Files are read and content hashes calculated (SHA-256)
  2. Batch upload to Cyborg API
  3. Backend processes files: chunking, embedding, indexing
  4. State file updated with document IDs and hashes

State File

After upload, .cyborg-state.json is created/updated:

json
{
  "apiUrl": "https://api.cyborgsdk.dev/api/v1",
  "lastSyncedAt": "2025-01-15T10:30:00Z",
  "files": {
    "getting-started.md": {
      "documentId": "doc_abc123",
      "contentHash": "sha256:e3b0c44298fc...",
      "syncedAt": "2025-01-15T10:30:00Z"
    }
  }
}

Response

json
{
  "success": true,
  "uploaded": [
    { "path": "getting-started.md", "documentId": "doc_abc123" },
    { "path": "api/useChat.md", "documentId": "doc_def456" }
  ],
  "failed": []
}

Examples

Upload All Markdown Files

json
upload_docs({
  "filePaths": ["./docs/**/*.md"]
})

Upload Specific Files

json
upload_docs({
  "filePaths": [
    "./README.md",
    "./docs/getting-started.md",
    "./docs/api-reference.md"
  ]
})

Upload with Custom Directory

json
upload_docs({
  "filePaths": ["./documentation/**/*.md"],
  "docsDir": "./documentation"
})

Error Handling

If some files fail to upload:

json
{
  "success": false,
  "uploaded": [
    { "path": "getting-started.md", "documentId": "doc_abc123" }
  ],
  "failed": [
    { "path": "api/useChat.md", "error": "File too large" }
  ]
}

Best Practices

  1. Use glob patterns for bulk uploads: ./docs/**/*.md
  2. Commit the state file to version control
  3. Review before uploading - check generated docs first
  4. Use consistent structure - helps the AI understand your docs

Next Steps

Built with VitePress