Skip to main content

Uploading Media with the API

Updated

Uploading a file takes three requests: start an upload, send the file to storage, then complete the upload. The completed upload returns a media ID you can attach to a post.

You need an API key and a workspace ID. To upload a file from your computer in one command, use maeve media:upload in the command line instead.

1. POST /v1/workspaces/{workspaceId}/media/upload
2. PUT  <uploadUrl>
3. POST /v1/workspaces/{workspaceId}/media/upload/{sessionId}/complete

Start the Upload

curl --fail-with-body "https://api.maevesocial.com/v1/workspaces/$WORKSPACE_ID/media/upload" \
  -H "Authorization: Bearer $MAEVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "photo.png",
    "contentType": "image/png",
    "fileSize": 102400
  }'

All three fields are required. fileSize is in bytes, and filename can contain up to 255 characters.

{
  "data": {
    "sessionId": "session-uuid",
    "uploadUrl": "https://storage.example.com/presigned-url",
    "expiresIn": 3600
  },
  "meta": null
}
File typecontentTypeMaximum size
JPEGimage/jpeg50 MB
PNGimage/png50 MB
GIFimage/gif50 MB
WebPimage/webp50 MB
AVIFimage/avif50 MB
MP4video/mp42 GB
QuickTimevideo/quicktime2 GB
PDF, Word, and PowerPointapplication/pdf and the Word and PowerPoint types100 MB

Send the File

Send the file's bytes to uploadUrl before it expires. This request goes directly to storage, so it does not use your API key:

curl --fail-with-body -X PUT "$UPLOAD_URL" \
  -H "Content-Type: image/png" \
  --data-binary @photo.png

Use the same content type you sent when starting the upload.

Complete the Upload

curl --fail-with-body "https://api.maevesocial.com/v1/workspaces/$WORKSPACE_ID/media/upload/$SESSION_ID/complete" \
  -H "Authorization: Bearer $MAEVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "width": 800, "height": 600, "folderId": "folder-uuid" }'

Every field in this request is optional:

FieldDescription
widthWidth in pixels
heightHeight in pixels
durationSecondsVideo length in seconds
thumbnailBase64A thumbnail image, Base64-encoded
folderIdThe media folder to place the file in
{
  "data": {
    "id": "media-uuid",
    "url": "https://media.maevesocial.com/...",
    "thumbnailUrl": "https://media.maevesocial.com/.../thumb.jpg",
    "folderId": "folder-uuid",
    "width": 800,
    "height": 600,
    "durationSeconds": null
  },
  "meta": null
}

Save the id. The file now appears in the workspace's Media room.

Attach the File to a Post

Reference the media ID in contentMedia when you create or update a post:

{
  "contentMedia": [
    { "mediaId": "media-uuid", "order": 0 }
  ]
}

Instagram and LinkedIn posts accept up to 20 files. Other platforms accept 10.

List Your Media

curl --fail-with-body "https://api.maevesocial.com/v1/workspaces/$WORKSPACE_ID/media?type=image&limit=20" \
  -H "Authorization: Bearer $MAEVE_API_KEY"
ParameterDefaultOptions
typeAllimage, video, or gif
searchNoneText to find in filenames
folderIdNoneA folder ID
rootOnlyNonetrue for files outside any folder
labelIdsNoneComma-separated media label IDs
isUnlabeledNonetrue or false
isFavoriteNonetrue or false
isUsedNonetrue or false
isUnusedNonetrue or false
stateactiveactive, deleted, or all
sortBycreatedAtcreatedAt, filename, or fileSize
orderdescasc or desc
limit50From 1 to 100
cursorNoneThe previous response's nextCursor

The media list uses cursor pagination. While meta.hasMore is true, pass meta.nextCursor as cursor and keep the same filters.

Questions

Why are there three requests?

The file goes straight to storage instead of through the API. You start an upload to get a URL, send the file there, then complete the upload to add it to your library.

Which file types can I upload?

JPEG, PNG, GIF, WebP, and AVIF images, MP4 and QuickTime videos, and PDF, Word, and PowerPoint documents.

How large can a file be?

Images up to 50 MB, videos up to 2 GB, and PDF, Word, and PowerPoint documents up to 100 MB.

Does the upload request need my API key?

The start and complete requests do. The PUT request to uploadUrl goes directly to storage and does not.

How do I attach an uploaded file to a post?

Add its media ID to the post's contentMedia array when you create or update the post.

How many files can a post have?

Up to 20 for Instagram and LinkedIn, and 10 for other platforms.

Is there an easier way to upload a local file?

Yes. The command line uploads a file in one step with maeve media:upload <file> --workspace <workspaceId>.