Media API
/api/v1/media is a simple REST interface to the media library. During the upload, an image is resized, converted to AVIF and WebP, cut into thumbnails and indexed before the response is returned. There is no queue to poll and no background worker to monitor.

Every call needs an API key, and every write needs the upload_files capability, which the admin, editor and author roles have.
Listing files
GET /api/v1/media takes exactly three parameters: page (1-indexed, default 1), per_page (default 20) and type.
type filters on the stored MIME type and accepts image, video, audio or file. file covers everything that is not an image, video or audio file, such as PDFs, spreadsheets and archives. Without type, the whole library is returned. There is no keyword search, no uploader filter and no sort parameter on this endpoint; results are always sorted newest first.
curl -H "X-API-Key: YOUR_TOKEN" \
"https://yoursite.com/api/v1/media?type=image&per_page=20"
{
"success": true,
"data": {
"items": [
{
"id": 45,
"filename": "cover-8f3a12c4.avif",
"original_filename": "cover.jpg",
"path": "images/2026/04/cover-8f3a12c4.avif",
"url": "https://yoursite.com/uploads/images/2026/04/cover-8f3a12c4.avif",
"type": "image",
"mime_type": "image/avif",
"size": 61204,
"width": 1600,
"height": 900,
"alt_text": "Plate of scrambled eggs",
"title": "cover",
"caption": "",
"user_id": 1,
"created_at": "2026-04-10 08:55:00",
"formats": {
"avif": { "path": "images/2026/04/cover-8f3a12c4.avif", "size": 61204 },
"webp": { "path": "images/2026/04/cover-8f3a12c4.webp", "size": 88431 }
},
"thumbnails": { "thumbnail": { "…": "…" }, "medium": { "…": "…" }, "large": { "…": "…" } }
}
],
"total": 412,
"pages": 21,
"current_page": 1
}
}
formats, thumbnails and srcset are stored in the row's JSON metadata column and are merged into the returned object, so they appear as ordinary top-level keys. GET /api/v1/media/{id} returns one item in the same shape, or 404 if the id does not exist.
Uploading a file
Send a multipart form with the binary in a field named file. You can add two optional text fields: alt becomes the alt text and title becomes the library title. If alt is empty, jekcms builds a readable default from the filename, so your pages do not get an empty alt="".
curl -X POST https://yoursite.com/api/v1/media \
-H "X-API-Key: YOUR_TOKEN" \
-F "file=@/path/to/cover.jpg" \
-F "alt=Plate of scrambled eggs"
The response contains the upload result: success, the stored id, the final path and url, size, mime_type, the generated formats and thumbnails. For images, the path already points at the converted file, not at what you sent.
Uploading from a URL
The same endpoint accepts a JSON body with a url instead of a multipart file, so an automation does not need to download the image first:
curl -X POST https://yoursite.com/api/v1/media \
-H "X-API-Key: YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"url": "https://images.example.com/food/eggs.jpg", "alt": "Plate of scrambled eggs"}'
The download is restricted. Only http and https are allowed, redirects are not followed, and the hostname is resolved before the request is made. Any address that resolves to a private, loopback, link-local or cloud-metadata address is refused. The download stops at 25 MB and times out at 60 seconds. A refusal returns HTTP 200 with success: false and one of these reason codes in the error text: private-or-reserved-ip, scheme-not-allowed, internal-host, metadata-or-linklocal, dns-failed or invalid-url. Check the flag as well as the status code.
This endpoint does not accept Base64 uploads. They are handled by the automation endpoint POST /api/v1/webhook/media-base64, which takes data and filename and accepts images only.
What conversion does
Conversion runs inline, during the request. An image is read, resized if either side exceeds the configured maximum (2560 pixels by default), then written as AVIF and as WebP. AVIF becomes the primary file and the one the database row points at; WebP is the fallback. Once both exist, the original JPEG, PNG or GIF is deleted; the library keeps only the new formats. A file uploaded as WebP or AVIF is kept unchanged.
Four thumbnail sizes are also created: a cropped 400×400 square, 800×800 and 1600×1600 fitted inside those bounds, and a cropped 1000×1500 for Pinterest.
Quality and size settings live in Settings → Media: maximum dimension (800–4096), JPEG quality, WebP quality (55–95, default 82) and AVIF quality (40–80, default 60). With the defaults, images show no visible quality loss and are much smaller than the original.
If the server has no GD extension, conversion is skipped without an error: the file is stored in its original format and the response says so. Only in this case do you get a JPEG instead of an AVIF.
Updating metadata
PUT or PATCH on /api/v1/media/{id} changes alt_text, title, caption and description. No other field can be changed through the API, and the response is {"success": true}.
Deleting
DELETE /api/v1/media/{id} removes the database row, the primary file, the WebP and AVIF siblings and every generated thumbnail.
It does not check whether anything still points at the file. If a deleted image is still a post's cover or is used inside a post body, that reference breaks. Check where an image is used before you delete it, especially from a script.
Limits
MAX_UPLOAD_SIZE caps uploads at 50 MB, and PHP's own upload_max_filesize and post_max_size also apply. On shared hosting the PHP limit is usually lower, so check it first when a large file is refused. Downloads from a URL have a lower limit of 25 MB.
Files are checked against a list of allowed extensions; the MIME type sent by the client is not used. Images accept jpg, jpeg, png, gif, webp and avif. Documents and archives accept pdf, doc, docx, xls, xlsx, zip and txt. Anything else is refused with an explanatory error in the response body.
SVG is not accepted. An SVG is served as image/svg+xml and can contain scripts, so an upload form would allow stored XSS on your own domain. Site logos and interface icons are part of the theme files instead.
Status codes
| Code | When | |---|---| | 200 | Listing, read, update, delete or upload handled | | 400 | Neither a file field nor a url was sent, or the media id is missing | | 401 | Missing, unknown, inactive or expired API key | | 403 | The key's role lacks upload_files | | 404 | No media with that id | | 405 | Method not supported on that path | | 429 | Over the per-IP hourly rate limit |
Validation failures during an upload (wrong extension, file too large, corrupt image, refused remote URL) return HTTP 200 with success: false and a message, because they are results of the upload, not errors in the request. Always check the flag.