Skip to content

Media API

Upload and serve media files (images and PDFs) associated with an agent. Uploaded files are stored in the agent's media directory and can be referenced in messages via media_files[].

POST /api/v1/agents/:agentId/media

Upload a media file as a raw binary body. Supported MIME types: image/*, application/pdf.

Request headers:

HeaderRequiredDescription
Content-TypeYesMIME type of the file (e.g. image/jpeg, application/pdf)
X-FilenameNoOriginal filename — used to preserve extension
bash
curl -X POST \
  -H "X-Api-Key: my-secret-key-123" \
  -H "Content-Type: image/jpeg" \
  -H "X-Filename: photo.jpg" \
  --data-binary @/path/to/photo.jpg \
  http://localhost:10850/api/v1/agents/alfred/media | jq
json
{ "mediaPath": "ui-upload/2026-05-10/gw-1746837600000.jpg" }

Error responses:

StatusWhen
400No file body received
403Key has no access to agent
404Agent not found
413File exceeds max upload size
415Unsupported MIME type

GET /api/v1/agents/:agentId/media/*

Serve a media file by path. The path must stay within the agent's media directory.

bash
curl -H "X-Api-Key: my-secret-key-123" \
  "http://localhost:10850/api/v1/agents/alfred/media/ui-upload/2026-05-10/gw-1746837600000.jpg" \
  --output photo.jpg

Error responses:

StatusWhen
400Path traversal attempt or invalid path
403Key has no access to agent
404Agent or file not found

Claude Code inside.