Was this page helpful?
The Files API lets you upload and manage files to use with the Claude API without re-uploading content with each request. This is particularly useful when using the code execution tool to provide inputs (e.g. datasets and documents) and then download outputs (e.g. charts). You can also use the Files API to prevent having to continually re-upload frequently used documents and images across multiple API calls. You can explore the API reference directly, in addition to this guide.
The Files API is in beta. Reach out through the feedback form to share your experience with the Files API.
This feature is in beta and is not eligible for Zero Data Retention (ZDR). Beta features are excluded from ZDR.
Referencing a file_id in a Messages request is supported in all models that support the given file type. For example, images are supported in all Claude 3+ models, PDFs in all Claude 3.5+ models, and various other file types for the code execution tool in Claude Haiku 4.5 plus all Claude 3.7+ models.
The Files API is currently not supported on Amazon Bedrock or Google Vertex AI.
The Files API provides a simple create-once, use-many-times approach for working with files:
file_idfile_id instead of re-uploading contentTo use the Files API, you'll need to include the beta feature header: anthropic-beta: files-api-2025-04-14.
Upload a file to be referenced in future API calls:
The response from uploading a file will include:
{
"id": "file_011CNha8iCJcU1wXNR6q4V8w",
"type": "file",
"filename": "document.pdf",
"mime_type": "application/pdf",
"size_bytes": 1024000,
"created_at": "2025-01-01T00:00:00Z",
"downloadable": false
}Once uploaded, reference the file using its file_id:
The Files API supports different file types that correspond to different content block types:
| File Type | MIME Type | Content Block Type | Use Case |
|---|---|---|---|
application/pdf | document | Text analysis, document processing | |
| Plain text | text/plain | document | Text analysis, processing |
| Images | image/jpeg, image/png, image/gif, image/webp | image | Image analysis, visual tasks |
| Datasets, others |
For file types that are not supported as document blocks (.csv, .txt, .md, .docx, .xlsx), convert the files to plain text, and include the content directly in your message:
For .docx files containing images, convert them to PDF format first, then use PDF support to take advantage of the built-in image parsing. This allows using citations from the PDF document.
For PDFs and text files, use the document content block:
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w"
},
"title": "Document Title", // Optional
"context": "Context about the document", // Optional
"citations": { "enabled": true } // Optional, enables citations
}For images, use the image content block:
{
"type": "image",
"source": {
"type": "file",
"file_id": "file_011CPMxVD3fHLUhvTqtsQA5w"
}
}Retrieve a list of your uploaded files:
Retrieve information about a specific file:
Remove a file from your workspace:
Download files that have been created by skills or the code execution tool:
You can only download files that were created by skills or the code execution tool. Files that you uploaded cannot be downloaded.
Messages API calls and associated tool usesCommon errors when using the Files API include:
file_id doesn't exist or you don't have access to it/v1/messages request)<, >, :, ", |, ?, *, \, /, or unicode characters 0-31){
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "File not found: file_011CNha8iCJcU1wXNR6q4V8w"
}
}File API operations are free:
File content used in Messages requests are priced as input tokens. You can only download files created by skills or the code execution tool.
During the beta period:
curl -X POST https://api.anthropic.com/v1/files \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: files-api-2025-04-14" \
-F "file=@/path/to/document.pdf"curl -X POST https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: files-api-2025-04-14" \
-H "content-type: application/json" \
-d @- <<EOF
{
"model": "claude-opus-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Please summarize this document for me."
},
{
"type": "document",
"source": {
"type": "file",
"file_id": "$FILE_ID"
}
}
]
}
]
}
EOF| Varies |
container_upload |
| Analyze data, create visualizations |
# Example: Reading a text file and sending it as plain text
# Note: For files with special characters, consider base64 encoding
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d @- <<EOF
{
"model": "claude-opus-4-6",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Here's the document content:\n\n${TEXT_CONTENT}\n\nPlease summarize this document."
}
]
}
]
}
EOFcurl https://api.anthropic.com/v1/files \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: files-api-2025-04-14"curl "https://api.anthropic.com/v1/files/$FILE_ID" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: files-api-2025-04-14"curl -X DELETE "https://api.anthropic.com/v1/files/$FILE_ID" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: files-api-2025-04-14"curl -X GET "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: files-api-2025-04-14" \
--output downloaded_file.txt