SPB Git

Repository Public

upload.md 2.2 KB 106 lines markdown

1---2title: Upload File3url: https://platform.claude.com/docs/en/api/files/upload4---56# Upload File78**POST** `/v1/files`910Upload File1112## Headers1314- `"anthropic-workspace-id": optional string`1516## Body parameters (form-data)1718- `file: string`1920  The file to upload. Only the final path component of the part's `filename` is kept; an absent or empty `filename` is replaced with `unnamed` plus the extension for the file's stored `mime_type`, when known.2122  format: binary2324- `expires_in_seconds: optional number`2526  Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).2728  minimum: 3600, maximum: 77760002930## Returns3132- `FileMetadata object`3334  - `type: "file"`3536    Object type.3738    For files, this is always `"file"`.3940  - `id: string`4142    Unique object identifier.4344    The format and length of IDs may change over time.4546  - `created_at: string`4748    RFC 3339 datetime string representing when the file was created.4950    format: date-time5152  - `filename: string`5354    Original filename of the uploaded file.5556    maxLength: 500, minLength: 15758  - `mime_type: string`5960    MIME type of the file.6162    maxLength: 255, minLength: 16364  - `size_bytes: number`6566    Size of the file in bytes.6768    minimum: 06970  - `downloadable: optional boolean`7172    Whether the file can be downloaded.7374    default: false7576  - `expires_at: optional string or null`7778    RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with `expires_in_seconds`, this is the upload time plus that value.7980    format: date-time8182## Example8384```bash85curl https://api.anthropic.com/v1/files \86    -H 'Content-Type: multipart/form-data' \87    -H 'anthropic-version: 2023-06-01' \88    -H "X-Api-Key: $ANTHROPIC_API_KEY" \89    -F 'file=@/path/to/file'90```9192### Response (200)9394```json95{96  "id": "file_011CNha8iCJcU1wXNR6q4V8w",97  "created_at": "2025-04-15T18:37:24.100435Z",98  "filename": "document.pdf",99  "mime_type": "application/pdf",100  "size_bytes": 102400,101  "type": "file",102  "downloadable": false,103  "expires_at": "2025-05-15T18:37:24.100435Z"104}105```106
Files main
Menu

Theme