Kodmyran Commerce Developer
  • API Documentation
    • API Overview
    • Integration API
    • Headless API
    • Report API
    • Service API
    • Entity API
    • Media API
  • Frontend
  • Platform
    • A/B Testing
    • KQL
    • Wolfpack
  • kodmyran.se

Media API

Download as PDF

  • Introduction
  • Uploads and content types
  • Security
  • Response

Introduction

The media API is used to upload, delete or retrieve file/directory data for the files in the Kodmyran Commerce upload area. It is identical to using the SFTP interface or the GUI upload dialogue.

API Endpoint:

https://testaccount.kodmyran.io/admin/api/media

Append the filename to the end-point above and make a GET, PUT or DELETE request.

  • Use GET to return information about the file/directory such as its type, size etc
  • Use PUT to upload a new file or replace an existing one
  • Use DELETE to remove a file

Directories are created automatically by the API and need not be created before upload. Unlike the SFTP interface the system will refuse to remove files that are in use by a product.

Uploads and content types

The body of a PUT request is the file itself, not a JSON document. The content-type header must therefore be set to the media type of the file you are uploading, and only the types below are accepted:

Content-type File extension
image/jpeg or image/jpg jpg or jpeg
image/png png
image/gif gif
image/webp (version >= 7.12.3) webp
application/pdf pdf
image/svg+xml svg

Before the file is stored the platform verifies that the content-type you declared, the actual contents of the file and the file name extension all agree with each other. An upload where any of the three disagree is denied, as is a file whose contents are not one of the supported types.

WebP is accepted as a source format from version 7.12.3 and onwards. A WebP image is converted to JPEG automatically when it is presented to a visitor whose browser does not support WebP. Conversion in the other direction, from an uploaded JPEG to WebP at presentation time, has been supported for a long time and does not require you to upload WebP at all.

A GET or DELETE request carries no body and needs no content-type header. The response to a GET is JSON as usual, it is only the upload direction that uses the media type of the file.

Security

In order to be able to use this API you must provide an API key as described in the overview, the authenticated user must also possess the Remote call: Read (for GET requests) or Remote call: Write (for PUT and DELETE requests) permissions.

Response

The system will respond with a 200 OK and standard response body for a successful DELETE or PUT operation. For a successful GET the system will respond with a JSON structure with information about the file/directory.

Successful response for DELETE or PUT:

{
                                  callStatus: "OK",
                                  message: "No error"
                              }

Successful response for a GET:

{
                                  callStatus: "OK",
                                  message: "No error",
                                  statistics: {
                                      size: 12345678,
                                      atime: 12345678,
                                      mtime: 12345678,
                                      ctime: 12345678,
                                      type: "file"
                                  }
                              }
Field Use
Size The size of the file in bytes
Atime The last timestamp when the file was accessed
Mtime The last timestamp when the file was modified
Ctime The timestamp when the file was created
Type Either dir or file

The timestamps are given as UNIX timestamps (seconds since epoch Jan 1st 1970)

Copyright (C) 2003-2026 Kodmyran AB
All rights reserved.