API reference
Upload a file
POST /api/pub/v1/files, upload a file into the key creator's drive in one multipart request.
POST
https://api.dhanu.ai/api/pub/v1/filesUploads one file in a single multipart request (field file) into the personal drive
of the person who created the key. The returned id works everywhere a file id does,
attach it to a task with fileIds on create a task
or send a message, or download it later.
For anything larger than the single-request limit, use the
presigned upload instead. Uploads count
against the workspace storage quota; a full drive answers storage_quota_exceeded.
Request
curl -X POST https://api.dhanu.ai/api/pub/v1/files \
-H "Authorization: Bearer $DHANU_API_KEY" \
-F "file=@notes.txt"const file = await dhanu.files.upload({
data: await fs.readFile("notes.txt"),
filename: "notes.txt",
mimeType: "text/plain",
});with open("notes.txt", "rb") as fh:
file = dhanu.files.upload(data=fh.read(), filename="notes.txt", mime_type="text/plain") Response
201 Created
{ "file": { "id": "…", "filename": "notes.txt", "mimeType": "text/plain", "sizeBytes": 5, "kind": "file", "createdAt": "…" } }
Errors
| Code | Status | Meaning |
|---|---|---|
invalid_api_key | 401 | The bearer key is missing or unknown. |
api_key_revoked | 401 | The key was revoked. |
api_key_expired | 401 | The key passed its expiry date. |
api_key_ip_not_allowed | 403 | The caller's IP is outside the key's allowlist. |
developer_access_revoked | 403 | The key's creator lost developer access in the workspace. |
api_key_project_scope | 403 | The key covers no active projects, or projectId is outside its scope. |
invalid_request_body | 422 | The body did not match the schema; error.issues names each field. |
unsupported_media_type | 415 | The file type is not accepted. |
file_too_large | 413 | The file is larger than the direct-upload limit. |
storage_quota_exceeded | 507 | The workspace's storage quota is full. |