Anthropic Files API (Beta) - Upload and manage files for use across API calls.

Values

BETA_HEADER

BETA_HEADER: Str "files-api-2025-04-14"

Functions

delete

fn (file_id: Str): Map
fn (file_id: Str, opts: Map): Map

DELETE /v1/files/{file_id} - Delete a file.

Permanently deletes a file.

Example

::anthropic::files/delete("file_abc123")

download

fn (file_id: Str): Any
fn (file_id: Str, opts: Map): Any

GET /v1/files/{file_id}/content - Download file content.

Downloads the content of a file. Only available for downloadable files.

Example

content ::anthropic::files/download("file_abc123")

get

fn (file_id: Str): FileMetadata
fn (file_id: Str, opts: Map): FileMetadata

GET /v1/files/{file_id} - Get file metadata.

Returns metadata about a specific file.

Example

file ::anthropic::files/get("file_abc123")
file.filename   // => "document.pdf"
file.size_bytes // => 102400

list

fn (): FilesListResponse
fn (opts: Map): FilesListResponse
fn (limit: Int): FilesListResponse
fn (limit: Int, opts: Map): FilesListResponse

GET /v1/files - List uploaded files.

Returns a paginated list of files uploaded to your account. Optionally pass a limit to control page size. Each file includes metadata such as filename, mime_type, size_bytes, and created_at.

Example

// List all files
files ::anthropic::files/list()
assert(is-vec(files.data))
map(files.data, %.filename)

// List with a limit
files ::anthropic::files/list(5)
assert(lte(length(files.data), 5))

Types

FileMetadata

FileMetadata type {
    id: Str,
    type: Str,
    filename: Str,
    mime_type: Str,
    size_bytes: Int,
    created_at: Str,
    downloadable: Bool?
}

FilesListResponse

FilesListResponse type {
    data: Vec<FileMetadata>,
    has_more: Bool,
    first_id: Str?,
    last_id: Str?
}