Skip to content
On this page

Media

Templates use media objects (e.g. a JPG or PNG file) to display images (e.g. the template image or a default image in a picture element). You can use the API to upload these images and reference them when creating and updating templates.

Please take into account the best practices when implementing this API call.

Create a media object

To create a media object, use the POST http method to send a JSON payload to the following endpoint:

POST https://api.colorlab.io/2022-08/media/upload/:mediaType

Verification string for API Signature

The verification string to generate the signature is Store ID

Read here how to generate the X-Colorlab-Api-Signature header with this verification string.

The endpoint requires a parameter mediaType which is equal to templates, pictures or uploads. This parameter is used to indicate where the media object will be used.

The endpoint accepts a multipart/form-data body that accepts following keys:

  • file: the file object
  • Content-Type: the content type of the file

Example response payload

json
{
  "_id": "media-id-here",
  "meta": {
    "width": 1000, 
    "height": 1000
  },
  "mimetype": "image/jpeg",
  "name": "media-id-here",
  "originalname": "my-image.jpg",
  "size": 12345,
  "token": "38fa8a54-11ca-4ead-81fc-6cde515442d8"
}

The _id property can be used to reference media objects when creating and updating templates.