Inventory adjustments

An adjustment corrects a SKU's stock at a location while recording why it changed (shrinkage, damage, count correction…). The resource exposes six endpoints: list, aggregate summary, get one, create, approve and reject.

Stock moves ON APPROVAL, not on creation

Creating an adjustment does not touch stock. The record is created with status: "pending" and describes an intent: "this SKU should end up at 137". The real movement happens when you call approve, which writes newQuantity onto the inventory record. Rejecting a pending adjustment does not move stock either — it just marks it rejected, because nothing had been applied.

A flow that creates the adjustment and assumes inventory already changed will read stale quantities until somebody approves.

No inventory endpoint checks permissions: it only authenticates

The entire Inventory domain is authenticated but not authorized. The API authorizer grants execute-api:Invoke over the whole API to any principal that authenticates, without looking at the requested route; it does hand the user's permission list to the lambda, but the inventory lambda never reads it: it contains not a single call to requirePermission or to the permission catalog.

The only things validated before the request is served are that the token carries a tenant (401 bad-request/missing-tenant) and that the tenant is not suspended (403 tenant/suspended). As a result, any valid token for the tenant can create, approve and reject adjustments, whether or not it holds the inventory:adjust scope. The one boundary that is enforced is tenant isolation: every query filters by the token's tenantId.

This page declares no "required permission" because there is none. This is tracked as technical debt.

List adjustments

Lists the tenant's adjustments, newest first, with optional filters.

200
{
  "adjustments": [
    {
      "_id": "670a1b2c3d4e5f6a7b8c9d10",
      "tenantId": "69db07c8bce4d49b18c42a49",
      "locationId": "670a1b2c3d4e5f6a7b8c9d01",
      "sku": "CAM-ROJO-M",
      "productSku": "CAM-ROJO",
      "oldQuantity": 140,
      "newQuantity": 137,
      "adjustmentQuantity": -3,
      "reason": "damage",
      "notes": "3 piezas mojadas en el anden",
      "status": "pending",
      "adjustedBy": "670a1b2c3d4e5f6a7b8c9daa",
      "sourceType": "manual",
      "createdAt": "2026-07-20T16:30:00.000Z",
      "updatedAt": "2026-07-20T16:30:00.000Z"
    }
  ],
  "pagination": { "page": 1, "limit": 20, "total": 6, "pages": 1 }
}

Returns an object with an adjustments key (the array of adjustments) and pagination. There is no data/meta envelope: both keys sit at the root. Pagination is 1-indexed (page: 1 is the first page) and pages is the total number of pages, not the current one. Ordering is by creation date descending and is not configurable.

Parameters

pagenumber

Page, 1-indexed. Default: 1. Parsed with parseInt; a non-numeric value yields NaN and the query fails with 500.

limitnumber

Items per page. Default: 20. There is no maximum cap: asking for limit=100000 returns 100000 records in a single body.

statusstring

Filters by exact status. Closed list of three values: pending, approved, rejected. A value outside the list is not an error: it returns zero results.

locationIdstring

Filters by location (exact ObjectId match, not a partial search).

skustring

Filters by SKU (exact, case-sensitive match; it is not a prefix search).

reasonstring

Filters by reason. Closed list of eight values: count_correction, damage, theft, expired, found, return, supplier_error, other.

Aggregate summary

Aggregate totals for the tenant's adjustments over a date range.

200
{
  "totalAdjustments": 34,
  "positiveAdjustments": 12,
  "negativeAdjustments": 22,
  "totalQuantityAdjusted": -187,
  "totalCostImpact": 0
}

Returns five totals at the root of the response, with no envelope. If there is no adjustment in the range, it returns the same shape with all five fields at 0 — never an empty object or a 404.

Two details that change how the result should be read:

  • totalQuantityAdjusted is a net, not a volume. It sums adjustmentQuantity algebraically, so a +5 adjustment and a −5 one cancel out and the total comes back as 0 even though ten units moved.
  • totalCostImpact is always 0 for adjustments created through this API. It sums each record's totalCostImpact field, and the create endpoint never computes or fills it. Do not read it as financial impact.

It counts every adjustment in the range regardless of status: pending ones (which have not moved stock yet) weigh the same as approved ones.

Parameters

startDatestring

Start date, compared against createdAt. Parsed with the JavaScript Date constructor; ISO 8601 recommended. An unparseable date yields an invalid date and the query fails with 500.

endDatestring

End date, same parsing and same comparison against createdAt. If you omit both, the summary spans the tenant's entire history.

Get one adjustment

Gets an adjustment by its ID, within the token's tenant.

200
{
  "_id": "670a1b2c3d4e5f6a7b8c9d10",
  "tenantId": "69db07c8bce4d49b18c42a49",
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "sku": "CAM-ROJO-M",
  "oldQuantity": 140,
  "newQuantity": 137,
  "adjustmentQuantity": -3,
  "reason": "damage",
  "status": "pending",
  "adjustedBy": "670a1b2c3d4e5f6a7b8c9daa",
  "createdAt": "2026-07-20T16:30:00.000Z"
}
404no adjustment with that ID exists in your tenant
{
  "code": "not-found",
  "message": "Adjustment not found"
}

Returns the adjustment document flat at the root, with no envelope. An adjustment belonging to another tenant returns 404, never cross-tenant information.

A malformed ID returns 500, not 404

The id is passed straight to the query without validating its shape. If it is not a 24-character hexadecimal ObjectId, the conversion fails and the error reaches the generic handler: the response is 500 internal-error, not 404 not-found. Validate the ID shape in your client before calling, or you will treat a client error as a server outage.

Parameters

idstringrequired

Adjustment ID (24-character hexadecimal ObjectId). You get it when creating an adjustment or from the list.

Create an adjustment

Records an adjustment in pending state. It does NOT move stock: that happens on approval.

{
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "sku": "CAM-ROJO-M",
  "newQuantity": 137,
  "reason": "damage",
  "notes": "3 piezas mojadas en el anden"
}
201
{
  "_id": "670a1b2c3d4e5f6a7b8c9d10",
  "tenantId": "69db07c8bce4d49b18c42a49",
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "sku": "CAM-ROJO-M",
  "oldQuantity": 140,
  "newQuantity": 137,
  "adjustmentQuantity": -3,
  "reason": "damage",
  "notes": "3 piezas mojadas en el anden",
  "status": "pending",
  "adjustedBy": "670a1b2c3d4e5f6a7b8c9daa",
  "sourceType": "manual",
  "createdAt": "2026-07-20T16:30:00.000Z",
  "updatedAt": "2026-07-20T16:30:00.000Z"
}
400locationId missing
{
  "code": "bad-request/missing-location",
  "message": "Location is required",
  "parameter": "locationId"
}
400sku missing
{
  "code": "bad-request/missing-sku",
  "message": "SKU is required",
  "parameter": "sku"
}
400newQuantity missing or not a number
{
  "code": "bad-request/missing-quantity",
  "message": "New quantity is required and must be a number",
  "parameter": "newQuantity"
}
400reason missing
{
  "code": "bad-request/missing-reason",
  "message": "Reason is required",
  "parameter": "reason"
}

Returns 201 with the created adjustment, flat at the root and with no envelope. Three of its fields are computed by the server and whatever you send in them is ignored:

  • oldQuantity is read from that SKU's current stock at that location at creation time. If no inventory record exists, it is 0.
  • adjustmentQuantity is computed as newQuantity − oldQuantity. It is the only signed field: negative subtracts, positive adds.
  • status is forced to pending and adjustedBy to the token's user.

newQuantity is an absolute quantity, not a delta: sending newQuantity: 137 means "leave it at 137", not "add 137 to it".

A reason outside the list returns 500, not 400

The endpoint only checks that reason is present; it does not validate its value. The closed list is enforced by the database on save, and that rejection reaches the generic handler: sending an unknown reason returns 500 internal-error, not a 400 describing the problem.

Eight values are accepted: count_correction, damage, theft, expired, found, return, supplier_error, other. Plausible-looking names that the API rejects with 500 include shrinkage, restock, sample and sale. If your operation needs to single out shrinkage, use damage or other and describe it in notes.

The body has no allowlist: internal fields can be overwritten

The body is passed to the model without filtering through a list of permitted fields. Any field that exists in the schema and is not one of the four the server computes is persisted as sent — including audit fields such as approvedBy, approvedAt, unitCost, totalCostImpact, sourceType and sourceId. A client can therefore plant a fake audit trail without having approved anything. Fields the schema does not declare are dropped silently, with no error. This is tracked as technical debt.

Parameters

locationIdstringrequired

Location whose stock is being corrected (ObjectId). Its existence is not validated: a non-existent ID still creates the adjustment.

skustringrequired

SKU to adjust. It is not validated against the product catalog: a non-existent SKU still creates the adjustment.

newQuantitynumberrequired

ABSOLUTE quantity the SKU should end up at, not a delta. It must be of type number: a string like '137' returns 400 bad-request/missing-quantity.

reasonstringrequired

Reason for the adjustment. Closed list of eight values: count_correction, damage, theft, expired, found, return, supplier_error, other. Any other value returns 500 — see the warning above.

notesstring

Free-text note for the audit trail. It is the only place for the detail the eight reasons cannot distinguish.

productSkustring

Parent product SKU when the adjusted SKU is a variant. It is stored as sent: the server does NOT infer it if you omit it, and the adjustment is left without it.

lotIdstring

Lot the adjustment applies to. Use it to write off an expired lot (with reason expired): the write-off is recorded as scrap at that lot's cost. See [Lots and valuation](/en/api/inventory/lots).

positionIdstring

Position of a receiving flow. With positionId the adjustment corrects the in-process merchandise (inProcess) of that stage; without it, it corrects stock. A difference in a stage is fixed with this adjustment, with sourceType flow. See [Receipts and receiving tray](/en/api/inventory/receipts).

sourceTypestring

Origin of the adjustment. Accepted values: manual, count, import, order, reversal, transfer, flow. The flow value marks an adjustment of a receiving flow stage.

Approve an adjustment

Approves a pending adjustment and WRITES newQuantity onto stock.

{}
200
{
  "_id": "670a1b2c3d4e5f6a7b8c9d10",
  "sku": "CAM-ROJO-M",
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "oldQuantity": 140,
  "newQuantity": 137,
  "adjustmentQuantity": -3,
  "status": "approved",
  "approvedBy": "670a1b2c3d4e5f6a7b8c9dbb",
  "approvedAt": "2026-07-21T09:15:00.000Z"
}
404the adjustment does not exist, or is no longer pending
{
  "code": "not-found",
  "message": "Adjustment not found or cannot be approved"
}

Returns the adjustment now in approved, flat at the root, with approvedBy and approvedAt stamped. As a side effect it writes stock: it sets that SKU's inventory at that location to newQuantity. No body is required; the handler does not read one.

Approving SETS stock to newQuantity and overwrites anything that happened meanwhile

Approval does not apply the adjustmentQuantity delta: it overwrites stock with the absolute newQuantity computed when the adjustment was created. If sales or a receipt landed between creation and approval, that movement is lost: an adjustment created when there were 140 and approved three days later leaves 137 even if real stock was 152.

Approve promptly, or create the adjustment at the moment you approve it. If the inventory record does not exist, approval creates it with that quantity.

An adjustment that was already approved or rejected returns 404 with the same body as a non-existent one, so you cannot tell "does not exist" from "already resolved" by the response. Fetch the adjustment first to learn its state.

Parameters

idstringrequired

ID of the adjustment to approve. It must be in status pending; any other status returns 404.

Reject an adjustment

Rejects a pending adjustment. It does not move stock, because none had been applied.

{ "rejectionReason": "El conteo fisico no coincide con el reporte" }
200
{
  "_id": "670a1b2c3d4e5f6a7b8c9d10",
  "sku": "CAM-ROJO-M",
  "status": "rejected",
  "rejectionReason": "El conteo fisico no coincide con el reporte",
  "rejectedAt": "2026-07-21T09:20:00.000Z"
}
400no body
{
  "code": "bad-request/missing-body",
  "message": "Request body with rejection reason is required"
}
400body without rejectionReason or reason
{
  "code": "bad-request/missing-reason",
  "message": "Rejection reason is required",
  "parameter": "rejectionReason"
}
404the adjustment does not exist, or is no longer pending
{
  "code": "not-found",
  "message": "Adjustment not found or cannot be rejected"
}

Returns the adjustment in rejected with rejectionReason and rejectedAt, flat at the root. It moves no stock and creates no additional record: since creation applied nothing, rejecting merely closes the record.

There is no record of WHO rejected it

The rejecting user is passed to the service, but the adjustment schema has no field to store it: only rejectedAt and rejectionReason are persisted. The rejection's audit trail is left without an author, unlike approval, which does store approvedBy. If you need to know who rejected it, include it yourself in the rejectionReason text. This is tracked as technical debt.

Parameters

idstringrequired

ID of the adjustment to reject. It must be in status pending; any other status returns 404.

rejectionReasonstringrequired

Reason for the rejection, free text. The alternate name reason is accepted: the server takes rejectionReason and, if absent, reason. Sending either one satisfies the requirement.

Lifecycle

An adjustment has three states and no transition back:

StatusHow you get thereWhat happened to stock
pendingon creating the adjustmentnothing yet
approvedapprove on a pending onestock was set to newQuantity
rejectedreject on a pending onenothing; it was never applied

approved and rejected are terminal: a second approve or reject returns 404.

Physical counts also generate adjustments. On completing a count, each line with a variance produces a count_correction adjustment that is created already approved and with stock applied — those never pass through pending. See Counts.

Example — create and approve

# 1. Create the adjustment (does not move stock yet)
curl -X POST https://api.fenicia.io/inventory/adjustments \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "locationId": "670a1b2c3d4e5f6a7b8c9d01",
    "sku": "CAM-ROJO-M",
    "newQuantity": 137,
    "reason": "damage",
    "notes": "3 piezas mojadas en el anden"
  }'
 
# 2. Approve it: THIS is where stock is written
curl -X POST https://api.fenicia.io/inventory/adjustments/670a1b2c3d4e5f6a7b8c9d10/approve \
  -H "Authorization: Bearer fkapi_your_api_key"

See the error catalog for the codes shared across the whole domain.

Next steps