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.
- Alcance
media_library:write- Permiso
- Editar en el módulo
- Tool del MCP
media_library_uploads_createEn la superficie completa; en la compacta,mb_execute_operationconid: "media_library.uploads.create".
Costo declarado: hasta 4 lecturas y 1 escrituras por llamada (cuentan en el cupo diario).
Parámetros
filenamestringcuerpoThe file's name, with its extension.
content_typeenumcuerpoThe 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
sizeintegercuerpoThe exact size in bytes of the file to upload (up to 1 GB; a document up to 100 MB).
folder_idstring | nullcuerpoopcionalpurposeenumcuerpoopcionalfile (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 · Por defecto: "file"
Respuesta
upload_urlstringmethod"PUT"headersobjectstorage_pathstringexpires_atnumbermax_sizenumberErrores
Ejemplo
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
}'Probar con tu API key de prueba
Con una API key de prueba el pedido va siempre a tu organización de práctica: datos de ejemplo que puedes 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
}'