Media files
Images, documents and other assets, shared by every pillar — a file uploaded here can be a page image, an email attachment, a product photo or a record attachment.
Scope: media:read · media:write
This group is rate-limited as "heavy"
Every method counts against the heavy class, not just writes — see Rate limits. Upload in a steady stream rather than in one burst.
Uploading a file
Uploads go directly to storage in two steps, so your bytes never pass through the API.
1. Mint an upload URL
curl -X POST https://api.onivos.com/files/upload-url \
-H "Authorization: Bearer onv_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"filename": "roof-inspection.jpg",
"contentType": "image/jpeg",
"size": 428113,
"visibility": "public"
}'| Field | Required | Description |
|---|---|---|
filename | yes | Original file name. |
contentType | yes | MIME type. |
size | no | Byte size, checked against your storage allowance. |
visibility | no | public or private. |
origin | no | library (default) or record — record keeps the file out of the media library listing. |
The response carries the URL to PUT to, and the storage key you will need in step 2.
2. PUT the bytes, then confirm
Upload the file to the returned URL with a plain PUT, then tell the API it landed:
curl -X POST https://api.onivos.com/files/complete \
-H "Authorization: Bearer onv_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"key": "…the key from step 1…",
"filename": "roof-inspection.jpg",
"contentType": "image/jpeg",
"altText": "Roof inspection, north slope",
"tags": ["inspection"],
"visibility": "public"
}'Only key is required. The file exists as a media record from this response onward — an upload that never gets confirmed is not part of your library.
/files/upload-urlMint a direct-upload URL. The response carries the URL to PUT to and the storage key for step 2.Try it/files/completeConfirm the bytes landed. Only key is required; the file becomes a media record from this response onward.Try itFiles
/filesPaged library listing.Try it/files/{id}One file's metadata and URLs.Try it/files/{id}Update name, altText, tags or folderId (at least one).Try it/files/{id}/visibilitySwitch between public and private.Try it/files/{id}/usagesWhere the file is referenced — pages, records, messages. Check this before deleting.Try it/files/moveMove up to 500 files into a folder. folderId: null moves them to the root.Try it/files/tagsTags in use, for building a filter UI.Try itFolders
/files/foldersThe folder tree.Try it/files/foldersCreate a folder.Try it/files/folders/{id}Rename or move a folder.Try itBringing files in from elsewhere
/files/externalRegister a file by URL.Try it/files/generateGenerate an image from a prompt. Spends AI credits.Try it/files/stock/searchSearch stock providers.Try it/files/stock/importImport a stock result, keeping the attribution the provider returned.Try itAttribution is your obligation
Stock imports keep the author and source URL the provider returned. Keep them on the rendered page — that is the licence condition, not a nicety.
Related
- Websites & pages — using a file on a page.
- Records —
attachmentfields point at these files.