Pages in API reference
Media Upload
Media hosted at a public URL goes straight into media. To upload files instead, send POST /api/posts as multipart/form-data: a data part with the usual JSON body, plus one part per file. A media item points at its file with { "file": "<part name>" }; Ampost reads the type, size, width, height and duration from the file's bytes. A file whose content is not its declared type gets VALIDATION_FAILED on media[i].file. Images are re-saved without metadata (EXIF, GPS). Every file part must be referenced exactly once.
Accepted types: image/jpeg, image/png, image/webp, video/mp4, video/quicktime, video/webm. The whole multipart request must be at most 4 MB, files and data together; a larger one gets 413 PAYLOAD_TOO_LARGE (over 4.5 MB, a plain-text 413 from the hosting edge). That fits images, not most videos: send larger files, up to 200 MB each, with an upload link (below) or as a public URL. Files Ampost stores or converts are at most 200 MB each: uploads, the URL media of a scheduled post (copied to Ampost storage when the post is created) and media it converts for a platform. A larger file goes only as a public URL in a post that is not scheduled and that the platform takes without conversion, up to the platform's own limit (media.maxVideoSizeBytes in GET /api/platforms, e.g. TikTok 4 GB, LinkedIn 500 MB, X 512 MB). Platforms that need media metadata list it in media.requiredFields of GET /api/platforms; TikTok videos, for example, need width, height and duration.
curl -X POST https://api.ampost.io/api/posts \
-H "Authorization: Bearer amp_live_YOUR_KEY" \
-F 'data={
"targets": [
{
"platforms": [
"instagram"
]
}
],
"text": "Uploaded straight from my laptop",
"media": [
{
"file": "photo",
"altText": "The new dashboard on a laptop"
}
]
}' \
-F "photo=@launch.jpg"Upload links for agents and apps
When the file is on the user's device, create a media upload. Show its uploadPageUrl to the user: an Ampost page where they pick up to 35 files in a browser. A client that has the file can instead PUT it to uploadUrl with the returned headers plus x-content-type. Both stop accepting files after 60 minutes.
Poll the upload every 3–5 seconds until it is completed, failed or expired. Each item in files is a media item; pass it to POST /api/posts unchanged. Ampost checks each file's bytes and reads width, height and duration from them; images are re-saved without metadata, so their URL differs from the one uploaded to. A direct upload whose content is not the type it was sent as ends failed, with the reason in error.
curl -X PUT "$UPLOAD_URL" \
-H "authorization: Bearer vercel_blob_client_..." \
-H "x-api-version: 12" -H "x-vercel-blob-access: public" \
-H "x-add-random-suffix: 0" \
-H "x-content-type: video/mp4" \
--data-binary @launch.mp4Files that no post uses are deleted 24 hours after the upload was created, by the hourly cleanup. Files used in a post stay with the post. 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).
How long Ampost keeps media
Scheduled posts copy URL media to Ampost storage when they are created, so the source URL only has to work at that moment; drafts and posts published now use the URL as given (except TikTok photos, which Ampost copies because TikTok takes photos only from Ampost's domain). Media in Ampost storage is deleted when its post is discarded, and 7 days after the post is published or has failed; a retry after that needs new media. The published copy on the platform stays.