Adjust stock
Try itRecords stock in, stock out, wastage, or a count that sets on-hand to what was counted.
https:/ / tablebuddy.radioworkflow.com/ api/ v1/ inventory/ materials/ {material_id}/ adjustmentsWhat the stockroom screen records: stock in (in), stock out (out), wastage (wastage), or a count (count) that sets on-hand to what was counted and records the difference as a movement. Every count is kept, even one that finds the books right; that one moves nothing and answers changed: false.
Out and wastage may not take more than the books hold: count first. Stock in with a unit_cost re-weights the material's average cost. quantity_milli is in thousandths of the material's unit: 1.5 kg is 1500.
Authentication
Authorization: Bearer <key>, or the same key in x-api-key. A key acts as the person who made it, cut down to this endpoint’s scope, and never as an owner. How keys workinventory.manage)Request headers
AuthorizationrequiredBearer <key>. x-api-key: <key> works too; Authorization wins when both are sent.Idempotency-KeyrequiredContent-Typerequiredapplication/json: the body is JSON.Path parameters
material_idstringidrequiredRequest body
modeenumrequiredin, out or wastage moves stock by quantity_milli; count sets on-hand to it.inoutwastagecountquantity_milliinteger0–100,000,000requiredunit_costinteger0–100,000,000optionalnullablereasonstring1–300 charsrequiredNot blank; no NUL character or unpaired surrogate.
A field the endpoint does not take is answered 422 invalid_request naming it, before anything is looked up or the Idempotency-Key is used.
Response
delta_milli is how much on-hand moved; balance_milli is on hand now.
currencystringISO 4217minor_digitsinteger0–3adjustmentobjectadjustment.changedbooleanadjustment.namestringadjustment.unitstringadjustment.delta_milliintegermilli-unitsadjustment.balance_milliintegermilli-unitsAn answer may gain fields within v1: ignore the ones you do not know. Versioning
Response headers
request-idalwaysCache-Controlalwaysno-store: an answer is never cached.RateLimit-Limit, RateLimit-Remaining, RateLimit-Resetonce the key is knownx-error-codeon an errorerror.code in the body.Idempotent-Replayed, Original-Request-Idon a replayed writetrue, and the request-id of the request that ran: this is the kept answer to an earlier request with the same Idempotency-Key.Retry-Afteron a 429, and a 409 idempotency_key_in_useWWW-Authenticateon a 401, and a 403 insufficient_scopeErrors
invalid_idempotency_keyA–Z a–z 0–9 - _ . : ~ + / =.Fix: Send a UUID.
idempotency_key_requiredFix: Generate one per operation; reuse it only to retry that operation.
insufficient_scopeFix: Scopes are fixed when a key is made: make a new key with the scope.
issuer_access_endedFix: Make a new key from an active account.
issuer_permission_changedFix: Ask an owner to restore the permission, or make a new key from an account that holds it.
permission_requiredFix: Use a key with the named scope, from a creator who holds the named permission.
not_foundFix: Find it with list-materials.
refusedFix: Read the sentence: it says what to change. The endpoint page lists the common ones.
idempotency_key_in_useFix: Wait Retry-After seconds and send the same request again.
payload_too_largeFix: Send less; split a batch.
json_requiredContent-Type: application/json.Fix: Send JSON with that header.
invalid_requestFix: Fix the named fields. Nothing was done, and an Idempotency-Key is not used up.
idempotency_key_reusedFix: Use a new key for a new request.
Refused by the restaurant’s rules
Answered 409 refused with the engine’s own sentence, the one the console shows. The common ones:
Only {quantity} of {material} is on the books. If there is more on the shelf, count it first.
Out or wastage past what the books hold.
Fix: Send a count of what is there first, then the out or the wastage.
{material} is archived. Restore it first.
An archived material.
Fix: Restore it in Table Buddy's stockroom first.
Enter a quantity above zero.
Stock in, out or wastage of zero.
Fix: Send a quantity above 0; only a count may be 0.
missing_api_keyNo Authorization: Bearer header and no x-api-key header.invalid_api_keyThe key is unknown, revoked or expired (answered alike).rate_limitedOver the key's 60 units a minute, or over 30 unknown keys a minute from one network (an address; an IPv6 caller's /64).internal_errorSomething failed on our side. Nothing kept the Idempotency-Key.curl -X POST "$TABLEBUDDY_URL/api/v1/inventory/materials/MATERIAL_ID/adjustments" \
-H "Authorization: Bearer $TABLEBUDDY_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '{"mode":"count","quantity_milli":17250,"reason":"Walk-in count"}'{
"currency": "USD",
"minor_digits": 2,
"adjustment": {
"changed": true,
"name": "Atlantic salmon fillet",
"unit": "lb",
"delta_milli": -1250,
"balance_milli": 17250
}
}