Get a signed URL to upload a file
media_library.uploads.create
First step to add an image, a video or a document to the media library through the API (the API does not take multipart uploads; a file of up to 750 KB can skip this step: media_library.items.create with content_base64). Send filename, content_type (images: image/jpeg, image/png, image/webp or image/gif; videos: video/mp4, video/quicktime or video/webm; documents, for LinkedIn document posts: application/pdf, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/msword or application/vnd.openxmlformats-officedocument.wordprocessingml.document), the exact size in bytes (up to 1 GB; a document up to 100 MB) and optionally folder_id; it checks the storage quota and returns upload_url, the headers to send, storage_path and expires_at (10 minutes to start the upload). Then PUT the raw bytes to upload_url from a server with exactly those headers and exactly size bytes (the URL is bound to that size and content type: anything else is rejected), and register the file with media_library.items.create passing storage_path: until then it is not in the library. The bytes count toward the storage quota from the moment the URL is issued (an upload that never happens is released by the storage recount, which runs every 6 hours). For a video thumbnail use purpose video_thumbnail, and for a document's first page purpose document_thumbnail (both JPEG, PNG or WebP up to 2 MB; they count toward the quota like any file), and pass its storage_path as thumbnail_storage_path. Each call issues a new URL (not idempotent). Errors: unsupported_media_type, file_too_large, limit_reached (details.resource storage: the storage is full), media_folder_not_found, invalid_input (a folder_id that is a reserved storage folder name: thumbnails, booking_avatar). Needs full access to the Media Library.
- Scope
media_library:write- Permission
- Edit in the module
- MCP tool
media_library_uploads_createOn the full surface; on the compact one,mb_execute_operationwithid: "media_library.uploads.create".
Declared cost: up to 4 reads and 1 writes per call (they count against the daily quota).
Parameters
filenamestringbodyThe file's name, with its extension.
content_typeenumbodyThe file's type: image/jpeg, image/png, image/webp, image/gif, video/mp4, video/quicktime, video/webm, application/pdf, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document (the library takes images, videos and documents: PDF, PowerPoint and Word).
Values: image/jpeg, image/png, image/webp, image/gif, video/mp4, video/quicktime, video/webm, application/pdf, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document
sizeintegerbodyThe exact size in bytes of the file to upload (up to 1 GB; a document up to 100 MB).
folder_idstring | nullbodyoptionalpurposeenumbodyoptionalfile (default): an image, a video or a document; video_thumbnail: a video's thumbnail; document_thumbnail: a document's first page (both JPEG, PNG or WebP up to 2 MB).
Values: file, video_thumbnail, document_thumbnail · Default: "file"
Response
upload_urlstringmethod"PUT"headersobjectstorage_pathstringexpires_atnumbermax_sizenumberErrors
Example
curl -X POST "https://api.mb-suite.com/v1/media-library/uploads" \
-H "Authorization: Bearer $MB_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"filename": "FILENAME",
"content_type": "image/jpeg",
"size": 1
}'Try it with your test API key
With a test API key the request always goes to your practice organization: example data you can reset.
curl -X POST "https://api.mb-suite.com/v1/media-library/uploads" \
-H "Authorization: Bearer $MB_TEST_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"filename": "FILENAME",
"content_type": "image/jpeg",
"size": 1
}'