Skip to content

Get file content by path ​

Interface Description ​

Read a readable knowledge-base file by its path, such as index.md or pages/example.md.

Endpoint ​

FieldValue
MethodGET
Path/openapi/v2/knowledge-bases/{knowledgeBaseId}/files/content
Operation IDgetFileContentByPath
AuthenticationBearer OpenAPI key

Parameters ​

NameLocationRequiredTypeExampleDescription
knowledgeBaseIdpathYesstringknowledge-base-11111111-1111-4111-8111-111111111111Knowledge-base identifier returned by knowledge-base APIs.
pathqueryYesstringpages/guide.mdReadable knowledge-base file path returned by tree, search, or file APIs. Parent traversal, backslashes, and storage paths are rejected.

Request Body ​

This operation has no request body.

Request Example ​

bash
curl -X GET "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/content?path=pages%2Fguide.md" \
  -H "Authorization: Bearer <openapi-key>"

Successful Responses ​

200 ​

Complete content of the readable file at the requested path. A file under pages/ that comes from uploaded Markdown preserves the current uploaded text, including frontmatter order, line breaks, and the final newline. Generated navigation, index, graph, and log resources return their generated content.

FieldRequiredTypeDescription
fileYesobjectReadable file metadata returned by the request.
contentYesstringComplete readable file content.

Success Response Example ​

json
{
  "file": {
    "activeContentRevision": 1,
    "fileId": "source-file-11111111-1111-4111-8111-111111111111",
    "knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
    "sourceFileId": "source-file-11111111-1111-4111-8111-111111111111",
    "path": "pages/guide.md",
    "fileKind": "page",
    "contentType": "text/markdown; charset=utf-8",
    "sizeBytes": 2048,
    "okfType": "Guide",
    "title": "Verified guide",
    "description": null,
    "tags": [
      "guide",
      "policy"
    ],
    "frontmatter": {
      "okf_version": "0.2",
      "type": "Guide",
      "title": "Verified guide",
      "tags": [
        "guide",
        "policy"
      ],
      "sources": [
        {
          "id": "source-a",
          "resource": "references/source-a.md"
        }
      ],
      "generated": {
        "by": "publisher:example",
        "at": "2026-06-17T00:00:00Z"
      },
      "verified": [
        {
          "by": "human:reviewer",
          "at": "2026-06-17T01:00:00Z"
        }
      ],
      "status": "stable",
      "stale_after": "2026-12-31"
    },
    "okfSignals": {
      "effectiveStatus": "stable",
      "trustTier": "human-reviewed",
      "isStale": false,
      "staleAfter": "2026-12-31",
      "generatedAt": "2026-06-17T00:00:00.000Z",
      "generatedAtSource": "generated",
      "latestVerifiedAt": "2026-06-17T01:00:00.000Z",
      "sourceCount": 1
    },
    "deletable": true,
    "contentAvailable": true,
    "readActions": {
      "fileDetailById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111",
      "fileContentById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111/content",
      "fileContentByPath": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/content?path=pages%2Fguide.md",
      "relatedFilesById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111/related",
      "graphExpansionByFileId": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/graph/expand?fileId=source-file-11111111-1111-4111-8111-111111111111",
      "sourceFileStatusById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files/source-file-11111111-1111-4111-8111-111111111111"
    }
  },
  "content": "---\ntype: page\ntitle: Guide\n---\n# Guide\n\nContent."
}

Error Codes ​

The table below lists every error response documented for this operation.

HTTP StatusError CodeExplanation
401UNAUTHORIZEDThe Bearer API key is missing, malformed, unknown, revoked, or deleted.
404NOT_FOUNDThe requested resource was not found.
413PAYLOAD_TOO_LARGEThe request body or requested file exceeds the size limit for this operation.
422VALIDATION_ERRORThe request failed validation.
429RATE_LIMITEDThe request exceeded the configured rate limits.
500INTERNAL_ERRORThe API encountered an internal error.
503DATABASE_REPOSITORY_UNAVAILABLEThe data required by this operation is temporarily unavailable.

Next Steps ​