Home Integration API reference

Integration API reference

REST API for integrations and external apps

Stock adjustments

List stock adjustments

Lists stock adjustment transactions for the business.

Endpoint summary

PropertyValue
MethodGET
Path/api/v1/integration/stock-adjustments
Permissionstock_adjustment.view, stock_adjustment.create, or view_own_stock_adjustment.
VisibilityRows are limited to permitted locations. When the token user lacks stock_adjustment.view but has view_own_stock_adjustment, rows are further limited to adjustments they created. A user with stock_adjustment.create but without stock_adjustment.view can still list adjustments in permitted locations.
Price visibilityfinal_total and total_amount_recovered are returned only when the token user has view_purchase_price; otherwise those fields are null.
CSV behaviorformat=csv streams all matching rows with a UTF-8 BOM and ignores page and per_page. The location object is JSON-encoded in CSV cells.
Success response200 with paginated StockAdjustmentRow rows.

Query parameters

ParameterTypeRequiredDescription
per_page, pageintegerNoPagination controls. per_page accepts 1 to 100 and defaults to 20.
start_date, end_datestringNoOptional Y-m-d bounds on transaction_date. The date filter is only applied when both values are present.
location_id, created_byintegerNoOptional location and creator filters.
adjustment_typestringNonormal or abnormal.
qstringNoMinimum 2 characters when sent. Matches reference number, notes, numeric id, and location name.
formatstringNojson (default) or csv.

StockAdjustmentRow object

FieldTypeDescription
idintegerStock adjustment transaction id.
ref_nostring | nullAdjustment reference number.
transaction_datestring | nullISO-8601 adjustment timestamp.
adjustment_typestring | nullnormal or abnormal.
additional_notesstring | nullSaved adjustment notes.
created_byinteger | nullCreator user id.
final_total, total_amount_recoverednumber | nullAdjustment totals. Returned as null when the token user lacks view_purchase_price.
locationobjectLocation summary with id and name.

Top-level JSON response

FieldTypeDescription
dataarray<StockAdjustmentRow>The current result page.
meta.current_page, meta.last_page, meta.per_page, meta.totalintegerLaravel paginator metadata.

Status codes

StatusWhen it happensResponse shape
200The stock adjustment list was returned successfully.{ "data": [...], "meta": { ... } } or CSV download.
403The token user lacks stock-adjustment list access.{ "message": "Unauthorized" }
422The query string failed validation or q was shorter than 2 characters.Laravel validation JSON or { "message": string }.

Get stock adjustment

Returns one visible stock adjustment by id.

Endpoint summary

PropertyValue
MethodGET
Path/api/v1/integration/stock-adjustments/{id}
PermissionSame permission and visibility rules as List stock adjustments.
Price visibilityHeader totals, line unit_price, and line line_total are returned only when the token user has view_purchase_price.
CSV behaviorformat=csv streams one UTF-8 BOM row whose data_json column matches the JSON data payload.
Success response200 with one StockAdjustmentDetail object.

StockAdjustmentLine object

FieldTypeDescription
idintegerStock-adjustment line id.
product_id, variation_idintegerProduct and variation ids on the adjustment line.
product_labelstringVariation display label from the loaded variation relation.
sub_skustring | nullVariation SKU.
quantitynumberStored adjustment quantity.
unit_pricenumber | nullLine unit price, or null when the token user lacks view_purchase_price.
line_totalnumber | nullRounded line total quantity * unit_price, or null when the token user lacks view_purchase_price.
lotobject | nullOptional lot summary with lot_number and exp_date when a lot relation exists.

StockAdjustmentDetail object

FieldTypeDescription
idintegerStock adjustment transaction id.
ref_nostring | nullAdjustment reference number.
transaction_datestring | nullISO-8601 adjustment timestamp.
adjustment_typestring | nullnormal or abnormal.
additional_notesstring | nullSaved adjustment notes.
created_byinteger | nullCreator user id.
final_total, total_amount_recoverednumber | nullAdjustment totals. Returned as null when the token user lacks view_purchase_price.
locationobjectLocation summary with id and name.
linesarray<StockAdjustmentLine>Adjustment lines ordered by line id.

Top-level JSON response

FieldTypeDescription
dataStockAdjustmentDetailThe requested stock adjustment payload.

Status codes

StatusWhen it happensResponse shape
200The stock adjustment was returned successfully.{ "data": { ... } } or CSV download.
403The token user lacks stock-adjustment list access.{ "message": "Unauthorized" }
404The stock adjustment id does not exist in the visible query.{ "message": "Not found" }
422The query string failed validation.Laravel validation JSON.

Create stock adjustment

Creates a stock adjustment and immediately maps its lines against purchase quantities.

Endpoint summary

PropertyValue
MethodPOST
Path/api/v1/integration/stock-adjustments
Permissionstock_adjustment.create.
Demo and subscriptionReturns 403 in demo environments and 402 when the business subscription is inactive.
Location rulelocation_id must belong to the business and must be inside the token user's permitted locations.
Product ruleEach product_id must belong to the business, and each variation_id must belong to the selected product.
Reference behaviorref_no is auto-generated from the stock-adjustment reference counter when omitted.
Default totalstotal_amount_recovered and final_total default to 0 when omitted.
Stock behaviorEach line immediately decreases available quantity at the selected location before the controller creates the transaction row and maps the adjustment against purchase stock.
Success response201 with one StockAdjustmentDetail object.

Request body

FieldTypeRequiredDescription
location_idintegerYesBusiness location id.
transaction_datestringYesDate string parsed through ProductUtil::uf_date(..., true).
adjustment_typestringYesnormal or abnormal.
productsarray<StockAdjustmentCreateLineInput>YesOne or more adjustment lines.
additional_notesstring | nullNoOptional adjustment notes.
total_amount_recoverednumber | nullNoOptional recovered amount. Defaults to 0.
final_totalnumber | nullNoOptional final total. Defaults to 0.
ref_nostring | nullNoOptional custom adjustment reference.

StockAdjustmentCreateLineInput object

FieldTypeRequiredDescription
product_idintegerYesBusiness product id.
variation_idintegerYesVariation id belonging to the selected product.
quantitynumberYesAdjustment quantity parsed with num_uf.
unit_pricenumberYesAdjustment unit price parsed with num_uf.
lot_no_line_idinteger | nullNoOptional purchase-line id used to preserve lot linkage on the adjustment line.

Top-level JSON response

FieldTypeDescription
dataStockAdjustmentDetailThe created stock adjustment payload.

Status codes

StatusWhen it happensResponse shape
201The stock adjustment was created successfully.{ "data": { ... } }
402The business subscription is inactive.{ "message": string }
403Demo mode is active or the token user lacks stock_adjustment.create.{ "message": string }
422The request body failed validation, the selected location is not permitted, the products do not belong to the business, or purchase-to-stock mapping raised a PurchaseSellMismatch.Laravel validation JSON or { "message": string }.
500The stock adjustment transaction failed unexpectedly.{ "message": "something_went_wrong" }

Delete stock adjustment

Deletes a visible stock adjustment and restores stock quantities for its lines.

Endpoint summary

PropertyValue
MethodDELETE
Path/api/v1/integration/stock-adjustments/{id}
Permissionstock_adjustment.delete.
VisibilityThe target adjustment must be in a permitted location. When the token user lacks stock_adjustment.view but has view_own_stock_adjustment, delete is limited to rows they created. A user with delete permission but without view permissions can still delete visible rows in permitted locations.
Demo modeReturns 403 in demo environments.
Delete behaviorThe controller reloads all stock-adjustment lines, adds their quantities back to the location, removes purchase-mapping quantities through mapPurchaseQuantityForDeleteStockAdjustment(), then deletes the adjustment transaction.
Success response200 with the deleted id.

Top-level JSON response

FieldTypeDescription
messagestringLocalized delete-success message.
data.idintegerThe deleted stock-adjustment id.

Status codes

StatusWhen it happensResponse shape
200The stock adjustment was deleted successfully.{ "message": string, "data": { "id": integer } }
403Demo mode is active or the token user lacks stock_adjustment.delete.{ "message": string }
404The stock adjustment id does not exist in the visible query.{ "message": "Not found" }
500The stock adjustment delete transaction failed unexpectedly.{ "message": "something_went_wrong" }