Overview /
Stock & supply /
Adjust a stock balance
Adjust a stock balance
post
https://api.flactrum.com/v1/stock-levels/adjust
Balances are never written directly. Every adjustment produces a stock movement carrying your reason, so "why did stock change" always has an answer. Send quantity to set an exact balance or delta to add to it.
| Required scope | stock.write |
| Success status | 200 |
Request body
| Field | Type | Description |
|---|---|---|
| stock_item_id * | string | — |
| branch_id | string|null | Either this or warehouse_id, not both. |
| warehouse_id | string|null | — |
| quantity | number|null | Set the balance to exactly this. |
| delta | number|null | Add this to the current balance; negative subtracts. Send exactly one of quantity or delta. |
| reason * | string | Required. It is written onto the movement so the change can always be explained later. |
| type | string | Movement type. Defaults to adjustment; use waste for spoilage. |
| unit_cost | number|null | — |
Examples
Recorded from the test suite — these are real requests and their real responses.
curl -X POST 'https://api.flactrum.com/v1/stock-levels/adjust' \
-H 'Authorization: Bearer flk_your_key:your_secret' \
-H 'Content-Type: application/json' \
-d '{
"stock_item_id": "01m43mzjk48kbg3arnqqe1qwgg",
"branch_id": "01m43mzjjvcqjd0grnj20jhzpv",
"quantity": 5000,
"reason": "Açılış stoğu"
}'
HTTP 200 · application/json
{
"data": {
"stock_item_id": "01m43mzjk48kbg3arnqqe1qwgg",
"changed": true,
"quantity_before": 0,
"quantity_after": 5000,
"movement_id": "01m43mzjkhna7146kh9eh338p7"
}
}
curl -X POST 'https://api.flactrum.com/v1/stock-levels/adjust' \
-H 'Authorization: Bearer flk_your_key:your_secret' \
-H 'Content-Type: application/json' \
-d '{
"stock_item_id": "01m43mzjt3jwbkzfvhnw7s50m2",
"branch_id": "01m43mzjst2446yf31gk5n5gm7",
"quantity": 100,
"delta": 50,
"reason": "Belirsiz"
}'
HTTP 422 · application/json
{
"error": {
"code": "validation_failed",
"message": "The submitted data is invalid.",
"details": {
"fields": {
"quantity": [
"Send exactly one of quantity (set to this value) or delta (add to the current value)."
]
}
}
}
}