Uploading large files
A file too large for one request is uploaded in parts: you open a session, send the parts (straight to storage or through the API), and complete it. An interrupted upload resumes from the parts already received. This guide walks through each call and ends with the handle you use afterwards. For a small file, one base64 request is simpler; see Values and handles.
The flow
- Open a session with the file's exact size. The response says how to send it.
- Send each part: in direct mode, PUT it to the presigned URL for its number; in proxied mode, PUT it to the API.
- Complete the session. The response is the stored file's handle.
Part n holds bytes (n - 1) * part_size up to n * part_size; the last part is shorter. Parts may be sent in any order and in parallel, and sending a part again replaces it.
Open a session
init_upload declares the file. size is required and exact: it bounds the number of parts, and completion checks the received bytes against it.
curl -X POST "https://api.hilus.ai/Platform/uploads/init" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "recording-2026-09-25.wav",
"content_type": "audio/wav",
"size": 734003200
}'
Response:
{
"upload_id": "8f14e45fceea167a5a36dedd4bea2543",
"mode": "direct",
"part_size": 67108864,
"part_count": 11,
"part_urls": {
"1": "https://storage.example/landing/8f14e4...?part=1&signature=...",
"2": "https://storage.example/landing/8f14e4...?part=2&signature=..."
},
"parts_received": []
}
Direct mode is the default: parts go straight to storage and never pass through the API, which is fastest for browsers. Ask for mode: "proxied" from a CLI or a server that cannot reach storage directly; the response then has no URLs and a smaller part_size.
An agent with a shell uses direct mode too: the part URLs carry their own signature, so a plain HTTP PUT of the file's bytes is enough and no API credential is needed. A file smaller than part_size is one part. Proxied mode needs your credential on every part, which a sandbox usually does not hold, and some sandboxes cannot reach the storage host at all; then ask the person for the file instead (below).
curl -X POST "https://api.hilus.ai/Platform/uploads/init" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "export.zip",
"content_type": "application/zip",
"size": 104857600,
"mode": "proxied"
}'
Send the parts
Direct mode. PUT each part's raw bytes to its URL from part_urls, with no API credentials (the URL carries its own signature). URLs expire after an hour; when one is refused with 403, get fresh ones with part_urls:
curl -X POST "https://api.hilus.ai/Platform/uploads/8f14e45fceea167a5a36dedd4bea2543/part-urls" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"parts": [
3,
4
]
}'
Proxied mode. Send each part to put_part as the raw application/octet-stream body of PUT /Platform/uploads/{upload_id}/parts/{part_number}, with your usual credentials. The response is the part's etag and size.
Resume an interrupted upload
upload_status lists the parts_received so far and, in direct mode, fresh URLs for the parts still missing. Send only those, then complete.
curl -X GET "https://api.hilus.ai/Platform/uploads/8f14e45fceea167a5a36dedd4bea2543" \
-H "Authorization: Bearer $HILUS_API_KEY"
Response:
{
"upload_id": "8f14e45fceea167a5a36dedd4bea2543",
"mode": "direct",
"phase": "open",
"status": "open",
"size": 734003200,
"part_size": 67108864,
"parts_received": [
1,
2,
5,
6,
7,
8,
9,
10,
11
],
"part_urls": {
"3": "https://storage.example/landing/8f14e4...?part=3&signature=...",
"4": "https://storage.example/landing/8f14e4...?part=4&signature=..."
}
}
Complete the upload
complete_upload assembles the parts, stores the file and detects its real type from its first bytes. It is synchronous and idempotent: if the call times out, call it again and it picks up where it stopped.
curl -X POST "https://api.hilus.ai/Platform/uploads/8f14e45fceea167a5a36dedd4bea2543/complete" \
-H "Authorization: Bearer $HILUS_API_KEY"
Response:
{
"upload_id": "8f14e45fceea167a5a36dedd4bea2543",
"status": "done",
"hash": "file-Rc9vT1",
"dtype": "file",
"size": 734003200,
"content_type": "audio/wav",
"filename": "recording-2026-09-25.wav",
"deduped": false
}
Every upload is stored as a generic file; the handle in hash is what you pass on. Pass it straight to any operation that takes a recording, document or image: its content decides which it is. Read it with the dtypes resource, or store it on an entity.
[!WARNING] Completion fails with 400 when the bytes received do not add up to the declared
size. Checkupload_statusfor missing parts, send them, and complete again.
To give up on an upload, abort_upload discards it and any parts received:
curl -X DELETE "https://api.hilus.ai/Platform/uploads/8f14e45fceea167a5a36dedd4bea2543" \
-H "Authorization: Bearer $HILUS_API_KEY"
Ask a person for a file
When the person you are working for has the file (an attachment in a chat, a document on their computer) and you cannot send its bytes yourself, give them an upload link. create_upload_link returns a page url; they open it, sign in as the account you act for, and pick the file. Nothing passes through you.
curl -X POST "https://api.hilus.ai/Platform/uploads/links" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"purpose": "the signed intake form",
"max_files": 1
}'
Response:
{
"link_id": "q2Vb7nXk",
"url": "https://app.hilus.ai/upload/q2Vb7nXk",
"purpose": "the signed intake form",
"max_files": 1,
"status": "pending",
"expires_at": 1791913435.0,
"files": []
}
Ask them to say when they are done, then read the link with get_upload_link. status turns done when the first file arrives, and files lists each file's handle:
curl -X GET "https://api.hilus.ai/Platform/uploads/links/q2Vb7nXk" \
-H "Authorization: Bearer $HILUS_API_KEY"
Response:
{
"link_id": "q2Vb7nXk",
"url": "https://app.hilus.ai/upload/q2Vb7nXk",
"purpose": "the signed intake form",
"max_files": 1,
"status": "done",
"expires_at": 1791913435.0,
"files": [
{
"hash": "file-Rc9vT1",
"dtype": "file",
"size": 2411520,
"content_type": "application/pdf",
"filename": "intake-form.pdf",
"deduped": false
}
]
}
Hosts that render apps show the same link as a file picker inside the conversation. Only the user who created a link can upload through it or read it, and it stops accepting files when it expires.
Ask for a secret
When you need a password, an API key or a token that nobody has given you, never ask for it in the conversation: ask with an upload link for a secret. Create the link with kind secret and a purpose that says what the credential is for:
curl -X POST "https://api.hilus.ai/Platform/uploads/links" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "secret",
"purpose": "the API token for the help desk tool server"
}'
Response:
{
"link_id": "t8Rw2mKc",
"url": "https://app.hilus.ai/upload/t8Rw2mKc",
"kind": "secret",
"purpose": "the API token for the help desk tool server",
"max_files": 1,
"status": "pending",
"expires_at": 1791913435.0,
"files": []
}
Give the person the url. They must sign in as the account you act for, the same as for a file; the page shows your purpose and one hidden input, and stores what they type in your organization's secret store. A secret link takes one value and cannot be used for files. Some MCP clients open the page for the person themselves and answer once the person has dealt with it: the link they hand back may already be done, with the handle in files, or may still be waiting for the value, and if the person declined the page the call says so instead of returning a link. Unless it is already done, ask the person to say when they are done, then read the link:
curl -X GET "https://api.hilus.ai/Platform/uploads/links/t8Rw2mKc" \
-H "Authorization: Bearer $HILUS_API_KEY"
Response:
{
"link_id": "t8Rw2mKc",
"url": "https://app.hilus.ai/upload/t8Rw2mKc",
"kind": "secret",
"purpose": "the API token for the help desk tool server",
"max_files": 1,
"status": "done",
"expires_at": 1791913435.0,
"files": [
{
"hash": "secret-Vf3kP9xQ2mN8",
"dtype": "secret",
"size": null,
"content_type": null,
"filename": null,
"deduped": false
}
]
}
files[0].hash is the secret's handle; the value never comes back. Write the handle into the record that uses the credential with an entity patch, as in "A credential someone gave you" in Values and handles. Until you do, the secret is stored but nothing uses it. The secrets topic has the whole rule.
For the password of a website login, also pass the login's sites, each an exact scheme://host[:port]. The page tells the person where it will be typed, and the handle is bound to those sites: a browser types the password only for a login with exactly them.
curl -X POST "https://api.hilus.ai/Platform/uploads/links" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "secret",
"purpose": "your password for the supplier portal",
"sites": [
"https://portal.example.com"
]
}'
Uploads from a form
A public form's visitor uploads with the form's session instead of an account. Pass the form's file-upload field_id when opening the session: the field's size limit and accepted types apply, completion re-checks the detected type against them (a mismatch is discarded with a 400), and the file expires unless the form is submitted with it. Each form session also has a total size and a limit on uploads in progress.
curl -X POST "https://api.hilus.ai/Platform/uploads/init" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "vaccination-record.pdf",
"content_type": "application/pdf",
"size": 2411520,
"field_id": "records_upload"
}'
Errors
- 400: a missing or non-positive
size, a part number out of range, a file type the form field does not accept, a size mismatch at completion, or a file sent to a link that asks for a secret. - 404: an unknown upload id or upload link, or one opened by another caller (both are bound to whoever opened them).
- 409: the upload was already completed or aborted, or the upload link already has its files or its secret.
- 410: the upload link expired.
- 413: the file or a part is larger than allowed.
Next steps
- Values and handles: read and convert the uploaded file by its handle.
- The secrets topic: why a credential is only ever passed by its handle.
- Entities and branches: attach the handle to an entity.
- The Uploads reference for every parameter.