Each way ends with media library ids, which go in a post’s
content[].media. A file already at a public link needs none of this: give the link to upload-media-from-url, or put it in the post. See Add media to posts.
ChatGPT: attach the file
In ChatGPT, the user attaches a photo, video or document to the message and asks for the post. ChatGPT passes the file toupload-media-file as file, filled in by ChatGPT itself: a private download link, the file’s id, and its name and type when ChatGPT has them. PostSyncer downloads the file and stores it like any upload, then answers one media item with its id.
- A file can be up to 500 MB, and the download has 75 seconds.
- The type rules are those of Upload a file. A file of another type is refused and nothing is stored.
- When the download fails, the error names the file, never the link. Most errors ask the user to attach it again: for example “ChatGPT’s link to spring-launch.mp4 didn’t work (HTTP 403). Attach the file again and retry.” A download that takes too long says to try again or attach a smaller file, and a file over 500 MB says it’s too big. A file that keeps taking too long goes through an upload link instead.
file_base64 (with filename) is only for a file whose bytes the AI has itself, such as one it read from disk. The AI never retypes a file it only sees in the chat: any attached file an app can’t pass as file, whatever its size, goes through an upload link.
Claude and other chat apps: open an upload link
1
Make the link
The AI calls
create-media-upload-link with workspace_id, and a folder_id if the files should go in a folder. Without MCP, it’s Create an upload link (POST /media/upload-links, media:create).2
Give the user the link
The answer’s
url is a page like https://app.postsyncer.com/upload/Hk3vQ9wLr2TnB7xYc4ZpM8dJf6sAe1Gu5oKi0WqXt2yNb7Rm. The AI gives it as a link to click and asks the user to say when the upload is done.3
The user drops the files
The page works on any device, with no PostSyncer sign-in. It names the workspace and folder, and how many more files the link takes and until when. The user drops files on it or taps Choose files. Each file shows its progress, and big files go in parts on their own. When every file is done, the page says: “Uploaded. Go back to your AI app and tell it the upload is done.”
4
Read the link
The AI calls
get-media-upload-link with the link’s id and uses the media ids it gets. See Read the link.Agents that run commands: send the file with curl
An agent that can run commands on the user’s computer makes the link the same way, then sends the file to the answer’supload_url itself. No API key goes with it: the link is enough.
A file up to 95 MB
One request, with the whole file asfile:
201:
422 (below), and a much bigger one can be cut off before PostSyncer reads it, with a 413 and no message. Either way, send the file in chunks.
A bigger file, in chunks
A file over 95 MB goes in chunks of up to 25 MB, one request each. Every request carries:
Each chunk but the last answers
200 with "status": "chunk_uploaded" and data (chunk_index, uploaded_chunks, total_chunks, progress in percent). The last answers 200 with "status": "upload_complete" and the media, as above. Sending a chunk again, after an answer got lost, is safe: a finished file answers with its media again, never a second copy.
This loop sends one file in 20 MB chunks, in bash or zsh. Put the link’s upload_url in UPLOAD_URL. Where there’s no uuidgen, cat /proc/sys/kernel/random/uuid makes a UUID on Linux. file reads the type from the bytes; if it says application/octet-stream, set MIME yourself, like video/mp4.
split names the chunks in order (.part.aa, .part.ab and on), so the loop sends them in order. The last answer printed holds the media, and the chunk files are then deleted. When a request fails, the loop stops, prints the answer and the chunk it stopped at, and keeps the chunk files: see Errors. To finish the file, send that chunk and the ones after it with the same file_id, total_chunks and their own chunk_index. Or delete the chunk files and run the loop again: that starts the file over with a new file_id.
The two addresses
Both come from the create answer. Use them as they are.{code} is the link’s code, the same in both. The page also reads GET https://postsyncer.com/api/media-upload-links/{code}, which answers what it shows: workspace_name, folder_name (or null), expires_at, max_files, files_uploaded and max_file_size (in bytes), or the same 404, 410 and 403 as an upload.
Read the link
When the user says the upload is done, read the link by itsid: get-media-upload-link in MCP, or Get an upload link (GET /media/upload-links/{upload_link_id}, media:read).
- Put each
media[].idin a post’scontent[].media. medialists the files the link took that are still in the library, in the order they arrived.files_uploadedcounts every file the link took, including any deleted from the library since, so it can be more than the items inmedia.- An empty
mediawithfiles_uploadedat0means nothing arrived yet: ask the user whether the upload finished. - This answer never has
urlorupload_url. Only the create answer gives them, so keep them until the upload is done. A lost link can’t be found again: make a new one.
Limits
An expired or full link keeps the files it took: they stay in the library and in the link’s
media.
Errors
Every refusal has amessage in plain words, which the page shows as it is. A refusal about the file or a field (422 with errors) has the same words under errors.file or the field’s name. Nothing is kept from a refused file.
Related
Create an upload link
POST /media/upload-links and its answer.Add media to posts
Links, uploads and library ids on posts.