Skip to content
Kaizena FlowDocs
Search

Search the docs

Inventory

Stock per variant and location, adjusted or counted as the Inventory page does.

OperationMethod and pathScope
List stock locationsGET /inventory/locationsinventory:read
List stock levelsGET /inventory/levelsinventory:read
Adjust stockPOST /inventory/adjustinventory:write
Set stock to a countPOST /inventory/setinventory: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.

Answer

FieldTypeDescription
datalist of objects
data[].idstring (uuid)
data[].namestring
data[].countrystring or null
data[].activeboolean
data[].priorityintegerThe order stock is taken in: lowest first.

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.
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/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.levels

  • Scope: inventory:read, or inventory: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.
variant_idstring (uuid)noOnly this variant.
location_idstring (uuid)noOnly this location.

Answer

FieldTypeDescription
datalist of objects
data[].variant_idstring (uuid)
data[].location_idstring (uuid)
data[].skustring or null
data[].on_handinteger
data[].availablenumber or nullWhat can be sold now across the store's locations: on hand less what open orders hold.
data[].can_buyboolean or null
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/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.

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
reasonstringno, default "correction"Why: one of received, correction, count, damaged, lost, promotion; correction when left out.
notestring, at most 200 characters or nullno, default null
rowslist of objects, 1 to 250 itemsyes
rows[].variant_idstring (uuid)noThe variant, by its id.
rows[].skustring, 1 to 64 charactersnoThe variant, by its SKU.
rows[].location_idstring (uuid)yes
rows[].deltainteger, -1,000,000 to 1,000,000yesUnits to add (negative to take away).

Answer

FieldTypeDescription
dataobject
data.writteninteger
data.unchangedinteger
data.conflictsinteger
data.refusedinteger
data.failedinteger
data.rowslist of objects
data.rows[].variant_idstring (uuid)
data.rows[].location_idstring (uuid)
data.rows[].outcomeone of written, unchanged, conflict, refused, failedconflict: the level moved since compare (or since it was read) and nothing was written for the row.
data.rows[].beforeinteger or null
data.rows[].afterinteger or null
data.rows[].problemstring or nullFor a row not written: why, in a sentence.

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

Body

JSON, with Content-Type: application/json.

FieldTypeRequiredDescription
reasonstringno, default "count"Why: one of received, correction, count, damaged, lost, promotion; count when left out.
notestring, at most 200 characters or nullno, default null
rowslist of objects, 1 to 250 itemsyes
rows[].variant_idstring (uuid)noThe variant, by its id.
rows[].skustring, 1 to 64 charactersnoThe variant, by its SKU.
rows[].location_idstring (uuid)yes
rows[].on_handinteger, 0 to 10,000,000yesThe level as counted.
rows[].compareinteger, -10,000,000 to 10,000,000noThe level the count was made against: a level that moved since is a conflict, never overwritten. The level now when left out.

Answer

FieldTypeDescription
dataobject
data.writteninteger
data.unchangedinteger
data.conflictsinteger
data.refusedinteger
data.failedinteger
data.rowslist of objects
data.rows[].variant_idstring (uuid)
data.rows[].location_idstring (uuid)
data.rows[].outcomeone of written, unchanged, conflict, refused, failedconflict: the level moved since compare (or since it was read) and nothing was written for the row.
data.rows[].beforeinteger or null
data.rows[].afterinteger or null
data.rows[].problemstring or nullFor a row not written: why, in a sentence.

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/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)

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

Was this page helpful?