Media
Upload images, videos and files, or have Unvop fetch them from a URL, and use them on pages.
Every site has a media library: the images, videos and files its pages use. Upload a file, or send a URL and Unvop downloads it. Either way you get back a url to put in an image prop or a collection field.
Uploading needs media:write (which content:write also grants).
Upload a file
Send it as multipart/form-data in a file field, with optional alt text:
curl https://api.unvop.com/v1/sites/site_…/media \
-H "Authorization: Bearer $UNVOP_KEY" \
-F "file=@sourdough.jpg" \
-F "alt=A sourdough loaf on the counter"import { readFile } from 'node:fs/promises';
const form = new FormData();
form.append('file', new Blob([await readFile('sourdough.jpg')], { type: 'image/jpeg' }), 'sourdough.jpg');
form.append('alt', 'A sourdough loaf on the counter');
const res = await fetch(`https://api.unvop.com/v1/sites/${siteId}/media`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.UNVOP_KEY}` },
body: form,
});
const media = await res.json();with open("sourdough.jpg", "rb") as f:
res = requests.post(
f"https://api.unvop.com/v1/sites/{site_id}/media",
headers={"Authorization": f"Bearer {os.environ['UNVOP_KEY']}"},
files={"file": ("sourdough.jpg", f, "image/jpeg")},
data={"alt": "A sourdough loaf on the counter"},
)
media = res.json()Or send a URL
Send JSON with an https URL and Unvop fetches the file itself:
{ "url": "https://images.example.com/sourdough.jpg", "alt": "A sourdough loaf on the counter" }What comes back
201 with the file: its id, url, filename, mime, size, and for images width and height. Put the url in a block's image prop or an image field of a collection entry.
Files can be up to 15 MB: JPG, PNG, WebP, GIF, AVIF, SVG, PDF, MP4 and WebM. Larger files get 413 too_large, other types 415 unsupported_media_type.
Alt text
Alt text is what screen readers and search engines read. Set it when you upload, or later with PATCH /sites/{siteId}/media/{mediaId} and { "alt": "…" }. Describe what the picture shows, not that it is a picture.
Find and delete
GET /sites/{siteId}/media lists files newest first (up to 500). Search with q, filter with type. DELETE /sites/{siteId}/media/{mediaId} deletes a file; pages that still use it show nothing in its place, so change those first.