Overview
The Drive API lets you manage files and folders in Copera. The drive is organized as a tree hierarchy, supports multipart uploads for large files, and provides signed download URLs. Requires a Personal Access Token (cp_pat_) with the ACCESS_DRIVE scope.
The Copera Node.js SDK and CLI fully support all Drive operations. Choose your preferred tool below.
Quick Start
# Browse drive tree
curl -X GET https://api.copera.ai/public/v1/drive/tree \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
# Get file metadata
curl -X GET https://api.copera.ai/public/v1/drive/files/{fileId} \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
# Download a file (returns signed URL)
curl -X GET https://api.copera.ai/public/v1/drive/files/{fileId}/download \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
# Search files
curl -X GET "https://api.copera.ai/public/v1/drive/search?q=report" \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN"
# Create a folder
curl -X POST https://api.copera.ai/public/v1/drive/folders \
-H "Authorization: Bearer cp_pat_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "name": "Project Files" }'
npm install @copera.ai/sdk
import { CoperaAI } from '@copera.ai/sdk' ;
const copera = CoperaAI ({ apiKey: 'cp_pat_your_token' });
// Browse drive tree
const tree = await copera . drive . getDriveTree ({ depth: 3 });
// Get file metadata
const file = await copera . drive . getFile ({ fileId: 'file-id' });
// Download a file (get signed URL, valid 3 hours)
const { url } = await copera . drive . downloadFile ({ fileId: 'file-id' });
// Search files
const results = await copera . drive . searchDrive ({ q: 'quarterly report' });
// Create a folder
const folder = await copera . drive . createFolder ({
name: 'Reports' ,
parentId: 'parent-folder-id'
});
// Upload a file (multipart flow)
const { uploadId , fileKey } = await copera . drive . startUpload ({
fileName: 'report.pdf' ,
fileSize: 5242880 ,
mimeType: 'application/pdf' ,
parentId: folder . id
});
const { parts } = await copera . drive . getPresignedUrls ({
uploadId , fileKey , parts: 1
});
// Upload chunk to S3, then finalize
const response = await fetch ( parts [ 0 ]. signedUrl , {
method: 'PUT' , body: fileBuffer
});
await copera . drive . finalizeUpload ({
uploadId , fileKey ,
parts: [{ partNumber: 1 , eTag: response . headers . get ( 'etag' ) ! }]
});
@copera.ai/sdk Full SDK documentation and source code
curl -fsSL https://cli.copera.ai/install.sh | bash
# Browse drive tree
copera drive tree
copera drive tree --parent < i d > --depth 5
# Search files
copera drive search "quarterly report"
# Get file metadata
copera drive get < file-i d >
# Download a file
copera drive download < file-i d >
copera drive download < file-i d > -o report.pdf
# Upload files
copera drive upload ./report.pdf
copera drive upload ./project/ --parent < i d > # recursive directory upload
# Create a folder
copera drive mkdir "New Folder"
copera drive mkdir "Sub" --parent < i d >
The CLI handles multipart uploads automatically with concurrent chunk uploads, configurable chunk size, and progress bars.
copera-cli CLI installation, configuration, and full command reference
Available Operations
Operation Description Drive Tree Browse the file/folder hierarchy with configurable depth Get File Retrieve metadata for a file or folder Download File Get a CloudFront signed URL (valid 3 hours) Search Files Full-text search across accessible drive items Create Folder Create a new folder at root or nested inside another Multipart Upload Upload files via S3 presigned URLs (start, get URLs, finalize)
Next Steps