Pages in API reference

Media

Start a media upload

POST/api/media/uploads

Get 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 leaves uploadPageUrl out), and uploadUrl + method + headers to PUT one file directly.
  • Both stop accepting files after 60 minutes.
  • Then poll media_upload_status; when it is completed, its files are media[] 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_LIMITED with Retry-After past that), and each of them holds 200 MB of the plan's media storage while it accepts files (QUOTA_EXCEEDED with details.quota storedMediaBytes when that does not fit).
Key scope
media:write
MCP tool
media_upload_create

Headers

  • Authorizationstringrequired

    Bearer <API key>. Create a key in the dashboard under API keys.

Body

  • fileNamestring

    File name for the direct upload, e.g. launch.mp4; it becomes the end of the file URL. Default file. 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.