Skip to main content

Create a Media

This endpoint creates a Media

info

The allowed types for this endpoint are:

  • image for image upload. The endpoint retrieve the image associated with the given url and creates an image media type.

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

  • share for sharing a community contribute object (Post, Discussion or Status) or a community Event object. The community object can't contain a media of type share. The object should be pass as an id in the following parameter:

    • shared_object: if the object is a contribute;
    • event_object: if the object is an event.
  • 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 if you are sharing a content (post, discussion, status)
» event_objectbodyintegerif type is shareRequired for type share if you are sharing an event
» embedbodyEmbedif type is embedThe embed object

Enumerated Values

ParameterValueDescription
» typeimageUrl media type
» typeurlUrl media type (used for any webpages, youtube etc.)
» 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