> ## Documentation Index
> Fetch the complete documentation index at: https://docs.posttu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Media

> Upload media assets, track their processing state, and attach them to posts.

The Media API handles the lifecycle of images and videos used in your posts: requesting a direct-upload URL, verifying and probing the uploaded file, and tracking when it is ready to attach.

## Media lifecycle

```mermaid theme={null}
sequenceDiagram
    participant C as Client
    participant API as Posttu API
    participant S as Storage
    C->>API: POST /media/upload (filename, contentType, bytes)
    API->>C: mediaId + presigned PUT URL
    C->>S: PUT file bytes
    C->>API: POST /media/finalize (mediaIds)
    API->>S: Verify + probe dimensions/duration
    API->>C: status LIVE + metadata
    C->>API: POST /posts/create (media: [mediaId])
```

## Media statuses

| Status | Meaning |
| - | - |
| `PENDING` | Upload URL issued, file not yet confirmed in storage |
| `PROCESSING` | Reserved for server-side processing — treat as not ready |
| `LIVE` | Verified in storage, probed, ready to attach to posts |
| `FAILED` | Verification or probing failed |
| `DELETED` | Removed, no longer accessible |

## Endpoints

| Method | Endpoint | Description | Scope |
| - | - | - | - |
| `POST` | `/api/media/upload` | Get a presigned URL for direct upload | `posts:write` |
| `POST` | `/api/v1/media/finalize` | Verify, probe, and mark uploads ready | `posts:write` |
| `GET` | `/api/media/{id}/status` | Check whether an upload is ready | `posts:read` |

## Limits and notes

* Presigned upload URLs expire after **1 hour**; request a new one if the upload is interrupted.
* Maximum file size for a single direct upload is **\~5 GB** (`maxSize: 5242880000` in the upload response).
* Finalize accepts up to **50 media IDs** per call.
* When a post is deleted or rejected, media attached only to that post is cleaned up automatically.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.