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.
- Escopo
media_library:write- Permissão
- Editar no módulo
- Tool do MCP
media_library_uploads_createNa superfície completa; na compacta,mb_execute_operationcomid: "media_library.uploads.create".
Custo declarado: até 4 leituras e 1 escritas por chamada (contam na cota diária).
Parâmetros
filenamestringcorpoThe file's name, with its extension.
content_typeenumcorpoThe 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).
Valores: 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
sizeintegercorpoThe exact size in bytes of the file to upload (up to 1 GB; a document up to 100 MB).
folder_idstring | nullcorpoopcionalpurposeenumcorpoopcionalfile (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).
Valores: file, video_thumbnail, document_thumbnail · Padrão: "file"
Resposta
upload_urlstringmethod"PUT"headersobjectstorage_pathstringexpires_atnumbermax_sizenumberErros
Exemplo
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
}'Testar com a sua API key de teste
Com uma API key de teste o pedido vai sempre para a sua organização de prática: dados de exemplo que você pode reiniciar.
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
}'