Skip to content
Kaizena FlowDocs
Search

Search the docs

Media

The media library's pictures, sent through a one-time upload address and checked as the library checks them, and a product's gallery.

OperationMethod and pathScope
Start an uploadPOST /media/uploadsproducts:manage
Keep an uploaded picturePOST /mediaproducts:manage
List the media libraryGET /mediaproducts:read
Get a product's galleryGET /products/{id}/mediaproducts:read
Add a picture to a productPOST /products/{id}/mediaproducts:manage
Order a product's picturesPATCH /products/{id}/mediaproducts:manage
Take a picture off a productDELETE /products/{id}/media/{media_id}products:manage

Start an upload

POST https://kaizenaflow.com/api/admin/v1/media/uploads

Gives a one-time address to PUT a picture to, for 2 hours. The file is checked and kept only by POST /media, as the media library checks an upload: its type read from its bytes, shrunk as the admin's browser shrinks pictures (WebP, at most 1600 pixels wide, a 480-pixel copy), counted against the store's storage.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
content_typeone of image/jpeg, image/png, image/webp, image/avifyesThe picture's type: JPEG, PNG, WebP or AVIF.
size_bytesinteger, 1 to 20,971,520yesIts size in bytes, at most 20 MB.

Answer

FieldTypeDescription
dataobject
data.upload_idstring (uuid)Give it to POST /media once the file is sent.
data.upload_urlstring or nullA one-time address: PUT the file's bytes there with the same Content-Type, once. Answered once: a replay of the request (the same Idempotency-Key) answers null.
data.method"PUT"
data.headersmap of string to stringThe headers to send with the PUT.
data.expires_atstring (date-time)The address and the upload id end then.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
409conflictNothing was done: it clashes with how things are now (nothing left to send), or an Idempotency-Key is in use or was used for another request.
422invalidNothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl -X POST 'https://kaizenaflow.com/api/admin/v1/media/uploads' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content_type":"image/jpeg","size_bytes":1}'

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/media/uploads", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "content_type": "image/jpeg",
    "size_bytes": 1
  }),
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/media/uploads",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "content_type": "image/jpeg",
        "size_bytes": 1,
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

Keep an uploaded picture

POST https://kaizenaflow.com/api/admin/v1/media

Checks the file sent to an upload's address and keeps it in the store's media library, once: an upload id is used up by its first success.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
upload_idstring (uuid)yesThe upload whose file was sent (POST /media/uploads).
file_namestring, 1 to 255 charactersnoThe name the library shows; picture when left out.
altstring, at most 300 charactersnoWords for people who cannot see it; the store's AI writes them when left out.

Answer

FieldTypeDescription
dataobject
data.idstring (uuid)
data.kindone of image, video, modelimage, video or model (3D).
data.urlstring
data.thumbnail_urlstring or nullA small copy, 480 pixels wide, for a picture.
data.file_namestring
data.content_typestring
data.size_bytesinteger
data.widthinteger or null
data.heightinteger or null
data.altstringIts words for people who cannot see it, in the store's main language.
data.created_atstring (date-time)
data.updated_atstring (date-time)

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
409conflictNothing was done: it clashes with how things are now (nothing left to send), or an Idempotency-Key is in use or was used for another request.
422invalidNothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl -X POST 'https://kaizenaflow.com/api/admin/v1/media' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"upload_id":"3399b5fa-aaf6-4440-bcb8-9b5321b1bfd9"}'

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/media", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "upload_id": "3399b5fa-aaf6-4440-bcb8-9b5321b1bfd9"
  }),
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/media",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "upload_id": "3399b5fa-aaf6-4440-bcb8-9b5321b1bfd9",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

List the media library

GET https://kaizenaflow.com/api/admin/v1/media

The store's pictures, videos and 3D models, newest first.

  • Operation: media.list

  • Scope: products:read, or products:write, which reads too

  • Answers: 200, a page: the rows under data, and next for the page after.

  • Pages: at most 100 rows, 50 when limit is left out; give an answer's next as ?after= for the page after.

Query parameters

NameTypeRequiredDescription
limitinteger, 1 to 100noRows a page holds, at most 100; 50 when left out. A larger number gives 100.
afterstring, at most 200 charactersnoThe next cursor of the page before; the first page when left out.
updated_afterstring (date-time)noOnly what was made or changed after this time (ISO 8601 with its offset), for incremental sync.
kindone of image, video, modelnoOnly this kind.

Answer

FieldTypeDescription
datalist of objects
data[].idstring (uuid)
data[].kindone of image, video, modelimage, video or model (3D).
data[].urlstring
data[].thumbnail_urlstring or nullA small copy, 480 pixels wide, for a picture.
data[].file_namestring
data[].content_typestring
data[].size_bytesinteger
data[].widthinteger or null
data[].heightinteger or null
data[].altstringIts words for people who cannot see it, in the store's main language.
data[].created_atstring (date-time)
data[].updated_atstring (date-time)
nextstring or nullThe cursor of the next page, given as ?after=; null on the last page.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
422invalidNothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl 'https://kaizenaflow.com/api/admin/v1/media' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/media", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/media",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

Get a product's gallery

GET https://kaizenaflow.com/api/admin/v1/products/{id}/media

The product's pictures, videos and 3D models in their order, the first the main one.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.

Answer

FieldTypeDescription
datalist of objects
data[].media_idstring (uuid) or nullThe library item (GET /media); null for a file the library does not hold.
data[].kindone of image, video, model
data[].urlstring
data[].thumbnail_urlstring or null
data[].altstring
data[].positionintegerIts place in the gallery: 0 is the main picture.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl 'https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

Add a picture to a product

POST https://kaizenaflow.com/api/admin/v1/products/{id}/media

Adds a library picture after the product's pictures, through the product editor's save. A product on the site only with products:publish (else gated). Answers the gallery as it is now.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
media_idstring (uuid)yesA picture of the store's media library.
altstring, at most 300 charactersnoIts words in the product's gallery; the library's, else the product's title, when left out.

Answer

FieldTypeDescription
datalist of objects
data[].media_idstring (uuid) or nullThe library item (GET /media); null for a file the library does not hold.
data[].kindone of image, video, model
data[].urlstring
data[].thumbnail_urlstring or null
data[].altstring
data[].positionintegerIts place in the gallery: 0 is the main picture.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
403gatedThe request needs a power beside the operation's scope (the message names it): changing a product, category or address on the site, an import that would, or a customer's email. A copied order is never changed.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
409conflictNothing was done: it clashes with how things are now (nothing left to send), or an Idempotency-Key is in use or was used for another request.
422invalidNothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl -X POST 'https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"media_id":"2690d087-c00f-46bc-b218-44e4db282d91"}'

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "media_id": "2690d087-c00f-46bc-b218-44e4db282d91"
  }),
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "media_id": "2690d087-c00f-46bc-b218-44e4db282d91",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

Order a product's pictures

PATCH https://kaizenaflow.com/api/admin/v1/products/{id}/media

Puts the product's pictures in the order given (each of them named once); a product on the site only with products:publish.

  • Operation: products.media_order

  • Scope: products:manage

  • Answers: 200, the answer under data.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
media_idslist of string (uuid), 1 to 20 itemsyesThe gallery's pictures, by library id, in the order they should have; the first is the main one. Videos and 3D models keep their places after them.

Answer

FieldTypeDescription
datalist of objects
data[].media_idstring (uuid) or nullThe library item (GET /media); null for a file the library does not hold.
data[].kindone of image, video, model
data[].urlstring
data[].thumbnail_urlstring or null
data[].altstring
data[].positionintegerIts place in the gallery: 0 is the main picture.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
403gatedThe request needs a power beside the operation's scope (the message names it): changing a product, category or address on the site, an import that would, or a customer's email. A copied order is never changed.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
422invalidNothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what.
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl -X PATCH 'https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"media_ids":["a9f8f01c-d10d-4794-ad3f-340d53a95a25"]}'

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "media_ids": [
      "a9f8f01c-d10d-4794-ad3f-340d53a95a25"
    ]
  }),
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media",
    method="PATCH",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "media_ids": [
            "a9f8f01c-d10d-4794-ad3f-340d53a95a25",
        ],
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

Take a picture off a product

DELETE https://kaizenaflow.com/api/admin/v1/products/{id}/media/{media_id}

Takes the picture out of the product's gallery (it stays in the library); a product on the site only with products:publish.

  • Operation: products.media_remove

  • Scope: products:manage

  • Answers: 200, the answer under data.

Path parameters

NameTypeRequiredDescription
idstring (uuid)yesThe thing's id in this store.
media_idstring (uuid)yesThe library picture.

Answer

FieldTypeDescription
datalist of objects
data[].media_idstring (uuid) or nullThe library item (GET /media); null for a file the library does not hold.
data[].kindone of image, video, model
data[].urlstring
data[].thumbnail_urlstring or null
data[].altstring
data[].positionintegerIts place in the gallery: 0 is the main picture.

Errors

StatusCodeWhen
401unauthorizedNo valid token in Authorization: Bearer kf_…, or one that was revoked.
403forbiddenThe token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which.
403gatedThe request needs a power beside the operation's scope (the message names it): changing a product, category or address on the site, an import that would, or a customer's email. A copied order is never changed.
404not_foundNo such route, or nothing with that id in the token's store (another store's ids are simply not found).
429rate_limitedMore calls than the budget allows; Retry-After says how many seconds to wait.
500failedSomething went wrong on our side; nothing more was done. It is safe to try again.

Example request

curl

curl -X DELETE 'https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media/2690d087-c00f-46bc-b218-44e4db282d91' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"

JavaScript

const response = await fetch("https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media/2690d087-c00f-46bc-b218-44e4db282d91", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();

Python

import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/products/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/media/2690d087-c00f-46bc-b218-44e4db282d91",
    method="DELETE",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)

Made from the API contract, version 1.57This page as Markdown

Was this page helpful?