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.
| Operation | Method and path | Scope |
|---|---|---|
| Start an upload | POST /media/uploads | products:manage |
| Keep an uploaded picture | POST /media | products:manage |
| List the media library | GET /media | products:read |
| Get a product's gallery | GET /products/{id}/media | products:read |
| Add a picture to a product | POST /products/{id}/media | products:manage |
| Order a product's pictures | PATCH /products/{id}/media | products:manage |
| Take a picture off a product | DELETE /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.
Operation:
media.uploadScope:
products:manageAnswers:
201, made: the answer underdata.Once only: with an
Idempotency-Keyheader.
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
content_type | one of image/jpeg, image/png, image/webp, image/avif | yes | The picture's type: JPEG, PNG, WebP or AVIF. |
size_bytes | integer, 1 to 20,971,520 | yes | Its size in bytes, at most 20 MB. |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.upload_id | string (uuid) | Give it to POST /media once the file is sent. |
data.upload_url | string or null | A 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.headers | map of string to string | The headers to send with the PUT. |
data.expires_at | string (date-time) | The address and the upload id end then. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 409 | conflict | Nothing 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. |
| 422 | invalid | Nothing 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. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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.
Operation:
media.createScope:
products:manageAnswers:
201, made: the answer underdata.Once only: with an
Idempotency-Keyheader.
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
upload_id | string (uuid) | yes | The upload whose file was sent (POST /media/uploads). |
file_name | string, 1 to 255 characters | no | The name the library shows; picture when left out. |
alt | string, at most 300 characters | no | Words for people who cannot see it; the store's AI writes them when left out. |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.id | string (uuid) | |
data.kind | one of image, video, model | image, video or model (3D). |
data.url | string | |
data.thumbnail_url | string or null | A small copy, 480 pixels wide, for a picture. |
data.file_name | string | |
data.content_type | string | |
data.size_bytes | integer | |
data.width | integer or null | |
data.height | integer or null | |
data.alt | string | Its words for people who cannot see it, in the store's main language. |
data.created_at | string (date-time) | |
data.updated_at | string (date-time) |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 409 | conflict | Nothing 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. |
| 422 | invalid | Nothing 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. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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.listScope:
products:read, orproducts:write, which reads tooAnswers:
200, a page: the rows underdata, andnextfor the page after.Pages: at most 100 rows, 50 when
limitis left out; give an answer'snextas?after=for the page after.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
limit | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
after | string, at most 200 characters | no | The next cursor of the page before; the first page when left out. |
updated_after | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |
kind | one of image, video, model | no | Only this kind. |
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].id | string (uuid) | |
data[].kind | one of image, video, model | image, video or model (3D). |
data[].url | string | |
data[].thumbnail_url | string or null | A small copy, 480 pixels wide, for a picture. |
data[].file_name | string | |
data[].content_type | string | |
data[].size_bytes | integer | |
data[].width | integer or null | |
data[].height | integer or null | |
data[].alt | string | Its words for people who cannot see it, in the store's main language. |
data[].created_at | string (date-time) | |
data[].updated_at | string (date-time) | |
next | string or null | The cursor of the next page, given as ?after=; null on the last page. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 422 | invalid | Nothing 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. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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.
Operation:
products.mediaScope:
products:read, orproducts:write, which reads tooAnswers:
200, the answer underdata.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].media_id | string (uuid) or null | The library item (GET /media); null for a file the library does not hold. |
data[].kind | one of image, video, model | |
data[].url | string | |
data[].thumbnail_url | string or null | |
data[].alt | string | |
data[].position | integer | Its place in the gallery: 0 is the main picture. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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.
Operation:
products.media_addScope:
products:manageAnswers:
201, made: the answer underdata.Once only: with an
Idempotency-Keyheader.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
media_id | string (uuid) | yes | A picture of the store's media library. |
alt | string, at most 300 characters | no | Its words in the product's gallery; the library's, else the product's title, when left out. |
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].media_id | string (uuid) or null | The library item (GET /media); null for a file the library does not hold. |
data[].kind | one of image, video, model | |
data[].url | string | |
data[].thumbnail_url | string or null | |
data[].alt | string | |
data[].position | integer | Its place in the gallery: 0 is the main picture. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 403 | gated | The 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. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | conflict | Nothing 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. |
| 422 | invalid | Nothing 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. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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_orderScope:
products:manageAnswers:
200, the answer underdata.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
media_ids | list of string (uuid), 1 to 20 items | yes | The 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
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].media_id | string (uuid) or null | The library item (GET /media); null for a file the library does not hold. |
data[].kind | one of image, video, model | |
data[].url | string | |
data[].thumbnail_url | string or null | |
data[].alt | string | |
data[].position | integer | Its place in the gallery: 0 is the main picture. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 403 | gated | The 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. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 422 | invalid | Nothing 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. |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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_removeScope:
products:manageAnswers:
200, the answer underdata.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | string (uuid) | yes | The thing's id in this store. |
media_id | string (uuid) | yes | The library picture. |
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].media_id | string (uuid) or null | The library item (GET /media); null for a file the library does not hold. |
data[].kind | one of image, video, model | |
data[].url | string | |
data[].thumbnail_url | string or null | |
data[].alt | string | |
data[].position | integer | Its place in the gallery: 0 is the main picture. |
Errors
| Status | Code | When |
|---|---|---|
| 401 | unauthorized | No valid token in Authorization: Bearer kf_…, or one that was revoked. |
| 403 | forbidden | The 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. |
| 403 | gated | The 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. |
| 404 | not_found | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | rate_limited | More calls than the budget allows; Retry-After says how many seconds to wait. |
| 500 | failed | Something 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)