Skip to content

Media

Media tools manage file attachments linked to coverage items. Files are stored in Supabase Storage (pr-media bucket) and metadata is tracked in the media table.

The upload flow is two-step:

  1. Call upload_media_url to get a presigned upload URL.
  2. Upload the file to that URL using HTTP PUT.
  3. Call attach_media to record the metadata.

upload_media_url

Get a presigned upload URL for media attached to a coverage item.

Parameters

ParameterTypeRequiredDescription
coverage_idstring (UUID)YesCoverage item to attach media to
filenamestringYesOriginal filename
mime_typestringYesMIME type (e.g. video/mp4, application/pdf)

Example

json
{
  "name": "upload_media_url",
  "arguments": {
    "coverage_id": "550e8400-e29b-41d4-a716-446655440000",
    "filename": "interview-clip.mp4",
    "mime_type": "video/mp4"
  }
}

Response Shape

json
{
  "media_id": "...",
  "upload_url": "https://...",
  "storage_path": "coverage-id/media-id/interview-clip.mp4",
  "token": "...",
  "instructions": "Upload your file to the upload_url using PUT with the appropriate Content-Type header. Then call attach_media to save the metadata."
}

attach_media

Record media metadata after uploading to storage.

Parameters

ParameterTypeRequiredDescription
coverage_idstring (UUID)YesCoverage ID
typestringYesarticle_pdf, video, video_clip, audio, audio_clip, image, document
filenamestringYesOriginal filename
storage_pathstringYesPath returned from upload_media_url
mime_typestringYesMIME type
size_bytesnumberNoFile size in bytes
duration_secondsnumberNoDuration for audio/video files
metadataobjectNoAdditional metadata as key-value pairs

Example

json
{
  "name": "attach_media",
  "arguments": {
    "coverage_id": "550e8400-e29b-41d4-a716-446655440000",
    "type": "video_clip",
    "filename": "interview-clip.mp4",
    "storage_path": "550e8400.../abc123.../interview-clip.mp4",
    "mime_type": "video/mp4",
    "size_bytes": 15728640,
    "duration_seconds": 120
  }
}

get_media

Get media details and a temporary download URL (valid for 1 hour).

Parameters

ParameterTypeRequiredDescription
idstring (UUID)YesMedia ID

Example

json
{
  "name": "get_media",
  "arguments": {
    "id": "550e8400-e29b-41d4-a716-446655440000"
  }
}

list_media

List media for a coverage item.

Parameters

ParameterTypeRequiredDescription
coverage_idstring (UUID)YesCoverage ID
include_archivedbooleanNoInclude archived media (default: false)

Example

json
{
  "name": "list_media",
  "arguments": {
    "coverage_id": "550e8400-e29b-41d4-a716-446655440000"
  }
}