上傳檔案
POST/v1/files
上傳檔案
Parameters
Returns
上傳檔案
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
$client = new Client(apiKey: 'my-anthropic-api-key');
$fileMetadata = $client->files->upload(
file: FileParam::fromString('Example data', filename: uniqid('file-upload-', true)),
expiresInSeconds: 3600,
workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);
var_dump($fileMetadata);Response 200
{
"id": "file_011CNha8iCJcU1wXNR6q4V8w",
"created_at": "2025-04-15T18:37:24.100435Z",
"filename": "document.pdf",
"mime_type": "application/pdf",
"size_bytes": 102400,
"type": "file",
"downloadable": false,
"expires_at": "2025-05-15T18:37:24.100435Z"
}Returns Examples
Response 200
{
"id": "file_011CNha8iCJcU1wXNR6q4V8w",
"created_at": "2025-04-15T18:37:24.100435Z",
"filename": "document.pdf",
"mime_type": "application/pdf",
"size_bytes": 102400,
"type": "file",
"downloadable": false,
"expires_at": "2025-05-15T18:37:24.100435Z"
}