O2M Logo
One to Many
Create a stock adjustment
Was this page helpful?

Create a stock adjustment

Correct stock: add, remove, set an exact number, or mark units as damaged.

Overview

A stock adjustment corrects your stock for a stated reason, such as a recount or damage. It is posted at once, unless your company's rules ask for approval.

Request

POST/adjustments

Needs the permission stock:adjust

cURL
curl -X POST "https://api.o2m.in/api/v1/adjustments" \
  -H "X-Access-Key: $O2M_ACCESS_KEY" \
  -H "X-Secret-Key: $O2M_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: adjust-2026-10-02-1" \
  -d '{
  "warehouse_code": "BLR",
  "reason_code": "correction",
  "note": "Recounted after the stock take",
  "lines": [
    {
      "sku": "MUG-BLUE",
      "qty": -2
    }
  ]
}'

Important  Always send an Idempotency-Key. Without one, a retry changes the stock a second time.

Good to know  The key of a 3PL client cannot create adjustments.

Body

ParameterTypeRequiredDescription
reason_codestringYesWhy the stock changed. See the reasons below.
warehouse_codestringNoThe warehouse's code. Without a warehouse, the Default warehouse is used.
warehouse_idstringNoThe warehouse's ID, instead of its code.
notestringNoUp to 1,000 characters.
linesarrayYesAt least one line. The body must stay under 100 KB.

Each line

ParameterTypeRequiredDescription
skustringYesThe item.
qtynumberYesThe change in units, positive or negative. With mode: set, the new number. Up to 3 decimals for items sold in loose quantities, otherwise whole numbers.
modestringNodelta to add or remove qty (the default), or set to make the stock exactly qty.
statestringNoThe stock state to change: available (the default), qc_hold, damaged, quarantine or reserved.
lot_nostringNoChange only this lot. A new lot comes in through a goods receipt.

Reason codes

A reason decides which way the stock may move. Your company can add its own in Settings → Stock → Stock settings, and change whether a reason needs approval.

CodeNameMoves
correctionCorrectionIn or out
count_varianceCount varianceIn or out
foundFoundIn only
return_restockReturn restockedIn only
opening_balanceOpening balanceIn only
shrinkageShrinkage (theft or unexplained loss)Out only
sample_or_promotionSample or promotionOut only
internal_useInternal useOut only
lost_in_transitLost in transitOut only
damagedDamaged in storageAvailable units to damaged
qc_failFailed quality checkAvailable units to damaged
expiredExpiredAvailable units to quarantine

Important  A reason that moves units to damaged or quarantine takes a positive qty: the number of available units to move. A negative number is refused.

Response

201 with the adjustment.

Response
{
  "id": "318",
  "number": "ADJ-2627-00318",
  "status": "posted",
  "reason_code": "correction",
  "lines": [
    {
      "sku": "MUG-BLUE",
      "qty": -2,
      "mode": "delta",
      "state": "available"
    }
  ]
}
FieldTypeDescription
id, numberstringO2M's ID and the document number.
statusstringposted: the stock has changed. pending_approval: it waits for someone to approve it in O2M, and the stock has not changed yet.
reason_codestringThe reason you sent.
linesarrayThe lines, with sku, qty, mode and state.

Your company's rules decide what needs approval, and an API key cannot approve. Reasons such as shrinkage need approval by default, and so do large changes on reasons such as correction. Treat pending_approval as not yet done.

Errors

The whole adjustment succeeds or fails together. If one line is refused, no stock changes.

StatusCodeMessageWhat to do
403CLIENT_KEYA client's key cannot change stock: this is done by the warehouseUse a key of your own company.
403—You are not assigned to Bengaluru. Ask a warehouse manager to add you.The key is limited to other warehouses.
403—Warehouse Management is not enabled for your company: stock changes go to the Default warehouseLeave out the warehouse.
404—No warehouse has the code XXXCheck warehouse_code.
404—Warehouse not foundCheck warehouse_id.
404LOT_NOT_FOUNDLine 1: MUG-BLUE has no lot L9. A new lot comes in through a goods receipt.Check lot_no.
409INSUFFICIENT_STOCKLine 1 (MUG-BLUE): only 10 available unit(s) to take 5000 fromRead the stock and lower the quantity.
409—Bengaluru does not take stock changesThe warehouse is inactive, or is run by a channel.
413—At most 5000 lines per adjustmentSplit the adjustment.
422—Choose an active reasonUse a reason code that exists and is switched on.
422—Add at least one lineSend lines.
422—Line 1: SKU is requiredAdd the sku.
422—Line 1: no product or variant has SKU GHOSTCheck the SKU in O2M.
422—Line 1: mode must be delta or setCorrect mode.
422—Line 1: state must be one of available, qc_hold, damaged, quarantine, reservedCorrect state.
422—Line 1: quantity must be a number with at most 3 decimalsCorrect qty.
422—Line 1: a set quantity cannot be negativeWith set, send 0 or more.
422—Line 1: a change of 0 does nothingSend a change, or use set.
422—Line 1 (MUG-BLUE): "Found" can only add stockUse a positive qty, or another reason.
422—Line 1 (MUG-BLUE): "Shrinkage (theft or unexplained loss)" can only remove stockUse a negative qty, or another reason.
422—Line 1: "Damaged in storage" moves sellable units; give a positive number of units to moveUse a positive qty and no mode or state.

Every endpoint can also return the common errors: a missing or invalid key, a missing permission, the rate limit, or a temporary failure.