Upload and gallery
Presigned uploads, gallery listing, and deletes.
Media lives in the workspace gallery. Needs Bearer + X-Workspace-Id.
Limits
| Kind | Max size | Types |
|---|---|---|
| Images | 8MB | jpeg, png, gif, webp |
| Video | 256MB | mp4, quicktime, webm |
Upload flow
- Ask for a presigned URL
- Upload bytes to that URL
- Confirm the upload so it appears in the gallery
1. Get an upload URL
POST /api/media/upload-url
curl -X POST https://api.dunsocial.com/api/media/upload-url \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "X-Workspace-Id: YOUR_WORKSPACE_ID" \
-H "Content-Type: application/json" \
-d '{
"filename": "hero.jpg",
"mimeType": "image/jpeg",
"fileSize": 245760
}'Response: { uploadUrl, storageKey, expiresAt }.
2. PUT the file
PUT the raw file to uploadUrl with the correct Content-Type.
3. Complete
POST /api/media/complete
Body: { storageKey, originalFilename, mimeType, fileSize, width?, height?, duration?, altText? }
Returns 201 with the asset and a previewUrl.
List gallery
| Method | Path | Notes |
|---|---|---|
GET |
/api/media |
Paginated assets + preview URLs |
GET |
/api/media/gallery |
Assets with usage status |
Get and batch
| Method | Path |
|---|---|
GET |
/api/media/:id |
POST |
/api/media/batch — { ids? , storageKeys? } |
GET |
/api/media/:id/relationships — posts/drafts using it + canDelete |
Alt text
PATCH /api/media/:id/alt-text with { "altText": "..." }
Validate for a platform
GET /api/media/validate?mediaAssetId=&platform= → { valid, issues[] }
Delete
DELETE /api/media/:id
Optional body: { cleanupDrafts?, forceDeleteScheduled? }
Fails with 400 if the asset is used in a published post (or scheduled without forceDeleteScheduled).