Skip to content

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 ​

bash
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"
      }'
FieldRequiredDescription
filenameyesOriginal file name.
contentTypeyesMIME type.
sizenoByte size, checked against your storage allowance.
visibilitynopublic or private.
originnolibrary (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:

bash
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.

POST/files/upload-urlMint a direct-upload URL. The response carries the URL to PUT to and the storage key for step 2.Try it
POST/files/completeConfirm the bytes landed. Only key is required; the file becomes a media record from this response onward.Try it

Files ​

GET/filesPaged library listing.Try it
GET/files/{id}One file's metadata and URLs.Try it
PATCH/files/{id}Update name, altText, tags or folderId (at least one).Try it
PATCH/files/{id}/visibilitySwitch between public and private.Try it
GET/files/{id}/usagesWhere the file is referenced — pages, records, messages. Check this before deleting.Try it
POST/files/moveMove up to 500 files into a folder. folderId: null moves them to the root.Try it
GET/files/tagsTags in use, for building a filter UI.Try it

Folders ​

GET/files/foldersThe folder tree.Try it
POST/files/foldersCreate a folder.Try it
PATCH/files/folders/{id}Rename or move a folder.Try it

Bringing files in from elsewhere ​

POST/files/externalRegister a file by URL.Try it
POST/files/generateGenerate an image from a prompt. Spends AI credits.Try it
POST/files/stock/importImport a stock result, keeping the attribution the provider returned.Try it

Attribution 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.