Skip to content

create_media_upload_url

Authorizes one image or video upload to PostMCP storage and returns a short-lived uploadUrl, the publicUrl the file will live at, its storage key and expiresIn in seconds. The file does not exist yet: PUT the raw bytes to uploadUrl with the returned headers, then call complete_media_upload in the same workspace. If the file is already at a public URL, use import_media_from_url instead.

Access
write
Category
Media
Endpoint
POST/api/tools/create_media_upload_url
On this page
  1. Parameters
  2. Example request
  3. Response
  4. Credit cost
  5. Errors

Parameters

fileName
stringrequired
Original filename including its extension, e.g. launch.png or demo.mp4.
contentType
stringrequired
The file’s MIME type, e.g. image/png or video/mp4. Send the same Content-Type on the storage PUT. PNG, JPEG, GIF, WebP, AVIF, HEIC, MP4, MOV, WebM and M4V are accepted.
fileSize
integerrequired
File size in bytes. Storage takes images up to 25 MiB and videos up to 512 MiB; each network has its own, often lower, publishing limit.
workspaceId
string
Workspace to act on, from list_workspaces. Omit to use the default workspace on the key.

Example request

curl -X POST "https://mcp.postmcpai.com/api/tools/create_media_upload_url" \
  -H "Content-Type: application/json" \
  -H "x-api-key: $POSTMCPAI_API_KEY" \
  -d '{
    "fileName": "launch.png",
    "contentType": "image/png",
    "fileSize": 245760
  }'

Response

Where to send the bytes and where they will be served from. uploaded is false until your PUT succeeds, and the URL expires after expiresIn seconds (normally 900).

200 · application/json
{
  "success": true,
  "uploadUrl": "https://<bucket>.r2.cloudflarestorage.com/u66a1f0c2_1763884800000_launch.png?X-Amz-Signature=…",
  "publicUrl": "https://cdn.postmcpai.com/u66a1f0c2_1763884800000_launch.png",
  "key": "u66a1f0c2_1763884800000_launch.png",
  "expiresIn": 900,
  "method": "PUT",
  "headers": {
    "Content-Type": "image/png"
  },
  "uploaded": false,
  "nextStep": "PUT the raw file bytes to uploadUrl using the returned headers (no PostMCP API key). After the PUT succeeds, call complete_media_upload with url=publicUrl, key, the original file metadata and the same workspaceId. Do not use publicUrl in a post until the upload succeeds."
}

Credit cost

No credits. Uploading stores a file and publishes nothing; credits are spent when a post that uses it is delivered.

Errors

Over REST these come back as a 500 with the message in error; over MCP as a tool error. See Errors for the shapes.

fileName is required. · contentType is required. · fileSize must be a positive integer in bytes.

A required field is missing, or fileSize is not a whole number of bytes above zero.

Fix: Send all three fields, with fileSize as an integer byte count.

Unsupported file type (…)

contentType is not one of the accepted image or video types.

Fix: Convert the file to PNG, JPEG, GIF, WebP, AVIF, HEIC, MP4, MOV, WebM or M4V.

That video is …MB — the limit is …MB.

fileSize is over the storage ceiling: 25 MiB for an image, 512 MiB for a video.

Fix: Compress or trim the file, then request a new upload URL.