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 -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
| Parameter | Type | Required | Description |
|---|---|---|---|
reason_code | string | Yes | Why the stock changed. See the reasons below. |
warehouse_code | string | No | The warehouse's code. Without a warehouse, the Default warehouse is used. |
warehouse_id | string | No | The warehouse's ID, instead of its code. |
note | string | No | Up to 1,000 characters. |
lines | array | Yes | At least one line. The body must stay under 100 KB. |
Each line
| Parameter | Type | Required | Description |
|---|---|---|---|
sku | string | Yes | The item. |
qty | number | Yes | The 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. |
mode | string | No | delta to add or remove qty (the default), or set to make the stock exactly qty. |
state | string | No | The stock state to change: available (the default), qc_hold, damaged, quarantine or reserved. |
lot_no | string | No | Change 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.
| Code | Name | Moves |
|---|---|---|
correction | Correction | In or out |
count_variance | Count variance | In or out |
found | Found | In only |
return_restock | Return restocked | In only |
opening_balance | Opening balance | In only |
shrinkage | Shrinkage (theft or unexplained loss) | Out only |
sample_or_promotion | Sample or promotion | Out only |
internal_use | Internal use | Out only |
lost_in_transit | Lost in transit | Out only |
damaged | Damaged in storage | Available units to damaged |
qc_fail | Failed quality check | Available units to damaged |
expired | Expired | Available 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.
{
"id": "318",
"number": "ADJ-2627-00318",
"status": "posted",
"reason_code": "correction",
"lines": [
{
"sku": "MUG-BLUE",
"qty": -2,
"mode": "delta",
"state": "available"
}
]
}| Field | Type | Description |
|---|---|---|
id, number | string | O2M's ID and the document number. |
status | string | posted: the stock has changed. pending_approval: it waits for someone to approve it in O2M, and the stock has not changed yet. |
reason_code | string | The reason you sent. |
lines | array | The 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.
| Status | Code | Message | What to do |
|---|---|---|---|
| 403 | CLIENT_KEY | A client's key cannot change stock: this is done by the warehouse | Use 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 warehouse | Leave out the warehouse. |
| 404 | — | No warehouse has the code XXX | Check warehouse_code. |
| 404 | — | Warehouse not found | Check warehouse_id. |
| 404 | LOT_NOT_FOUND | Line 1: MUG-BLUE has no lot L9. A new lot comes in through a goods receipt. | Check lot_no. |
| 409 | INSUFFICIENT_STOCK | Line 1 (MUG-BLUE): only 10 available unit(s) to take 5000 from | Read the stock and lower the quantity. |
| 409 | — | Bengaluru does not take stock changes | The warehouse is inactive, or is run by a channel. |
| 413 | — | At most 5000 lines per adjustment | Split the adjustment. |
| 422 | — | Choose an active reason | Use a reason code that exists and is switched on. |
| 422 | — | Add at least one line | Send lines. |
| 422 | — | Line 1: SKU is required | Add the sku. |
| 422 | — | Line 1: no product or variant has SKU GHOST | Check the SKU in O2M. |
| 422 | — | Line 1: mode must be delta or set | Correct mode. |
| 422 | — | Line 1: state must be one of available, qc_hold, damaged, quarantine, reserved | Correct state. |
| 422 | — | Line 1: quantity must be a number with at most 3 decimals | Correct qty. |
| 422 | — | Line 1: a set quantity cannot be negative | With set, send 0 or more. |
| 422 | — | Line 1: a change of 0 does nothing | Send a change, or use set. |
| 422 | — | Line 1 (MUG-BLUE): "Found" can only add stock | Use a positive qty, or another reason. |
| 422 | — | Line 1 (MUG-BLUE): "Shrinkage (theft or unexplained loss)" can only remove stock | Use a negative qty, or another reason. |
| 422 | — | Line 1: "Damaged in storage" moves sellable units; give a positive number of units to move | Use 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.