Files
List files stored in a workspace. Requires the files scope and a workspace_id.
GET
/v1/filesfiles scopeList files in a workspace. Returns metadata only.
| Parameter | Type | Description |
|---|---|---|
| workspace_id * | string | Workspace to list files from. |
| prefix | string | Filter by path prefix, e.g. results/. |
| limit | integer | Max results (default 100). |
files = client.files.list(workspace_id="ws_abc123")
for f in files:
print(f"{f['name']} — {f['size'] / 1024:.1f} KB key={f['key']}")const files = await client.files.list({ workspaceId: 'ws_abc123' });
files.forEach(f => console.log(`${f.name} — ${(f.size/1024).toFixed(1)} KB key=${f.key}`));curl "https://api.smarts.bio/v1/files?workspace_id=ws_abc123" \ -H "Authorization: Bearer sk_live_..."
# List files in a workspace smarts file ls -w ws_abc123
POST
/v1/files/uploadfiles scopeUpload a file via multipart/form-data. Max 500 MB. For larger files use the presigned URL flow.
| Form field | Type | Description |
|---|---|---|
| file * | binary | File bytes. |
| workspace_id * | string | Destination workspace. |
| path | string | Optional folder path, e.g. raw/. |
| description | string | Optional description. |
result = client.files.upload(
"sample.vcf",
workspace_id="ws_abc123",
path="raw/",
)
file_key = result["key"] # pass this to query or downloadconst result = await client.files.upload('./sample.vcf', {
workspaceId: 'ws_abc123',
path: 'raw/',
});
const fileKey = result.key; // pass to query or downloadcurl -X POST https://api.smarts.bio/v1/files/upload \
-H "Authorization: Bearer sk_live_..." \
-F "file=@sample.vcf" \
-F "workspace_id=ws_abc123" \
-F "path=raw/"
# → { "status": "success", "data": { "key": "...", "name": "sample.vcf", "size": 2097152, "fileId": "f_xyz" } }# Upload a file to a workspace folder smarts file upload sample.vcf --to raw/ -w ws_abc123
GET
/v1/files/downloadfiles scopeReturns a presigned S3 download URL valid for ~1 hour. Fetch that URL directly to get the file bytes.
| Parameter | Type | Description |
|---|---|---|
| workspace_id * | string | Workspace the file belongs to. |
| key * | string | S3 key of the file. |
# Download directly to disk (one-liner)
local_path = client.files.download(
result["key"], workspace_id="ws_abc123", dest="./output/"
)
print(f"Saved to {local_path}")// Download directly to disk (one-liner)
const localPath = await client.files.download(result.key, 'ws_abc123', './output/');
console.log(`Saved to ${localPath}`);# Get the presigned URL
curl "https://api.smarts.bio/v1/files/download?workspace_id=ws_abc123&key=/files/output.vcf" \
-H "Authorization: Bearer sk_live_..."
# → { "data": { "downloadUrl": "https://s3.amazonaws.com/..." } }
# Download using it
curl -o output.vcf "https://s3.amazonaws.com/..."# Download a workspace file to a local path smarts file download /files/output.vcf -o ./output/ -w ws_abc123
DELETE
/v1/filesfiles scopeDelete a file. Requires workspace_id and key as query parameters.
client.files.delete(result["key"], workspace_id="ws_abc123")
await client.files.delete(result.key, 'ws_abc123');
curl -X DELETE "https://api.smarts.bio/v1/files?workspace_id=ws_abc123&key=/files/old.vcf" \ -H "Authorization: Bearer sk_live_..."
# Delete a file from a workspace smarts file rm /files/old.vcf -w ws_abc123
Large file upload (>500 MB)
Use a two-step presigned URL flow to upload large files directly to S3.
1. POST /v1/files/upload-url
2. PUT to S3
3. POST /v1/files/upload-confirm
import requests, os
path = "large_genome.bam"
size = os.path.getsize(path)
# 1. Request presigned URL
info = client.files.upload_large(
filename=os.path.basename(path),
workspace_id="ws_abc123",
content_type="application/octet-stream",
size=size,
path="bam/",
)
# 2. PUT bytes directly to S3
with open(path, "rb") as f:
requests.put(info["uploadUrl"], data=f,
headers={"Content-Type": "application/octet-stream"})
# 3. Confirm
result = client.files.upload_confirm(
file_key=info["fileKey"],
workspace_id="ws_abc123",
filename=os.path.basename(path),
size=size,
)
print(result["key"])import { readFileSync, statSync } from 'fs';
import { basename } from 'path';
const filePath = 'large_genome.bam';
const size = statSync(filePath).size;
// 1. Request presigned URL
const info = await client.files.uploadLarge({
filename: basename(filePath), workspaceId: 'ws_abc123',
contentType: 'application/octet-stream', size, path: 'bam/',
});
// 2. PUT bytes directly to S3
await fetch(info.uploadUrl, {
method: 'PUT', body: readFileSync(filePath),
headers: { 'Content-Type': 'application/octet-stream' },
});
// 3. Confirm
const result = await client.files.uploadConfirm({
fileKey: info.fileKey, workspaceId: 'ws_abc123',
filename: basename(filePath), size,
});
console.log(result.key);