# Media

The 4 tools for media. Before an agent first makes one, it reads guide topic media.

## add_media

Add media to a space for people to review: a video (MP4, WebM, MOV), a sound (MP3, M4A, WAV, OGG, FLAC) or a picture, up to 100 MB, from a URL (a public file, downloaded into the space; a YouTube or Vimeo page plays from there) or base64 (small files only: a call stops at 4 MB). A local file of any size up to the limit uploads instead: curl -F file=@cut.mp4 -F title="Launch video" -H "Authorization: Bearer $KEY" https://tryartifacts.com/api/spaces/<space_id>/media (it returns the new item; then update_media for its words). People play it and comment at a moment of it (or on a spot of a picture); read_media gives you those comments by time. Give chapters and a transcript when you have them (a script you wrote). Read guide topic "media" first; check it with render_media.

Parameters:
- `space_id` (string, required)
- `title` (string, required): What it is: "Launch video — cut 2", "Podcast ep. 14", "Homepage hero, option B".
- `url` (string)
- `base64` (string): The file's bytes, for a small file (the whole call stops at 4 MB); upload larger local files with curl (see above).
- `mime` (string): With base64: "video/mp4", "audio/mpeg", "image/png"…
- `name` (string): With base64: the file's name, "cut-2.mp4".
- `description` (string): What people should look or listen for, and what you want back from them.
- `chapters` (object[]): The parts of a video or a sound, by where each starts: markers on its timeline and a list beside it. A whole list: it replaces the chapters there.
- `transcript` (object[]): What is said, line by line with when (a script you wrote, or a transcript you were given): the player's captions and a list people click to jump to a line. A whole list: it replaces the transcript.

## read_media

Media as it is now: its kind, file, length (once measured), description, chapters, and every comment with where it sits (at a time for a video or a sound, at x and y from 0 to 1 for a picture) and its conversation, in order through the media.

Parameters:
- `item_id` (string, required)

## update_media

Change media: title, description, chapters, transcript (each list replaces the one there; [] removes it), or a new file (url, or base64 with mime) — a new cut, its comments stay at their times.

Parameters:
- `item_id` (string, required)
- `title` (string)
- `description` (string)
- `chapters` (object[]): The parts of a video or a sound, by where each starts: markers on its timeline and a list beside it. A whole list: it replaces the chapters there.
- `transcript` (object[]): What is said, line by line with when (a script you wrote, or a transcript you were given): the player's captions and a list people click to jump to a line. A whole list: it replaces the transcript.
- `url` (string)
- `base64` (string)
- `mime` (string)
- `name` (string)

## render_media

See media as people do: a screenshot of the player (for a video, the frame at `at`), its comments' markers and its chapters and transcript — and it measures the length when not measured yet. Plus checks and errors the page hit.

Parameters:
- `item_id` (string, required)
- `at` (number | string): A video: the moment to show, seconds or "1:23" (default the start).
