Follow Discord
Sweep 20 Nov 2026 · 19:55Z Build v2.1.330 547 read Stable v2.1.323 Latest v2.1.330 Next v2.1.330 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

files changedbuild-with-claude/files

Nearest release: v2.1.328, published 7 hours after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+93added
Lines−34removed
From line 88 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits35to this page, all time

The whole hunk

from line 88, old and new numbered
/
lines
from line 88
8888 
8989 ```typescript TypeScript
9090 const uploaded = await client.files.upload({
91 file: await toFile(fs.createReadStream("/path/to/document.pdf"), undefined, {
91 file: await toFile(createReadStream("/path/to/document.pdf"), undefined, {
9292 type: "application/pdf"
9393 })
9494 });
from line 142
142142 );
143143 
144144 String fileId = file.id();
145 System.out.println(fileId);
145 IO.println(fileId);
146146 ```
147147 
148148 ```php PHP
149 $document = fopen('/path/to/document.pdf', 'rb')
150 ?: throw new \RuntimeException('Could not open /path/to/document.pdf.');
151 
149152 $file = $client->files->upload(
150 file: FileParam::fromResource(fopen('/path/to/document.pdf', 'rb'), contentType: 'application/pdf'),
153 file: FileParam::fromResource($document, contentType: 'application/pdf'),
151154 );
152155 
153156 $fileId = $file->id;
from line 352
349352 .build();
350353 
351354 Message message = client.messages().create(params);
352 System.out.println(message);
355 IO.println(message);
353356 ```
354357 
355358 ```php PHP
from line 373
370373 ],
371374 ],
372375 ],
373 model: 'claude-opus-5-5',
376 model: Model::CLAUDE_OPUS_5_5,
374377 );
375378 
376379 echo $response;
from line 465
462465 
463466<CodeGroup>
464467 ```bash cURL
465 # Read the text file
466 # Note: For files with special characters, consider base64 encoding
467 TEXT_CONTENT=$(cat document.txt)
468 # Encode the file's text as a JSON string so that quotes and line breaks are safe
469 TEXT_JSON=$(jq -Rs . document.txt)
468470 
469471 curl https://api.anthropic.com/v1/messages \
470472 -H "content-type: application/json" \
from line 480
478480 {
479481 "role": "user",
480482 "content": [
481 {
482 "type": "text",
483 "text": "Here's the document content:\n\n${TEXT_CONTENT}\n\nPlease summarize this document."
484 }
483 {"type": "text", "text": "Here's the document content:"},
484 {"type": "text", "text": ${TEXT_JSON}},
485 {"type": "text", "text": "Please summarize this document."}
485486 ]
486487 }
487488 ]
from line 521
520521 "content": [
521522 {
522523 "type": "text",
523 "text": f"Here's the document content:\n\n{text_content}\n\nPlease summarize this document.",
524 "text": f"""Here's the document content:
525 
526 {text_content}
527 
528 Please summarize this document.""",
524529 }
525530 ],
526531 }
from line 554
549554 content: [
550555 {
551556 type: "text",
552 text: `Here's the document content:\n\n${textContent}\n\nPlease summarize this document.`
557 text: `Here's the document content:
558 
559 ${textContent}
560 
561 Please summarize this document.`
553562 }
554563 ]
555564 }
from line 581
572581 MaxTokens = 1024,
573582 Messages = [new UserMessageParam
574583 {
575 Content = $"Here's the document content:\n\n{textContent}\n\nPlease summarize this document."
584 Content = $"""
585 Here's the document content:
586 
587 {textContent}
588 
589 Please summarize this document.
590 """
576591 }]
577592 };
578593 
from line 639
624639 MessageCreateParams params = MessageCreateParams.builder()
625640 .model(Model.CLAUDE_OPUS_5_5)
626641 .maxTokens(1024L)
627 .addUserMessage("Here's the document content:\n\n" + textContent + "\n\nPlease summarize this document.")
642 .addUserMessage(
643 """
644 Here's the document content:
645 
646 %s
647 
648 Please summarize this document.""".formatted(textContent)
649 )
628650 .build();
629651 
630652 Message response = client.messages().create(params);
631653 response.content().stream()
632654 .flatMap(block -> block.text().stream())
633 .forEach(textBlock -> System.out.println(textBlock.text()));
655 .forEach(textBlock -> IO.println(textBlock.text()));
634656 ```
635657 
636658 ```php PHP
from line 659
637659 $client = new Client();
638660 
639661 // Read the text file
640 $textContent = file_get_contents('document.txt');
662 $textContent = file_get_contents('document.txt')
663 ?: throw new \RuntimeException('Could not read document.txt.');
641664 
642665 $message = $client->messages->create(
643666 maxTokens: 1024,
from line 670
647670 'content' => [
648671 [
649672 'type' => 'text',
650 'text' => "Here's the document content:\n\n{$textContent}\n\nPlease summarize this document."
673 'text' => <<<TEXT
674 Here's the document content:
675 
676 {$textContent}
677 
678 Please summarize this document.
679 TEXT
651680 ]
652681 ]
653682 ]
654683 ],
655 model: 'claude-opus-5-5',
684 model: Model::CLAUDE_OPUS_5_5,
656685 );
657686 
658687 foreach ($message->content as $block) {
659 if ($block->type === 'text') {
688 if ($block instanceof \Anthropic\Messages\TextBlock) {
660689 echo $block->text, PHP_EOL;
661690 }
662691 }
from line 706
677706 content: [
678707 {
679708 type: "text",
680 text: "Here's the document content:\n\n#{text_content}\n\nPlease summarize this document."
709 text: <<~TEXT.chomp
710 Here's the document content:
711 
712 #{text_content}
713 
714 Please summarize this document.
715 TEXT
681716 }
682717 ]
683718 }
from line 720
685720 )
686721 
687722 message.content.each do |block|
688 puts block.text if block.type == :text
723 puts block.text if block.is_a?(Anthropic::Models::TextBlock)
689724 end
690725 ```
691726</CodeGroup>
from line 778
743778 
744779 ```java Java
745780 import com.anthropic.models.files.FileListPage;
746 // ...
781 
747782 void main() {
748783 AnthropicClient client = AnthropicOkHttpClient.fromEnv();
749784 
750785 FileListPage files = client.files().list();
751 System.out.println(files);
786 IO.println(files);
752787 }
753788 ```
754789 
from line 802
767802 ```
768803</CodeGroup>
769804 
770To check a known set of files in one request instead of paging, pass up to 100 file IDs as `ids[]` query parameters. An `ids[]` request always returns a single page (`next_page` is `null`), and any ID that does not resolve to a file in your workspace is silently omitted from `data`; compare the returned IDs against the requested IDs to detect misses. `ids[]` cannot be combined with `page` or `limit`.
805To check a known set of files in one request instead of paging, pass up to 100 file IDs as `ids[]` query parameters. An `ids[]` request differs from a paged list in three ways:
771806 
807* You can’t combine `ids[]` with `page` or `limit`.
808* The response is always a single page (`next_page` is `null`).
809* If an ID doesn’t resolve to a file in your workspace, the API leaves that ID out of `data` without returning an error. To find the IDs that the API left out, compare the returned IDs against the requested IDs.
810 
772811#### Get file metadata
773812 
774813Retrieve information about a specific file:
from line 850
811850 ```java Java
812851 FileMetadata metadata = client.files().retrieveMetadata(fileId);
813852 
814 System.out.println(metadata);
853 IO.println(metadata);
815854 ```
816855 
817856 ```php PHP
from line 913
874913 
875914### Downloading a file
876915 
877Download files that were created by [skills](https://platform.claude.com/docs/en/build-with-claude/skills-guide) or the [code execution tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool). Files you upload cannot be downloaded. The `file_id` of a generated file appears in the [`bash_code_execution_tool_result` content block](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool#retrieve-generated-files) of the Messages response that created it:
916Download files that [skills](https://platform.claude.com/docs/en/build-with-claude/skills-guide) or the [code execution tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool) created. Files you upload cannot be downloaded. The `file_id` of a generated file appears in the [`bash_code_execution_tool_result` content block](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool#retrieve-generated-files) of the Messages response that created the file. Use that `file_id` in the download request:
878917 
879918<CodeGroup>
880919 ```bash cURL
from line 934
895934 ```
896935 
897936 ```typescript TypeScript
898 const content = await client.files.download(uploaded.id);
937 const content = await client.files.download(fileId);
899938 
900 const bytes = Buffer.from(await content.arrayBuffer());
901 await fsp.writeFile("downloaded_file.txt", bytes);
939 await writeFile("downloaded_file.txt", content.body!);
902940 ```
903941 
904942 ```csharp C#
from line 983
945983 ```ruby Ruby
946984 file_content = client.files.download(file_id)
947985 
948 File.binwrite("downloaded_file.txt", file_content.read)
986 IO.copy_stream(file_content, "downloaded_file.txt")
949987 ```
950988</CodeGroup>
951989 
from line 1049
10111049 
10121050### SDK beta namespace
10131051 
1014Starting with Python SDK 1.2.0, TypeScript SDK 0.122.0, Go SDK 1.68.0, Java SDK 2.59.0, PHP SDK 0.45.0, Ruby SDK 1.67.0, and C# SDK 12.44.0, `client.beta.files` (csharp, go: `client.Beta.Files`; java: `client.beta().files()`; php: `$client->beta->files`) no longer sends `files-api-2025-04-14` and returns the same shapes as `client.files` (csharp, go: `client.Files`; java: `client.files()`; php: `$client->files`), with `Beta`-prefixed type names (in PHP, classes in the `Anthropic\Beta` namespace). It takes beta names through `betas` (csharp, go: `Betas`; java: `.addBeta()`) for Files features that are in beta, such as `scope_id` filtering under a [Managed Agents](https://platform.claude.com/docs/en/managed-agents/files) beta header. Earlier SDK releases are typed to the beta shapes; if you depend on those types, stay on an earlier release until you migrate.
1052The SDK offers the Files API in two namespaces. This page uses the stable namespace, and Files features that are in beta use the beta namespace.
1053 
1054Starting with your SDK’s release in the following table, the beta namespace differs from the one in earlier releases in two ways:
1055 
1056* It no longer sends `files-api-2025-04-14`.
1057* It returns the same shapes as the stable namespace but under `Beta`-prefixed type names.
1058 
1059The table also gives each SDK’s namespace names and where the beta namespace takes `anthropic-beta` values:
1060 
1061| SDK | Stable namespace | Beta namespace | Beta namespace changed in | `anthropic-beta` values go in |
1062| ---------- | ---------------- | ---------------------------------------------------- | ------------------------- | ----------------------------- |
1063| Python | `client.files` | `client.beta.files` | 1.2.0 | `betas` |
1064| TypeScript | `client.files` | `client.beta.files` | 0.122.0 | `betas` |
1065| C# | `client.Files` | `client.Beta.Files` | 12.44.0 | `Betas` |
1066| Go | `client.Files` | `client.Beta.Files` | 1.68.0 | `Betas` |
1067| Java | `client.files()` | `client.beta().files()` | 2.59.0 | `.addBeta()` |
1068| PHP | `$client->files` | `$client->beta->files` (classes in `Anthropic\Beta`) | 0.45.0 | `betas` |
1069| Ruby | `client.files` | `client.beta.files` | 1.67.0 | `betas` |
1070 
1071For a Files feature that’s in beta, use the beta namespace and pass the feature’s `anthropic-beta` value as the table shows. For example, under a Managed Agents beta header, `scope_id` limits a file list to the files of one session. To use `scope_id`, see [Listing and downloading session files](https://platform.claude.com/docs/en/managed-agents/files#listing-and-downloading-session-files).
1072 
1073In releases before your SDK’s release in the table, the beta namespace’s types match the shapes that `files-api-2025-04-14` returns. If you depend on those types, stay on such a release until you migrate off them.
10151074 
10161075Requests that carry `anthropic-beta: managed-agents-2026-04-01` without `files-api-2025-04-14` receive the shapes on this page with one compatibility affordance on `GET /v1/files`: `before_id` and `after_id` are still accepted (not combinable with `page` or `ids[]`), and the list response includes `has_more`, `first_id`, and `last_id` alongside `next_page`. Later Managed Agents beta versions receive the plain shape.
10171076 
Feedback