POST

Upload an asset

An upload link for one file; PUT the bytes to it.

View as Markdown
POSThttps://api.muzekit.com/v1/assets/uploads
curl https://api.muzekit.com/v1/assets/uploads \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "logo.png", "type": "image/png", "brand": true }'

curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/png" --data-binary @logo.png
Field
name, typeThe file name and MIME type
sizeOptional; refused early when over the limit
kindOptional: image, video, audio, font (read from type otherwise)
familyFonts: the family name in the font list
userUpload into this end user's library
brandAdd to the editor's brand kit (not with user)

The link works once, for 15 minutes. The PUT answers with the file's id, url, width and height; Muzekit reads the type from the bytes and refuses files that don't match, are over the limit, or are unsafe SVGs.

Without user or brand, the file goes into the workspace library. Uploading the same file again to the same library gives back the asset it already has.

Examples

Upload into an end user's library

Send user to put the file in that end user's own uploads. They see it every time they open the editor, and other users don't.

UPLOAD_URL=$(curl -s https://api.muzekit.com/v1/assets/uploads \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "photo.jpg", "type": "image/jpeg", "user": "usr_8fK2mQ1xZpR" }' \
  | jq -r .upload_url)

curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/jpeg" --data-binary @photo.jpg

The PUT answers with the stored file:

JSON
{
  "url": "https://storage.muzekit.com/…/photo.jpg",
  "type": "image/jpeg",
  "size": 482113,
  "width": 1600,
  "height": 1200,
  "id": "ast_dQC3Z8RgqAH"
}

Add a font to the brand kit

Send "brand": true and the family name the font list should show. Upload one file per weight, each with the same family.

UPLOAD_URL=$(curl -s https://api.muzekit.com/v1/assets/uploads \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme-Bold.woff2",
    "type": "font/woff2",
    "family": "Acme",
    "brand": true
  }' \
  | jq -r .upload_url)

curl -X PUT "$UPLOAD_URL" -H "Content-Type: font/woff2" --data-binary @Acme-Bold.woff2

Upload a video

Videos are uploaded the same way. Send size too, so a file over the video limit (413 file_too_large) or over your plan's storage (402 storage_full) is refused before you send the bytes.

SIZE=$(wc -c < promo.mp4 | tr -d ' ')

UPLOAD_URL=$(curl -s https://api.muzekit.com/v1/assets/uploads \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d "{ \"name\": \"promo.mp4\", \"type\": \"video/mp4\", \"size\": $SIZE }" \
  | jq -r .upload_url)

curl -X PUT "$UPLOAD_URL" -H "Content-Type: video/mp4" --data-binary @promo.mp4

Copy a file from your own storage

When the file already lives at a URL (your bucket or CDN), download it on your server and PUT the bytes. Muzekit keeps its own copy, so the editor never loads your URL.

UPLOAD_URL=$(curl -s https://api.muzekit.com/v1/assets/uploads \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "banner.png", "type": "image/png", "user": "usr_8fK2mQ1xZpR" }' \
  | jq -r .upload_url)

curl -s https://cdn.example.com/banner.png \
  | curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/png" --data-binary @-

Response

JSON
{
  "object": "upload",
  "upload_url": "https://api.muzekit.com/runtime/uploads/…",
  "url": "https://storage.muzekit.com/…/logo.png",
  "kind": "image",
  "expires_in": 900
}