*Social Media Manual — [index](../MANUAL.md)*

# 5. Media

Images and videos are uploaded once and then referenced by `media_id` from any number of
drafts. Media belongs to the member who uploaded it.

## Uploading

`social_upload_media` with `base64` (the file contents), an optional `name` (used for the
stored object and shown in lists) and an optional `mime_type`. The file is sniffed; the sniffed
type always wins over `mime_type`. Reply: `media` with `media_id`, `mime_type`, `bytes`,
`width`, `height` (images) and `url`.

| accepted | notes |
|---|---|
| `image/jpeg`, `image/png`, `image/gif`, `image/webp` | dimensions are read from the file |
| `video/mp4`, `video/quicktime` (MOV) | stored as is; no live platform currently publishes video, so preview rejects it with `CAPABILITY_UNSUPPORTED` |

The server-wide size limit is 25 MB by default (`MEDIA_TOO_LARGE`). Each platform has a
smaller per-file limit and its own accepted types, enforced at preview and publish time, not at
upload (chapter 11): Instagram takes JPEG only, 8 MB; Facebook 10 MB; X 5 MB.

`MEDIA_INVALID` means the bytes are not valid base64 or not a recognisable file;
`MEDIA_UNSUPPORTED` means the sniffed type is not in the accepted list.

## Where the file lives

Uploaded media is stored at a public URL (`url` in the reply). The platforms fetch the file
from that URL when a post is published, so the URL must remain reachable until every post that
references the media has been delivered. Do not treat the URL as private.

## Listing and deleting

`social_list_media` returns the caller's media that has not been deleted. `social_delete_media`
removes the file. Any draft that still references the deleted `media_id` answers
`MEDIA_UNAVAILABLE` when edited, previewed or published, and a scheduled slot using such a
post fails at its time. Replace the media in the draft (`social_update_draft` with new
`media_ids`) before deleting, when the post still matters.

`MEDIA_NOT_FOUND` is a `media_id` that is not yours or never existed.

## Attaching media to a post

A draft carries up to 10 `media_ids`, in display order. Whether a platform accepts them is a
preview matter: one image, several images (`multi_image`) and video are separate capabilities,
and Instagram requires at least one image. Chapter 6 covers the checks.
