Skip to main content

Create a Media

This endpoint creates a Media

info

The allowed types for this endpoint are:

  • vimeo for video upload. The endpoint must receive the url of the video after the video is fully uploaded to vimeo servers by the client.

  • url for url fetch. The endpoint retrieve metadata associated with the given url and create a preview.

  • share for sharing a community object (Post, Discussion or Status). The community object can't contain a media of type share.

  • embed for external objects. The endpoint create an association with an external object using Embed format.

If embed parameter are set and no Embed with embed_type - embed_id are in the community database this endpoint create an Embed object with the metadata passed.

info

This operation requires authentication

HTTP Request

POST /api/v2/media/

Parameters

NameInTypeRequiredDescription
» typebodystringtrueThe media type
» urlbodystring(uri)if type is urlRequired for type url
» shared_objectbodyintegerif type is shareRequired for type share
» embedbodyEmbedif type is embedThe embed object

Enumerated Values

ParameterValueDescription
» typevimeoVimeo video media type
» typeurlUrl media type (used for any webpages, youtube or vimeo public videos)
» typeembedExternal resource

Example Body Parameters

{
"type": "string",
"url": "string(uri)",
"embed": {Embed}
}

Example Request

const inputBody = '{
"type": "url",
"url": "https://example.com",
"embed": null
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization': 'Bearer {access_token}'
};

fetch('/api/v2/media/',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

Responses

StatusMeaningDescriptionSchema
201CreatedResponse status codeMedia

Example responses

{
"id": "integer",
"added_at": "string",
"type": "string",
"title": "string",
"description": "string",
"url": "string(uri)",
"image": "string",
"image_width": "integer",
"image_height": "integer",
"order": "integer",
"embed": {Embed}
}