Inventory
Stock per variant and location, adjusted or counted as the Inventory page does.
| Operation | Method and path | Scope |
|---|---|---|
| List stock locations | GET /inventory/locations | inventory:read |
| List stock levels | GET /inventory/levels | inventory:read |
| Adjust stock | POST /inventory/adjust | inventory:write |
| Set stock to a count | POST /inventory/set | inventory:write |
List stock locations
GET https://kaizenaflow.com/api/admin/v1/inventory/locations
The store's stock locations, in the order stock is taken from them.
Operation:
inventory.locationsScope:
inventory:read, orinventory:write, which reads tooAnswers:
200, the answer underdata.
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].id | string (uuid) | |
data[].name | string | |
data[].country | string or null | |
data[].active | boolean | |
data[].priority | integer | The order stock is taken in: lowest first. |
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. |
| 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/inventory/locations' \
-H "Authorization: Bearer $KAIZENA_TOKEN"JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/inventory/locations", {
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/inventory/locations",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
},
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)List stock levels
GET https://kaizenaflow.com/api/admin/v1/inventory/levels
Stock per variant and location, the most recently changed first, with what can be sold now.
Operation:
inventory.levelsScope:
inventory:read, orinventory: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. |
variant_id | string (uuid) | no | Only this variant. |
location_id | string (uuid) | no | Only this location. |
Answer
| Field | Type | Description |
|---|---|---|
data | list of objects | |
data[].variant_id | string (uuid) | |
data[].location_id | string (uuid) | |
data[].sku | string or null | |
data[].on_hand | integer | |
data[].available | number or null | What can be sold now across the store's locations: on hand less what open orders hold. |
data[].can_buy | boolean or null | |
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/inventory/levels' \
-H "Authorization: Bearer $KAIZENA_TOKEN"JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/inventory/levels", {
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/inventory/levels",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
},
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)Adjust stock
POST https://kaizenaflow.com/api/admin/v1/inventory/adjust
Adds or takes away units per variant and location, as the Inventory page does, recorded with source api. Each row stands alone: one refused or in conflict never stops the others.
Operation:
inventory.adjustScope:
inventory:writeAnswers:
200, the answer underdata.Once only: with an
Idempotency-Keyheader.
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
reason | string | no, default "correction" | Why: one of received, correction, count, damaged, lost, promotion; correction when left out. |
note | string, at most 200 characters or null | no, default null | |
rows | list of objects, 1 to 250 items | yes | |
rows[].variant_id | string (uuid) | no | The variant, by its id. |
rows[].sku | string, 1 to 64 characters | no | The variant, by its SKU. |
rows[].location_id | string (uuid) | yes | |
rows[].delta | integer, -1,000,000 to 1,000,000 | yes | Units to add (negative to take away). |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.written | integer | |
data.unchanged | integer | |
data.conflicts | integer | |
data.refused | integer | |
data.failed | integer | |
data.rows | list of objects | |
data.rows[].variant_id | string (uuid) | |
data.rows[].location_id | string (uuid) | |
data.rows[].outcome | one of written, unchanged, conflict, refused, failed | conflict: the level moved since compare (or since it was read) and nothing was written for the row. |
data.rows[].before | integer or null | |
data.rows[].after | integer or null | |
data.rows[].problem | string or null | For a row not written: why, in a sentence. |
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/inventory/adjust' \
-H "Authorization: Bearer $KAIZENA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"rows":[{"variant_id":"a9012318-1d02-4424-9f91-3c4f58cc1841","location_id":"316a8630-7456-426c-a5fd-70b56f8cd80d","delta":1}]}'JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/inventory/adjust", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"rows": [
{
"variant_id": "a9012318-1d02-4424-9f91-3c4f58cc1841",
"location_id": "316a8630-7456-426c-a5fd-70b56f8cd80d",
"delta": 1
}
]
}),
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/inventory/adjust",
method="POST",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
"Content-Type": "application/json",
},
data=json.dumps({
"rows": [
{
"variant_id": "a9012318-1d02-4424-9f91-3c4f58cc1841",
"location_id": "316a8630-7456-426c-a5fd-70b56f8cd80d",
"delta": 1,
},
],
}).encode(),
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)Set stock to a count
POST https://kaizenaflow.com/api/admin/v1/inventory/set
Sets levels to what was counted. A level that moved since the count (compare) is a conflict and is never overwritten.
Operation:
inventory.setScope:
inventory:writeAnswers:
200, the answer underdata.Once only: with an
Idempotency-Keyheader.
Body
JSON, with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
reason | string | no, default "count" | Why: one of received, correction, count, damaged, lost, promotion; count when left out. |
note | string, at most 200 characters or null | no, default null | |
rows | list of objects, 1 to 250 items | yes | |
rows[].variant_id | string (uuid) | no | The variant, by its id. |
rows[].sku | string, 1 to 64 characters | no | The variant, by its SKU. |
rows[].location_id | string (uuid) | yes | |
rows[].on_hand | integer, 0 to 10,000,000 | yes | The level as counted. |
rows[].compare | integer, -10,000,000 to 10,000,000 | no | The level the count was made against: a level that moved since is a conflict, never overwritten. The level now when left out. |
Answer
| Field | Type | Description |
|---|---|---|
data | object | |
data.written | integer | |
data.unchanged | integer | |
data.conflicts | integer | |
data.refused | integer | |
data.failed | integer | |
data.rows | list of objects | |
data.rows[].variant_id | string (uuid) | |
data.rows[].location_id | string (uuid) | |
data.rows[].outcome | one of written, unchanged, conflict, refused, failed | conflict: the level moved since compare (or since it was read) and nothing was written for the row. |
data.rows[].before | integer or null | |
data.rows[].after | integer or null | |
data.rows[].problem | string or null | For a row not written: why, in a sentence. |
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/inventory/set' \
-H "Authorization: Bearer $KAIZENA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"rows":[{"variant_id":"a9012318-1d02-4424-9f91-3c4f58cc1841","location_id":"316a8630-7456-426c-a5fd-70b56f8cd80d","on_hand":1}]}'JavaScript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/inventory/set", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"rows": [
{
"variant_id": "a9012318-1d02-4424-9f91-3c4f58cc1841",
"location_id": "316a8630-7456-426c-a5fd-70b56f8cd80d",
"on_hand": 1
}
]
}),
});
const answer = await response.json();Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://kaizenaflow.com/api/admin/v1/inventory/set",
method="POST",
headers={
"Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
"Content-Type": "application/json",
},
data=json.dumps({
"rows": [
{
"variant_id": "a9012318-1d02-4424-9f91-3c4f58cc1841",
"location_id": "316a8630-7456-426c-a5fd-70b56f8cd80d",
"on_hand": 1,
},
],
}).encode(),
)
with urllib.request.urlopen(request) as response:
answer = json.load(response)