Media
Upload images and video
OpenPost stores uploads in Cloudflare R2. Every upload is re-sniffed server-side with file-type, stripped of EXIF, and for images re-encoded via sharp. The browser-declared content type is never trusted.
413.Pick an upload mode
- Small files —
POST /v1/mediaas multipart form. - Remote URL —
POST /v1/media/from-urlwith a URL; we download, sniff, and store. - Large files — the multipart upload flow (
init→ part PUTs →complete).
Direct upload (small files)
/v1/mediaauth: Bearer tokenMultipart form upload. Field name: file. Max 1 GB video / 30 MB image.
curl -X POST https://api.openpost.so/v1/media \
-H "Authorization: Bearer $OP_KEY" \
-F "file=@launch.jpg"
{
"media": {
"id": "9f1e2d4c-...",
"org_id": "...",
"file_url": "<r2-object-key>",
"file_type": "image/jpeg",
"file_size": 2148304,
"created_at": "2026-04-16T10:27:04Z"
}
}
Upload from a URL
/v1/media/from-urlauth: Bearer tokenDownload a remote file, re-sniff, and persist in R2. 30-second fetch timeout.
| Field | Type | Description |
|---|---|---|
| url* | string | Public HTTPS URL to the file. |
curl -X POST https://api.openpost.so/v1/media/from-url \
-H "Authorization: Bearer $OP_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/hero.jpg" }'
Multipart upload (large files)
For video uploads near the 1 GB cap, use the chunked flow. R2 requires every part except the last to be at least 5 MiB, and supports a maximum of 10,000 parts per upload.
/v1/media/multipart/initauth: Bearer tokenRegister an upload. Body: { filename, type, size, totalParts }. Returns uploadId, key, partSize, trackingId.
/v1/media/multipart/partauth: Bearer tokenGet a presigned PUT URL for a single part and upload its bytes.
/v1/media/multipart/completeauth: Bearer tokenFinalize the upload after all parts are uploaded. We re-sniff the object and persist metadata.
Using media in a post
Reference the returned media id in the media_ids array when you create a post.