Skip to content
dhanu docs
Browse pages

API reference

Download a file

GET /api/pub/v1/files/{fileId}/download, the stored bytes of an uploaded file.

GEThttps://api.dhanu.ai/api/pub/v1/files/{fileId}/download

Streams the stored bytes of an uploaded file with its original Content-Type and a Content-Disposition carrying the filename. Only uploaded kinds have bytes; an artifact answers unsupported_media_type, export it.

Request

curl -OJ https://api.dhanu.ai/api/pub/v1/files/$FILE_ID/download \
  -H "Authorization: Bearer $DHANU_API_KEY"
const { bytes, mimeType, filename } = await dhanu.files.download(fileId);
await fs.writeFile(filename ?? "download.bin", bytes);
downloaded = dhanu.files.download(file_id)
with open(downloaded.filename or "download.bin", "wb") as fh:
    fh.write(downloaded.bytes)

Response

200 OK

The file body, with Content-Type, Content-Length and Content-Disposition: attachment; filename="…".

Errors

CodeStatusMeaning
invalid_api_key401The bearer key is missing or unknown.
api_key_revoked401The key was revoked.
api_key_expired401The key passed its expiry date.
api_key_ip_not_allowed403The caller's IP is outside the key's allowlist.
developer_access_revoked403The key's creator lost developer access in the workspace.
api_key_project_scope403The key covers no active projects, or projectId is outside its scope.
not_found404No such resource in the key's workspace.