Upload a media file
POST
/cms/media
const url = 'https://api.example.com/cms/media';const form = new FormData();form.append('file', 'file');form.append('content_id', '1');form.append('title', 'example');form.append('alternate_text', 'example');
const options = {method: 'POST', headers: {'API-Key': '<API-Key>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.example.com/cms/media \ --header 'API-Key: <API-Key>' \ --header 'Content-Type: multipart/form-data' \ --form file=@file \ --form content_id=1 \ --form title=example \ --form alternate_text=exampleUploads a new media file into the library. Optionally associate it with a content item by providing a content_id.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typemultipart/form-data
object
file
required
The file to upload
string format: binary
content_id
Optional ID of a content item to associate the media with
integer
title
Optional title for the media
string
alternate_text
Optional alternate text for the media
string
Responses
Section titled “Responses”Upload successful
Media typeapplication/json
object
id
ID of the created attachment
integer
Example generated
{ "id": 1}Bad request (missing file or invalid content_id)
Unauthorized
Forbidden