Source Intelligence
Sweep 28 Aug 2026 ยท 16:06Z Build v2.1.251 479 read Stable v2.1.236 Latest v2.1.251 Next v2.1.251 Feeds RSS JSON llms.txt

DisclaimerUnofficial, and not affiliated with Anthropic. Nearly all of this is read straight out of what ships: npm bundles, captured prompts, published docs. Anthropic's own notes go in verbatim, marked as theirs. The rest is my reading, and every entry carries the strings behind it. If one looks wrong, vote it down and say why.

Page history

files

managed-agents/files

4 recorded changes 699 lines First seen Last changed Upstream

History

managed-agents/files Changed · +15 / -14 lines

from line 24
   ```
 
   ```bash CLI
-  FILE_ID=$(ant files upload \
-    --file data.csv \
-    --transform id --raw-output)
+  FILE_ID=$(ant files upload --file data.csv --transform id --raw-output)
   ```
 
   ```python Python
from line 69
   ```
 
   ```php PHP
-  // The PHP SDK exposes the Files API under the beta namespace; field names can differ from other SDKs.
-  $file = $client->beta->files->upload(
-      FileParam::fromResource(fopen($csvPath, 'r'), filename: 'data.csv', contentType: 'text/csv'),
+  $file = $client->files->upload(
+      file: FileParam::fromResource(fopen($csvPath, 'r'), filename: 'data.csv', contentType: 'text/csv'),
   );
   echo "File ID: {$file->id}\n";
   ```
from line 314
 
   ```php PHP
   $resources = [
-      ['type' => 'file', 'file_id' => 'file_abc123', 'mount_path' => '/data.csv'],
-      ['type' => 'file', 'file_id' => 'file_def456', 'mount_path' => '/config.json'],
-      ['type' => 'file', 'file_id' => 'file_ghi789', 'mount_path' => '/src/main.py'],
+      ['type' => 'file', 'fileID' => 'file_abc123', 'mountPath' => '/data.csv'],
+      ['type' => 'file', 'fileID' => 'file_def456', 'mountPath' => '/config.json'],
+      ['type' => 'file', 'fileID' => 'file_ghi789', 'mountPath' => '/src/main.py'],
   ];
   ```
 
from line 535
 
 ## Listing and downloading session files
 
-Use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) to list files scoped to a session and download them. Filtering by `scope_id` requires the `managed-agents-2026-04-01` beta header, so the list examples use the `beta` files namespace and pass that header explicitly.
+Use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) to list files scoped to a session and download them. Files the agent writes to `/mnt/session/outputs/` appear in the list shortly after the agent finishes writing them, sometimes a few seconds after the session goes idle. If an output file you expect is missing, list again after a short delay; once it appears in the list, its upload has finished.
 
+Filtering by `scope_id` requires the `managed-agents-2026-04-01` beta header, so the list examples use the `beta` files namespace and pass that header explicitly.
+
 <CodeGroup>
   ```bash cURL
   # List files associated with a session
from line 556
 
   ```bash CLI
   # List files associated with a session
-  ant beta:files list --scope-id sesn_abc123 \
-    --beta managed-agents-2026-04-01
+  ant beta:files list --scope-id sesn_abc123 --beta managed-agents-2026-04-01
 
   # Download a file
   ant files download --file-id "$FILE_ID" --output output.txt
from line 649
   ```
 
   ```php PHP
-  // The PHP SDK exposes the Files API under the beta namespace; field names can differ from other SDKs.
   // List files associated with a session
   $files = $client->beta->files->list(
       scopeID: 'sesn_abc123',
       betas: ['managed-agents-2026-04-01'],
   );
+  foreach ($files->getItems() as $file) {
+      echo "{$file->id} {$file->filename}\n";
+  }
 
   // Download a file
-  $content = $client->beta->files->download($files->data[0]->id);
+  $content = $client->files->download($files->getItems()[0]->id);
   file_put_contents('output.txt', $content);
   ```
 
from line 696
 * If you omit `mount_path`, the file is placed at `/mnt/session/uploads/<file_id>`
 * Parent directories are created automatically
 * Paths should be absolute (starting with `/`)
+* Files the agent writes to `/mnt/session/outputs/` become available through the Files API, scoped to the session; see [Listing and downloading session files](https://platform.claude.com/docs/en/managed-agents/files#listing-and-downloading-session-files)
 

managed-agents/files Changed · +3 / -1 lines

from line 71
   ```
 
   ```php PHP
+  // The PHP SDK exposes the Files API under the beta namespace; field names can differ from other SDKs.
   $file = $client->beta->files->upload(
       FileParam::fromResource(fopen($csvPath, 'r'), filename: 'data.csv', contentType: 'text/csv'),
   );
from line 538
 
 ## Listing and downloading session files
 
-Use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) to list files scoped to a session and download them. Filtering by `scope_id` requires the `managed-agents-2026-04-01` beta header, so the list examples use the `beta` files namespace and pass that header explicitly. Downloading a file doesn't require a beta header.
+Use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) to list files scoped to a session and download them. Filtering by `scope_id` requires the `managed-agents-2026-04-01` beta header, so the list examples use the `beta` files namespace and pass that header explicitly.
 
 <CodeGroup>
   ```bash cURL
from line 651
   ```
 
   ```php PHP
+  // The PHP SDK exposes the Files API under the beta namespace; field names can differ from other SDKs.
   // List files associated with a session
   $files = $client->beta->files->list(
       scopeID: 'sesn_abc123',

managed-agents/files Changed · +21 / -19 lines

from line 24
   ```
 
   ```bash CLI
-  FILE_ID=$(ant beta:files upload \
+  FILE_ID=$(ant files upload \
     --file data.csv \
     --transform id --raw-output)
   ```
 
   ```python Python
-  file = client.beta.files.upload(file=Path("data.csv"))
+  file = client.files.upload(file=Path("data.csv"))
   print(f"File ID: {file.id}")
   ```
 
   ```typescript TypeScript
-  const file = await client.beta.files.upload({
+  const file = await client.files.upload({
     file: await toFile(readFile("data.csv"), "data.csv", { type: "text/csv" }),
   });
   console.log(`File ID: ${file.id}`);
from line 43
 
   ```csharp C#
   await using var stream = File.OpenRead(csvPath);
-  var file = await client.Beta.Files.Upload(new() { File = stream });
+  var file = await client.Files.Upload(new() { File = stream });
   Console.WriteLine($"File ID: {file.ID}");
   ```
 
from line 54
   }
   defer csvFile.Close()
 
-  file, err := client.Beta.Files.Upload(ctx, anthropic.BetaFileUploadParams{
+  file, err := client.Files.Upload(ctx, anthropic.FileUploadParams{
   	File: csvFile,
   })
   if err != nil {
from line 64
   ```
 
   ```java Java
-  var file = client.beta().files().upload(
+  var file = client.files().upload(
       FileUploadParams.builder().file(dataCsv).build()
   );
   IO.println("File ID: " + file.id());
from line 78
   ```
 
   ```ruby Ruby
-  file = client.beta.files.upload(file: Pathname(csv_path))
+  file = client.files.upload(file: Pathname(csv_path))
   puts "File ID: #{file.id}"
   ```
 </CodeGroup>
from line 537
 
 ## Listing and downloading session files
 
-Use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) to list files scoped to a session and download them.
+Use the [Files API](https://platform.claude.com/docs/en/build-with-claude/files) to list files scoped to a session and download them. Filtering by `scope_id` requires the `managed-agents-2026-04-01` beta header, so the list examples use the `beta` files namespace and pass that header explicitly. Downloading a file doesn't require a beta header.
 
 <CodeGroup>
   ```bash cURL
from line 551
   curl -fsSL "https://api.anthropic.com/v1/files/$FILE_ID/content" \
     -H "x-api-key: $ANTHROPIC_API_KEY" \
     -H "anthropic-version: 2023-06-01" \
-    -H "anthropic-beta: managed-agents-2026-04-01" \
     -o output.txt
   ```
 
from line 560
     --beta managed-agents-2026-04-01
 
   # Download a file
-  ant beta:files download --file-id "$FILE_ID" --output output.txt
+  ant files download --file-id "$FILE_ID" --output output.txt
   ```
 
   ```python Python
from line 573
       print(file.id, file.filename)
 
   # Download a file
-  content = client.beta.files.download(files.data[0].id)
+  content = client.files.download(files.data[0].id)
   content.write_to_file("output.txt")
   ```
 
   ```typescript TypeScript
+  import { writeFile } from "node:fs/promises";
+
   // List files associated with a session
   const files = await client.beta.files.list({
     scope_id: "sesn_abc123",
from line 590
   }
 
   // Download a file
-  const content = await client.beta.files.download(files.data[0].id);
-  await content.writeToFile("output.txt");
+  const content = await client.files.download(files.data[0].id);
+  await writeFile("output.txt", new Uint8Array(await content.arrayBuffer()));
   ```
 
   ```csharp C#
   // List files associated with a session
-  var files = await client.Beta.Files.List(new FileListParams
+  var files = await client.Beta.Files.List(new()
   {
       ScopeID = "sesn_abc123",
       Betas = ["managed-agents-2026-04-01"],
from line 603
   });
 
   // Download a file
-  byte[] content = await client.Beta.Files.Download(files.Data[0].ID);
-  await File.WriteAllBytesAsync("output.txt", content);
+  using var content = await client.Files.Download(files.Items[0].ID);
+  await using var output = File.Create("output.txt");
+  await (await content.ReadAsStream()).CopyToAsync(output);
   ```
 
   ```go Go
from line 619
   }
 
   // Download a file
-  resp, err := client.Beta.Files.Download(ctx, files.Data[0].ID, anthropic.BetaFileDownloadParams{})
+  resp, err := client.Files.Download(ctx, files.Data[0].ID)
   if err != nil {
   	panic(err)
   }
from line 642
       .build());
 
   // Download a file
-  try (HttpResponse response = client.beta().files().download(files.data().get(0).id())) {
+  try (HttpResponse response = client.files().download(files.data().get(0).id())) {
       try (InputStream body = response.body()) {
           Files.copy(body, Path.of("output.txt"), StandardCopyOption.REPLACE_EXISTING);
       }
from line 669
   )
 
   # Download a file
-  content = client.beta.files.download(files.data[0].id)
+  content = client.files.download(files.data[0].id)
   File.binwrite("output.txt", content.read)
   ```
 </CodeGroup>

managed-agents/files First recorded · 694 lines, first recorded

## Uploading files ## Mounting files in a session ## Multiple files ## Managing files on a running session ## Listing and downloading session files ## Supported file types ## File paths

The first capture of this source. The page was already there, and this is what it said.

---
title: Adding files
url: https://platform.claude.com/docs/en/managed-agents/files
description: Upload files and mount them in your sandbox for reading and processing.
---

You can provide files to your agent by uploading them through the Files API and mounting them in the session's sandbox.

<Note>
  Managed Agents API requests require the `managed-agents-2026-04-01` beta header, except memory store endpoints, which use `agent-memory-2026-07-22` instead. The SDK sets the correct beta header automatically. See [Beta headers](https://platform.claude.com/docs/en/api/beta-headers#endpoint-specific-headers).
</Note>

## Uploading files

First, upload a file using the [Files API](https://platform.claude.com/docs/en/build-with-claude/files):

<CodeGroup>
  ```bash cURL
  file=$(curl --fail-with-body -sS "${auth[@]}" \
    "${base_url}/files" \
    -F [email protected])
  file_id=$(jq -er '.id' <<<"${file}")
  printf 'File ID: %s\n' "${file_id}"
  ```

  ```bash CLI
  FILE_ID=$(ant beta:files upload \
    --file data.csv \
    --transform id --raw-output)
  ```

  ```python Python
  file = client.beta.files.upload(file=Path("data.csv"))
  print(f"File ID: {file.id}")
  ```

  ```typescript TypeScript
  const file = await client.beta.files.upload({
    file: await toFile(readFile("data.csv"), "data.csv", { type: "text/csv" }),
  });
  console.log(`File ID: ${file.id}`);
  ```

  ```csharp C#
  await using var stream = File.OpenRead(csvPath);
  var file = await client.Beta.Files.Upload(new() { File = stream });
  Console.WriteLine($"File ID: {file.ID}");
  ```

  ```go Go
  csvFile, err := os.Open("data.csv")
  if err != nil {
  	panic(err)
  }
  defer csvFile.Close()

  file, err := client.Beta.Files.Upload(ctx, anthropic.BetaFileUploadParams{
  	File: csvFile,
  })
  if err != nil {
  	panic(err)
  }
  fmt.Printf("File ID: %s\n", file.ID)
  ```

  ```java Java
  var file = client.beta().files().upload(
      FileUploadParams.builder().file(dataCsv).build()
  );
  IO.println("File ID: " + file.id());
  ```

  ```php PHP
  $file = $client->beta->files->upload(
      FileParam::fromResource(fopen($csvPath, 'r'), filename: 'data.csv', contentType: 'text/csv'),
  );
  echo "File ID: {$file->id}\n";
  ```

  ```ruby Ruby
  file = client.beta.files.upload(file: Pathname(csv_path))
  puts "File ID: #{file.id}"
  ```
</CodeGroup>

## Mounting files in a session

Mount uploaded files into the sandbox by adding them to the `resources` array when creating a session:

<Tip>
  The `mount_path` is optional, but make sure the uploaded file has a descriptive name so the agent can identify it.
</Tip>

<CodeGroup>
  ```bash cURL
  session=$(
    jq -n \
      --arg agent_id "${agent_id}" \
      --arg environment_id "${environment_id}" \
      --arg file_id "${file_id}" \
      '{
        agent: $agent_id,
        environment_id: $environment_id,
        resources: [
          {
            type: "file",
            file_id: $file_id,
            mount_path: "/data.csv"
          }
        ]
      }' | curl --fail-with-body -sS "${auth[@]}" "${base_url}/sessions" --json @-
  )
  session_id=$(jq -er '.id' <<<"${session}")
  ```

  ```bash CLI
  SESSION_ID=$(ant beta:sessions create \
    --agent "$AGENT_ID" \
    --environment-id "$ENVIRONMENT_ID" \
    --transform id --raw-output <<EOF
  resources:
    - type: file
      file_id: $FILE_ID
      mount_path: /data.csv
  EOF
  )
  ```

  ```python Python
  session = client.beta.sessions.create(
      agent=agent.id,
      environment_id=environment.id,
      resources=[
          {
              "type": "file",
              "file_id": file.id,
              "mount_path": "/data.csv",
          },
      ],
  )
  ```

  ```typescript TypeScript
  const session = await client.beta.sessions.create({
    agent: agent.id,
    environment_id: environment.id,
    resources: [
      {
        type: "file",
        file_id: file.id,
        mount_path: "/data.csv",
      },
    ],
  });
  ```

  ```csharp C#
  var session = await client.Beta.Sessions.Create(new()
  {
      Agent = agent.ID,
      EnvironmentID = environment.ID,
      Resources =
      [
          new BetaManagedAgentsFileResourceParams
          {
              Type = "file",
              FileID = file.ID,
              MountPath = "/data.csv",
          },
      ],
  });
  ```

  ```go Go
  session, err := client.Beta.Sessions.New(ctx, anthropic.BetaSessionNewParams{
  	Agent: anthropic.BetaSessionNewParamsAgentUnion{
  		OfString: anthropic.String(agent.ID),
  	},
  	EnvironmentID: environment.ID,
  	Resources: []anthropic.BetaSessionNewParamsResourceUnion{{
  		OfFile: &anthropic.BetaManagedAgentsFileResourceParams{
  			Type:      anthropic.BetaManagedAgentsFileResourceParamsTypeFile,
  			FileID:    file.ID,
  			MountPath: anthropic.String("/data.csv"),
  		},
  	}},
  })
  if err != nil {
  	panic(err)
  }
  ```

  ```java Java
  var session = client.beta().sessions().create(
      SessionCreateParams.builder()
          .agent(agent.id())
          .environmentId(environment.id())
          .addResource(
              BetaManagedAgentsFileResourceParams.builder()
                  .type(BetaManagedAgentsFileResourceParams.Type.FILE)
                  .fileId(file.id())
                  .mountPath("/data.csv")
                  .build()
          )
          .build()
  );
  ```

  ```php PHP
  $session = $client->beta->sessions->create(
      agent: $agent->id,
      environmentID: $environment->id,
      resources: [
          BetaManagedAgentsFileResourceParams::with(
              type: 'file',
              fileID: $file->id,
              mountPath: '/data.csv',
          ),
      ],
  );
  ```

  ```ruby Ruby
  session = client.beta.sessions.create(
    agent: agent.id,
    environment_id: environment.id,
    resources: [
      {
        type: "file",
        file_id: file.id,
        mount_path: "/data.csv"
      }
    ]
  )
  ```
</CodeGroup>

With the preceding `mount_path`, the agent reads the file at `/mnt/session/uploads/data.csv` (see [File paths](https://platform.claude.com/docs/en/managed-agents/files#file-paths)).

A new `file_id` is created that references the instance of the file in the session. These copies do not count against your [storage limits](https://platform.claude.com/docs/en/build-with-claude/files).

## Multiple files

Mount multiple files by adding entries to the `resources` array:

<CodeGroup>
  ```json cURL
  "resources": [
    { "type": "file", "file_id": "file_abc123", "mount_path": "/data.csv" },
    { "type": "file", "file_id": "file_def456", "mount_path": "/config.json" },
    { "type": "file", "file_id": "file_ghi789", "mount_path": "/src/main.py" }
  ]
  ```

  ```yaml CLI
  resources:
    - type: file
      file_id: file_abc123
      mount_path: /data.csv
    - type: file
      file_id: file_def456
      mount_path: /config.json
    - type: file
      file_id: file_ghi789
      mount_path: /src/main.py
  ```

  ```python Python
  resources = [
      {"type": "file", "file_id": "file_abc123", "mount_path": "/data.csv"},
      {"type": "file", "file_id": "file_def456", "mount_path": "/config.json"},
      {"type": "file", "file_id": "file_ghi789", "mount_path": "/src/main.py"},
  ]
  ```

  ```typescript TypeScript
  resources: [
    { type: "file", file_id: "file_abc123", mount_path: "/data.csv" },
    { type: "file", file_id: "file_def456", mount_path: "/config.json" },
    { type: "file", file_id: "file_ghi789", mount_path: "/src/main.py" }
  ]
  ```

  ```csharp C#
  using Anthropic.Models.Beta.Sessions;

  var resources = new[]
  {
      new BetaManagedAgentsFileResourceParams { Type = BetaManagedAgentsFileResourceParamsType.File, FileID = "file_abc123", MountPath = "/data.csv" },
      new BetaManagedAgentsFileResourceParams { Type = BetaManagedAgentsFileResourceParamsType.File, FileID = "file_def456", MountPath = "/config.json" },
      new BetaManagedAgentsFileResourceParams { Type = BetaManagedAgentsFileResourceParamsType.File, FileID = "file_ghi789", MountPath = "/src/main.py" },
  };
  ```

  ```go Go
  resources := []anthropic.BetaSessionNewParamsResourceUnion{
  	{OfFile: &anthropic.BetaManagedAgentsFileResourceParams{Type: "file", FileID: "file_abc123", MountPath: anthropic.String("/data.csv")}},
  	{OfFile: &anthropic.BetaManagedAgentsFileResourceParams{Type: "file", FileID: "file_def456", MountPath: anthropic.String("/config.json")}},
  	{OfFile: &anthropic.BetaManagedAgentsFileResourceParams{Type: "file", FileID: "file_ghi789", MountPath: anthropic.String("/src/main.py")}},
  }

Cut at 300 lines.