Skip to main content
GET
/
documents
/
viewer
View Document Content
curl --request GET \
  --url https://api.example.com/documents/viewer
Use the document viewer endpoint when a UI needs the full parsed text for a file preview. The endpoint returns a single standard response shape for tenant attachments and knowledge-base documents.

Query Parameters

ParameterTypeRequiredDescription
sourceknowledge_base | attachmentyesDocument source type
file_idstringfor attachmentsAttachment file ID
agent_idstringnoOptional agent scope for attachment authorization
kb_idstringfor KB documentsKnowledge base ID
document_idstringpreferred for KB documentsIndexed KB document ID
file_pathstringalternative for KB documentsSource file path or filename when a document ID is not available
For knowledge-base documents, prefer document_id from GET /api/v1/knowledge-bases/{kb_id}/files or GET /api/v1/knowledge-bases/{kb_id}/documents. Use file_path only when the caller has a source path but no indexed document ID.

Attachment Example

curl -H "Authorization: Bearer $AGENTFLOW_TOKEN" \
  "https://your-instance.agentflow.ai/api/v1/documents/viewer?source=attachment&file_id=file_abc123"

Knowledge Base Example

curl -H "Authorization: Bearer $AGENTFLOW_TOKEN" \
  "https://your-instance.agentflow.ai/api/v1/documents/viewer?source=knowledge_base&kb_id=kb_abc123&document_id=doc_abc123"

Response

{
  "filename": "handbook.md",
  "file_path": "handbook.md",
  "content": "# Handbook\n\nFull parsed text...",
  "size": 2048,
  "last_modified": "2026-04-28T10:00:00+00:00",
  "file_type": "MD",
  "encoding": "utf-8",
  "summary": "Optional attachment summary"
}
FieldTypeDescription
filenamestringDisplay filename
file_pathstringSource path or viewer path
contentstringFull parsed text
sizeintegerSource file size in bytes when available
last_modifiedstring | nullLast modified timestamp when available
file_typestringFile extension/type label
encodingstringText encoding, usually utf-8
summarystring | nullAttachment summary when available