Upload a picture or video
Try itAdds a picture or video to the site's library, sent as base64 in data_base64. Pictures: PNG, JPEG, WebP, GIF or SVG (no scripts), up to 8 MB. Videos: MP4 or WebM, up to 30 MB in the library, with an optional still (poster_base64, a JPEG/PNG/WebP) shown before it plays and instead of it for reduced motion. Use the url it answers in sections, posts and covers (a video's in a Video section with source "file", or a Big banner's video). The REST body may be up to 31 MiB (so about 23 MB of video once base64'd); over MCP the whole message is capped at 256 KiB, so send bigger files through REST.
/api/v1/sites/{site_id}/mediaAuthentication
An API key as Authorization: Bearer or x-api-key. It needs the media:write scope — upload pictures.
Parameters
Named placeholders go in the path; the rest in a JSON body.
site_idstringPath · required- The site's id.1 to 100 characters
filenamestringBody · required- e.g. storefront.jpg1 to 200 characters
content_typestringBody · required- One of: image/png, image/jpeg, image/webp, image/gif, image/svg+xml, video/mp4, video/webm
data_base64stringBody · required- The file's bytes, base64.4 to 32505856 characters
poster_base64stringBody · optional- Videos only: a still picture (JPEG, PNG or WebP), base64.4 to 11534336 characters
poster_content_typestringBody · optional- The still's type (default image/jpeg).One of: image/jpeg, image/png, image/webp
altstringBody · optional- What the picture shows, for screen readers and Google.At most 200 characters
widthintegerBody · optional- 1 to 50000
heightintegerBody · optional- 1 to 50000
Response
201 with JSON on success (schema on the right). Errors use the standard envelope; a retry with the same Idempotency-Key gets the first answer back (how retries work).
curl -X POST 'https://websites.workflowcorp.com/api/v1/sites/SITE_ID/media' \
-H "Authorization: Bearer $WEBSITEBUDDY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"filename":"dot.png","content_type":"image/png","data_base64":"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==","alt":"A dot"}'{
"site_id": "SITE_ID",
"filename": "dot.png",
"content_type": "image/png",
"data_base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
"alt": "A dot"
}{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"filename": {
"type": "string"
},
"url": {
"type": "string",
"description": "The file's address on this server (/media/…) — use a picture's in sections, posts and covers, a video's in a Video section's `file` or a Big banner's `video`."
},
"absolute_url": {
"type": "string"
},
"content_type": {
"type": "string"
},
"bytes": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"width": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"height": {
"anyOf": [
{
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
{
"type": "null"
}
]
},
"alt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"poster_url": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "A video's still (/media/…), shown before it plays; null for pictures."
},
"site_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Null = the account's shared library."
},
"is_sample": {
"type": "boolean"
},
"created_at": {
"type": "string"
}
},
"required": [
"id",
"filename",
"url",
"absolute_url",
"content_type",
"bytes",
"width",
"height",
"alt",
"poster_url",
"site_id",
"is_sample",
"created_at"
],
"additionalProperties": false
}