What it does
Upload one file to the draft: an image (png, jpg, jpeg, gif, webp, avif, svg, ico), a PDF, a font (woff2, woff, ttf, otf) or a short video (mp4, webm). Send one of source_url or content_base64. With source_url, Pagehive downloads a file at a public https link (up to max_file_bytes, 3 redirects, 60 seconds). content_base64 carries the bytes in the call, a third larger than the file: a 93 KB PNG is tens of thousands of output tokens. create_upload_url uploads a file from a local disk without the bytes passing through a call. Pages link the file as /files/name, for example <img src="/files/logo.png" alt="...">, after publish_site. The bytes must match the extension. The same name again replaces the file. Counts against max_file_bytes and the account's storage.
Plans
Works on every plan: Free, Basic, Pro and Ultra.
Parameters
| Name | Type | About |
|---|---|---|
site_idrequired | string | The id of the site. list_sites gives the ids of your sites. |
namerequired | string | The file name. It is served at /files/<name> after the next publish. |
source_url | string | An https link to fetch the file from. Use this for a file that is already online. |
content_base64 | string | The file's bytes as base64. Only for small files: use create_upload_url for anything bigger. |
message | string | A short note for the version history, like a commit message. |
verbose | boolean | true lists every file and page of the draft. Otherwise the response lists only what this call changed, plus draft totals. |
Example
Call upload_file with these arguments:
{
"site_id": "01a1…",
"name": "logo.png",
"source_url": "https://example.com/logo.png"
}
Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.
Related guides
- Images, fonts, PDFs and videoUpload files and use them on your pages.