Inventory Reports

A single endpoint generates five report types depending on the reportType parameter. The response shape changes completely between types: do not assume a shared schema. All five share only two fields (reportType and generatedAt); everything else varies.

Generates a report of the requested type. The response shape depends on reportType.

200reportType=inventory
{
  "reportType": "inventory",
  "generatedAt": "2026-08-14T18:04:11.512Z",
  "data": [
    {
      "_id": "670a1b2c3d4e5f6a7b8c9d0e",
      "tenantId": "69db07c8bce4d49b18c42a49",
      "sku": "CAM-ROJO-M",
      "productSku": "CAM-ROJO",
      "locationId": "670a1b2c3d4e5f6a7b8c9d01",
      "stock": 137,
      "compromised": 4,
      "createdAt": "2026-05-02T10:11:00.000Z",
      "updatedAt": "2026-08-14T17:55:03.000Z"
    }
  ],
  "summary": { "totalItems": 1, "locationId": "670a1b2c3d4e5f6a7b8c9d01" }
}
200reportType=transfers
{
  "reportType": "transfers",
  "generatedAt": "2026-08-14T18:04:11.512Z",
  "period": { "startDate": "2026-07-01T00:00:00.000Z", "endDate": "2026-07-31T23:59:59.000Z" },
  "data": [
    {
      "_id": "670a1b2c3d4e5f6a7b8c9d0f",
      "tenantId": "69db07c8bce4d49b18c42a49",
      "originId": "670a1b2c3d4e5f6a7b8c9d01",
      "destinationId": "670a1b2c3d4e5f6a7b8c9d02",
      "productsList": [{ "sku": "CAM-ROJO-M", "reassignAmount": 10, "originAmount": 137 }],
      "status": "received",
      "createdAt": "2026-07-14T09:00:00.000Z"
    }
  ],
  "summary": { "total": 1, "byStatus": { "received": 1 } }
}
200reportType=adjustments
{
  "reportType": "adjustments",
  "generatedAt": "2026-08-14T18:04:11.512Z",
  "period": { "startDate": "2026-07-01T00:00:00.000Z", "endDate": "2026-07-31T23:59:59.000Z" },
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "data": [
    {
      "_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"
    }
  ],
  "summary": { "total": 1, "totalQuantityAdjusted": -3, "byReason": { "damage": 1 } }
}
200reportType=counts
{
  "reportType": "counts",
  "generatedAt": "2026-08-14T18:04:11.512Z",
  "period": { "startDate": "2026-07-01T00:00:00.000Z", "endDate": "2026-07-31T23:59:59.000Z" },
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "data": [
    {
      "_id": "670a1b2c3d4e5f6a7b8c9d11",
      "tenantId": "69db07c8bce4d49b18c42a49",
      "locationId": "670a1b2c3d4e5f6a7b8c9d01",
      "name": "Conteo ciclico julio",
      "countType": "cycle",
      "status": "completed",
      "countItems": [],
      "createdBy": "670a1b2c3d4e5f6a7b8c9daa",
      "createdAt": "2026-07-05T08:00:00.000Z"
    }
  ],
  "summary": { "total": 1, "byStatus": { "completed": 1 } }
}
200reportType=valuation
{
  "reportType": "valuation",
  "generatedAt": "2026-08-14T18:04:11.512Z",
  "locationId": "670a1b2c3d4e5f6a7b8c9d01",
  "data": [
    { "sku": "CAM-ROJO-M", "stock": 137, "totalValue": 0, "locationId": "670a1b2c3d4e5f6a7b8c9d01" }
  ],
  "summary": { "totalItems": 1, "totalUnits": 137, "totalValue": 0, "averageUnitCost": 0 }
}
400reportType missing
{
  "code": "bad-request/missing-type",
  "message": "Report type is required",
  "parameter": "reportType"
}
400unknown reportType
{
  "code": "bad-request/invalid-report",
  "message": "Unknown report type: ventas"
}
405any method other than GET
{
  "code": "method-not-allowed",
  "message": "Method POST not allowed"
}

Returns the report object with no envelope: the reportType, generatedAt, data and summary fields sit at the root of the response, not inside data or meta. data is always an array and summary always an object, but the contents of both depend on reportType. Types transfers, adjustments and counts additionally include period; adjustments, counts and valuation additionally include locationId.

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 reaches any inventory route, whether or not it holds the inventory:read scope — including an API key issued for a different domain. 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. Do not design your access model assuming these endpoints filter by permission; this is tracked as technical debt.

Parameters

reportTypestringrequired

Report type. Closed list of five values: inventory, transfers, adjustments, counts, valuation. Any other value returns 400 bad-request/invalid-report.

startDatestring

Start date, parsed with the JavaScript Date constructor (ISO 8601 recommended). Only reportType=transfers, adjustments and counts use it; the inventory and valuation types ignore it silently.

endDatestring

End date, same parsing and same scope as startDate.

locationIdstring

Filters by location. Only reportType=inventory, adjustments, counts and valuation use it; the transfers type ignores it silently.

formatstring

Closed list of two values: json, csv. It has NO effect — see the warning below; the response is always JSON.

format is accepted and discarded: it never produces CSV

The format parameter is read and passed to the library, which destructures it with a default of json and never uses it again. Sending format=csv returns exactly the same JSON, with 200, and no signal at all that the conversion did not happen. Do not build a CSV export flow on top of this parameter.

No report is paginated, and two of them are capped

No type accepts page or limit: they always return the full set in a single body. reportType=inventory is capped at 10,000 records by an internal constant, and the cut is not signalled by any field in the response — a tenant with more than 10,000 inventory records receives a truncated report indistinguishable from a complete one. The transfers, adjustments and counts types have no cap at all, so their size grows without bound with the tenant's age; always bound them with startDate/endDate.

What each type returns

reportType=inventory

Snapshot of current stock. data holds the inventory documents exactly as stored (sku, productSku, locationId, stock, compromised, timestamps). summary.locationId echoes the requested location, or the literal string "all" if you sent none. It does not use startDate/endDate.

reportType=transfers

The tenant's transfers bounded by creation date, sorted newest first. summary.byStatus counts only the statuses present in the result: if no transfer is cancelled, the cancelled key is absent — do not expect it at zero. This type ignores locationId: you cannot report transfers for a single location here.

reportType=adjustments

Adjustments bounded by date and, optionally, by locationId. summary.totalQuantityAdjusted is the algebraic sum of adjustmentQuantity, so a +5 adjustment and a −5 one cancel out and the total comes back as 0: it is a net, not a volume. summary.byReason counts by reason and, like byStatus, lists only the reasons present.

reportType=counts

Counts bounded by date and locationId. Each element of data includes its full countItems array, so a physical count of a large location produces a very heavy response.

reportType=valuation

Valuation always reports zero: do not use it for money decisions

This report computes totalValue as stock × unitCost, but the inventory schema has no unitCost field — it does not exist in the collection. The value read is always undefined, so totalValue comes back as 0 on every row and summary.totalValue and summary.averageUnitCost come back as 0 for the whole tenant. This is not a rounding issue or an edge case: it is the result for any inventory, at any stock level.

And because unitCost and productName end up undefined, they disappear from the JSON (JSON.stringify drops undefined keys): each row of data arrives with only sku, stock, totalValue and locationId, even though the code names six fields. A client reading item.unitCost gets undefined, not 0.

This is tracked as technical debt; until it is fixed, treat this report type as unavailable.

Example

curl -G https://api.fenicia.io/inventory/reports \
  -H "Authorization: Bearer fkapi_your_api_key" \
  --data-urlencode "reportType=adjustments" \
  --data-urlencode "startDate=2026-07-01T00:00:00Z" \
  --data-urlencode "endDate=2026-07-31T23:59:59Z"

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

Next steps