Uploading media
Add an image, video or PDF to the media library from a public link, and put it on posts in the same call.
https://antwork.io/api/v1/mediaScopemediaRequest
POST /api/v1/media with {"url": "https://..."} fetches the file and stores it in the workspace's media library. The link must be a public http(s) address on the default port; every redirect is checked again. The type is read from the file's bytes, never from its name or the host's headers: PNG, JPEG, GIF, WebP and AVIF images up to 10 MB, MP4, MOV and WebM video and PDF up to 100 MB. With more than one workspace, send workspaceId. Needs the media scope. Send an Idempotency-Key: a retried request stores nothing twice.
curl -X POST https://antwork.io/api/v1/media \
-H "Authorization: Bearer $ANTWORK_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"url": "https://cdn.example.com/launch.png",
"attachToPostIds": [
"pQ7x..."
]
}'attachToPostIds (at most 20 of your posts in that workspace) adds the file to the end of each post's media, as the MCP add_media tool does. A published post is listed in notAttached and left alone; one that is not yours answers 404 before anything is fetched. PUT /api/v1/posts/{id}/media sets a post's exact list afterwards.
{"urls": [...]} takes up to 10 links in one call, fetched in order, each exactly as url is (a link stored in the last 24 hours is reused, and only links that store nothing count toward the limit). The answer lists every link in results. The files are attached to attachToPostIds only when every link stored one: otherwise nothing is attached, the first failure's status and code lead, and storedMediaIds names the files already in the library. A host that refuses one link with 401 or 403 is not asked for the others.
Response
{
"object": "media",
"id": "m_8f2...",
"workspaceId": "ws_...",
"url": "https://firebasestorage.googleapis.com/v0/b/.../o/workspaces%2Fws_...%2Fmedia%2Fupload-...png?alt=media&token=...",
"name": "launch.png",
"type": "image",
"size": 482113,
"durationSec": null,
"uploadedAt": "2026-10-22T10:00:00.000Z",
"attached": ["pQ7x..."],
"notAttached": []
}201 with the library item. Its url is what a post's media takes. A video's durationSec is filled when its length can be read from the file, and is null otherwise; an unknown length never blocks a publish.
400 with the reason in code, the same codes the MCP add_media tool gives: remote_http_error (the host answered something other than the file), not_a_file (a web page, such as a chat share link), unsupported_type, too_large, empty_file, blocked_url (not a public address), fetch_timeout, fetch_failed, private_link (a Google Drive, Docs, Slides, Dropbox or OneDrive file not shared as 'Anyone with the link'), folder_link and design_link (a Canva or InVideo page: export the file and upload it). A Google Drive, Docs, Slides, Dropbox or OneDrive share link works as it is: Antwork fetches the file behind it, a Doc or Slides deck as a PDF. Each key can fetch 20 links every 10 minutes; past that the answer is 429 url_ingest_rate_limited with Retry-After.Uploading a file you hold
POST /api/v1/media with {"upload": {"filename": "demo.mp4", "mimeType": "video/mp4", "size": 48213044}} answers 201 with a one-time uploadUrl. Send the file's bytes to it in one PUT within 10 minutes; a long upload may finish after that. That request stores the file, adds it to the library and appends it to attachToPostIds, and its JSON answer carries the mediaId and url. Images up to 10 MB, video and PDF up to 1 GB. The address works once, and the bytes go straight to the upload endpoint the MCP add_media tool uses. An unsupported mimeType is refused with unsupported_type, a size over the limit with too_large.
{
"object": "media_upload",
"uploadUrl": "https://api.antwork.io/uploads/kQ3...",
"method": "PUT",
"expiresAt": "2026-10-22T10:10:00.000Z",
"attachesTo": ["pQ7x..."],
"maxBytes": 1073741824
}curl -sS -X PUT --data-binary @demo.mp4 "$UPLOAD_URL"
# → {"success": true, "mediaId": "m_8f2...", "url": "https://firebasestorage...", "type": "video",
# "attached": ["pQ7x..."], "notAttached": [], ...}Something look wrong? Tell us which.