Skip to content
Hayonix

API reference · Files

A short-lived link to download a file's content without credentials

POST/v1/files/{file_id}/download-link
API keyfile:readProjectIdempotency-Key
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

Headers
HeaderRequiredDescription
AuthorizationyesBearer and your API key. The key implies its project.
X-Project-Idsession onlyThe project to act in, for console sessions. Requests with an API key leave it out.
Idempotency-KeynoMakes 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_idstringrequired

    ID of the file

    ID with prefix file_

Response

201 DownloadLink — The link

  • objectstringrequired

    Always `download_link`: the type of this object

    One ofdownload_link

  • urlstringrequired

    Absolute URL of the download; works without credentials until `expires_at`

  • pathstringrequired

    The same link relative to the API origin (`/v1/downloads?token=…`)

  • filenamestringrequired

    The name the download is saved under

  • bytesintegerrequired

    Size in bytes

  • expires_atstring (date-time)required

    When it expires (null: never) (ISO 8601, UTC)

Example response
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:

Errors
StatusTypeWhen
400invalid_request_errorA parameter or body field is missing or not allowed; param names it.
401authentication_errorThe key or session is missing, revoked or expired.
403permission_errorThe credential lacks the permission this needs, or the organization is suspended.
404not_found_errorNo such resource in this project (an ID from another project is answered the same way).
409conflict_errorThe resource's current state does not allow this.
409conflict_error idempotency_in_progressA request with the same Idempotency-Key is still running.
422idempotency_error idempotency_key_reusedThe Idempotency-Key was used with a different request.
429rate_limit_error rate_limitedToo many requests; retry after retry-after seconds.