Uploading 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.

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

1
POST https://api.colorlab.io/v1/media?type={mediaType}

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

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

Example response payload

1
2
3
4
5
6
7
8
9
10
11
12
{
"_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.

Generating the signature

Create a verification string containing this data:
shopId

Now use your API secret to compute a sha256 HMAC signature. You can test the output using online generators like https://www.freeformatter.com/hmac-generator.html.

Use the resulting value in the X-Colorlab-Api-Signature header when sending requests to the above API endpoints.