Files

Read and write the files in an agentic project's shared-data Git repository.

The Files endpoints read and write the files tracked in an agentic project's shared-data Git repository (branch main), such as its knowledge/ and mdl/ files.

Agentic projects only. Reads are allowed for any path in the repository; writes are restricted to the knowledge/ and mdl/ prefixes and otherwise fail with PROJECT_FILES_PATH_NOT_WRITABLE. Requests against non-agentic projects fail with PROJECT_NOT_AGENTIC.

Learn more at Wren AI - Knowledge.

Endpoints Overview

  • GET /v2/projects/{projectId}/files: List files, optionally narrowed to a subtree with prefix (for example, knowledge).
  • GET /v2/projects/{projectId}/files/{path}: Read a file. {path} is the file's path within the repository, such as knowledge/sql-pairs/foo.md.
  • PUT /v2/projects/{projectId}/files/{path}: Create or update a file.
  • DELETE /v2/projects/{projectId}/files/{path}: Delete a file.
  • POST /v2/projects/{projectId}/files/batch: Apply several upsert and delete operations as a single atomic commit, for example to sync your knowledge/ and mdl/ files from your own source of truth.

Example Responses

Each listed entry is either a file or a dir; size and last_modified are present for files.

{
  "branch": "main",
  "prefix": "knowledge",
  "files": [
    {
      "name": "a.md",
      "path": "knowledge/a.md",
      "type": "file",
      "size": 12,
      "last_modified": "2026-05-12T00:00:00Z"
    },
    {
      "name": "sql-pairs",
      "path": "knowledge/sql-pairs",
      "type": "dir"
    }
  ]
}
{
  "path": "knowledge/sql-pairs/foo.md",
  "content": "# Revenue\nRevenue means net revenue.\n",
  "lastModified": "2026-05-12T00:00:00Z"
}
{
  "path": "knowledge/sql-pairs/foo.md",
  "commitSha": "3f9a1c7e2b8d4056a1e9c3f7b2d8e40a6c1f9b3e"
}
{
  "path": "knowledge/sql-pairs/foo.md",
  "commitSha": "7c2e9b4a1d8f6035c9a2e7b1f4d80c3a6e1b9d2f"
}

A batch returns the resulting commit and the number of operations applied.

{
  "commitSha": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
  "operationCount": 2
}