API reference · Files
A short-lived link to download a file's content without credentials
/v1/files/{file_id}/download-link- TypeScript
client.files.createDownloadLink()- Python
client.files.create_download_link()- CLI
hayonix files download-link
The link works for 5 minutes, for this file only, and stops working if the file is deleted. Use it where a request cannot carry credentials (a browser saving a large file straight to disk).
Project API key (Authorization: Bearer sk_…), or a console session. Requires the file:read permission (a key's scope, or a role that includes it).
Examples
The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.
curl -sS -X POST "$API_BASE_URL/files/file_01jc5zq4m8k3v6x9t2w7r0b1e4/download-link" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: $(uuidgen)"Request
| Header | Required | Description |
|---|---|---|
Authorization | yes | Bearer and your API key. The key implies its project. |
X-Project-Id | session only | The project to act in, for console sessions. Requests with an API key leave it out. |
Idempotency-Key | no | Makes a retry safe: the same key and request within 24 hours return the original response (see Idempotency). The SDKs send one for you. |
Path parameters
file_idstringrequiredID of the file
ID with prefix file_
Response
201 DownloadLink — The link
objectstringrequiredAlways `download_link`: the type of this object
One of
download_linkurlstringrequiredAbsolute URL of the download; works without credentials until `expires_at`
pathstringrequiredThe same link relative to the API origin (`/v1/downloads?token=…`)
filenamestringrequiredThe name the download is saved under
bytesintegerrequiredSize in bytes
expires_atstring (date-time)requiredWhen it expires (null: never) (ISO 8601, UTC)
Example response
{
"object": "download_link",
"url": "https://api.example.com/v1/downloads?token=dl1.eyJr….Zm9v",
"path": "string",
"filename": "string",
"bytes": 1,
"expires_at": "2026-01-01T00:00:00.000Z"
}Errors
Errors use the standard envelope. What this operation can answer:
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | A parameter or body field is missing or not allowed; param names it. |
401 | authentication_error | The key or session is missing, revoked or expired. |
403 | permission_error | The credential lacks the permission this needs, or the organization is suspended. |
404 | not_found_error | No such resource in this project (an ID from another project is answered the same way). |
409 | conflict_error | The resource's current state does not allow this. |
409 | conflict_error idempotency_in_progress | A request with the same Idempotency-Key is still running. |
422 | idempotency_error idempotency_key_reused | The Idempotency-Key was used with a different request. |
429 | rate_limit_error rate_limited | Too many requests; retry after retry-after seconds. |