Start a media upload
POST
/api/media/uploadsGet a way to upload a local file for a post.
- Media in posts_create must be a public URL; use this when the user has the file on their device or you have the file itself.
- Returns
uploadPageUrl, an Ampost page where the user uploads files in a browser (in MCP, a client that supports URL elicitation asks the user to open it itself and leavesuploadPageUrlout), anduploadUrl+method+headersto PUT one file directly. - Both stop accepting files after 60 minutes.
- Then poll media_upload_status; when it is completed, its
filesaremedia[]items for posts_create. - Files that no post uses are deleted 24 hours after the upload was created (by the hourly cleanup).
- At most 20 upload links accept files at once (
RATE_LIMITEDwithRetry-Afterpast that), and each of them holds 200 MB of the plan's media storage while it accepts files (QUOTA_EXCEEDEDwithdetails.quotastoredMediaByteswhen that does not fit).
- Key scope
- media:write
- MCP tool
- media_upload_create
Headers
AuthorizationstringrequiredBearer <API key>. Create a key in the dashboard under API keys.
Body
fileNamestringFile name for the direct upload, e.g.
launch.mp4; it becomes the end of the file URL. Defaultfile. Files uploaded on the page keep their own names.
Over MCP
Show uploadPageUrl to the user and ask them to open it in a browser and upload their files. Or, if you can make HTTP requests and have the file, PUT its bytes to uploadUrl with the given headers plus x-content-type. Then call media_upload_status with the id every 3-5 seconds until the status is completed, failed or expired, and pass its files to posts_create as media.
Errors return { error: { code, message } }; every code is in Error codes.