# Inventory

Warehouses, stock, movements (kardex) and adjustments: each invoice that sells a product with track_stock takes out what it sells.

The guide, step by step: https://fiscalisto.com/en/docs/api/inventario.md

## Endpoints

- [List warehouses](https://fiscalisto.com/en/docs/api/referencia/inventario/list-warehouses.md): `GET /v1/warehouses`
- [Get a warehouse](https://fiscalisto.com/en/docs/api/referencia/inventario/get-warehouse.md): `GET /v1/warehouses/{id}`
- [Get a warehouse's stock](https://fiscalisto.com/en/docs/api/referencia/inventario/list-warehouse-stock.md): `GET /v1/warehouses/{id}/stock`
- [Get a product's stock](https://fiscalisto.com/en/docs/api/referencia/inventario/get-product-stock.md): `GET /v1/products/{id}/stock`
- [List movements (kardex)](https://fiscalisto.com/en/docs/api/referencia/inventario/list-stock-movements.md): `GET /v1/stock_movements`
- [Get a movement](https://fiscalisto.com/en/docs/api/referencia/inventario/get-stock-movement.md): `GET /v1/stock_movements/{id}`
- [Adjust stock](https://fiscalisto.com/en/docs/api/referencia/inventario/create-stock-adjustment.md): `POST /v1/stock_adjustments`
- [List adjustments](https://fiscalisto.com/en/docs/api/referencia/inventario/list-stock-adjustments.md): `GET /v1/stock_adjustments`
- [Get an adjustment](https://fiscalisto.com/en/docs/api/referencia/inventario/get-stock-adjustment.md): `GET /v1/stock_adjustments/{id}`
- [Create a production order](https://fiscalisto.com/en/docs/api/referencia/inventario/create-production-order.md): `POST /v1/production_orders`
- [List production orders](https://fiscalisto.com/en/docs/api/referencia/inventario/list-production-orders.md): `GET /v1/production_orders`
- [Get a production order](https://fiscalisto.com/en/docs/api/referencia/inventario/get-production-order.md): `GET /v1/production_orders/{id}`
- [Start a production order](https://fiscalisto.com/en/docs/api/referencia/inventario/start-production-order.md): `POST /v1/production_orders/{id}/start`
- [Finish a production order](https://fiscalisto.com/en/docs/api/referencia/inventario/complete-production-order.md): `POST /v1/production_orders/{id}/complete`
- [Cancel a production order](https://fiscalisto.com/en/docs/api/referencia/inventario/cancel-production-order.md): `POST /v1/production_orders/{id}/cancel`

## The Warehouse object

An issuer's warehouse: one for the Matriz and one per branch are created on their own; each invoice takes stock out of its branch's warehouse.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"warehouse"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The warehouse's issuer. |
| `name` | string | yes | Its name («Matriz», its branch's, or the one given in the app). |
| `code` | string or null | yes | Its short code, or null. |
| `type` | `warehouse`, `consignment` | yes | warehouse (own warehouse) or consignment (goods on consignment with a customer, still yours). |
| `branch` | string or null | yes | Its branch (brn_…), or null if it belongs to the Matriz. |
| `default` | boolean | yes | true si es el almacén del que vende y recibe su sucursal. |
| `archived` | boolean | yes | true if archived. |
| `created_at` | string (date-time) or null | yes | When it was created. |

Example:

```json
{
  "id": "whs_OufpKqnrvx9p1",
  "object": "warehouse",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "name": "Matriz",
  "code": null,
  "type": "warehouse",
  "branch": null,
  "default": true,
  "archived": false,
  "created_at": "2026-10-27T09:12:00-06:00"
}
```

## The StockMovement object

A stock entry or exit (the stock ledger): a sale, a purchase, an adjustment, a transfer…

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"stock_movement"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer. |
| `product` | string | yes | The product (prd_…). |
| `warehouse` | string | yes | The warehouse (whs_…). |
| `type` | `sale`, `purchase`, `customer_return`, `supplier_return`, `adjustment`, `count`, `transfer_out`, `transfer_in`, `production_consumption`, `production_output`, `initial`, `cost`, `reversal` | yes | sale (an invoice), purchase (a purchase), customer_return, supplier_return, adjustment, count (physical count), transfer_out, transfer_in, production_consumption (a component that went to production), production_output (what was produced), initial, cost (a cost adjustment) or reversal (undoes another, like a canceled invoice). |
| `quantity` | number | yes | How much came in (positive) or went out (negative). |
| `unit_cost` | number | yes | The unit cost it came in or went out with, in pesos without IVA. |
| `value` | number | yes | quantity × unit_cost: how much the inventory value changed. |
| `lot` | string or null | yes | The lot or serial number, or null. |
| `source` | object | yes | What caused it: type invoice (id is the CFDI's UUID), adjustment (adj_…), production (mfo_…), receipt, transfer, count or ticket. |
| `source.type` | string | yes | What moved it: invoice (an invoice; id is its UUID), adjustment (an adjustment, adj_…), production (a production order, mfo_…), count (a count) or another source. |
| `source.id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `reason` | string or null | yes | The reason for an adjustment, or null. |
| `date` | string or null | yes | When it happened, Mexico City time (the CFDI's Fecha on a sale). |
| `reversed` | boolean | yes | true if a later movement undid it. |
| `created_at` | string (date-time) or null | yes | When it was recorded. |

Example:

```json
{
  "id": "stm_OufpKqnrvx9p7",
  "object": "stock_movement",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "product": "prd_OufpKqnrvx9p2",
  "warehouse": "whs_OufpKqnrvx9p1",
  "type": "sale",
  "quantity": -2,
  "unit_cost": 90,
  "value": -180,
  "lot": null,
  "source": {
    "type": "invoice",
    "id": "5F1E8C2A-3B7D-4C9E-A1B2-C3D4E5F60718"
  },
  "reason": null,
  "date": "2026-10-27T10:15:42",
  "reversed": false,
  "created_at": "2026-10-27T10:15:43-06:00"
}
```

## The StockAdjustment object

A stock adjustment: what came into or went out of a warehouse for opening inventory, shrinkage, theft, a count…

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"stock_adjustment"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer. |
| `warehouse` | string | yes | The warehouse (whs_…). |
| `reason` | `shrinkage`, `theft`, `damage`, `expiration`, `internal_use`, `gift`, `initial`, `surplus`, `count`, `other` | yes | The reason (see POST /v1/stock_adjustments). |
| `note` | string or null | yes | Its note, or null. |
| `status` | `applied`, `pending`, `rejected`, `reversed` | yes | applied (it already moved stock), pending (awaiting approval in the app), rejected or reversed (it was undone). |
| `value` | number | yes | What what it moved is worth, in pesos without IVA. |
| `lines` | array of object | yes | What came in or went out of each product. |
| `lines[].product` | string | yes | A product from your catalog (prd_…): takes its key, unit, price and taxes. |
| `lines[].quantity` | number | yes | Quantity (Cantidad). 1 by default. |
| `lines[].unit_cost` | number or null | yes | The unit cost given to the adjustment, in pesos without IVA, or null (the average cost). |
| `lines[].lot` | string or null | yes | Medicine lot (LoteMedicamento). |
| `created_at` | string (date-time) or null | yes | When it was made. |

Example:

```json
{
  "id": "adj_OufpKqnrvx9p1",
  "object": "stock_adjustment",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "warehouse": "whs_OufpKqnrvx9p1",
  "reason": "initial",
  "note": "Inventario de apertura",
  "status": "applied",
  "value": 4500,
  "lines": [
    {
      "product": "prd_OufpKqnrvx9p2",
      "quantity": 50,
      "unit_cost": 90,
      "lot": null
    }
  ],
  "created_at": "2026-10-27T09:30:00-06:00"
}
```

## The ProductionOrder object

A production order: the recipe's components go out of one warehouse and what is produced goes into another at its real cost.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"production_order"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer. |
| `number` | string | yes | Its folio, like OP-12. |
| `status` | `draft`, `in_process`, `completed`, `cancelled` | yes | draft (nothing has moved), in_process (the components already went out), completed (what was produced already came in) or cancelled (everything went back). |
| `product` | string | yes | What is produced (prd_…). |
| `quantity` | number | yes | How many units were planned. |
| `quantity_made` | number or null | yes | How many actually came out, or null if it hasn't finished. |
| `warehouse` | string | yes | The warehouse the components come out of (whs_…). |
| `destination_warehouse` | string | yes | The warehouse what is produced goes into (whs_…). |
| `lot` | string or null | yes | The lot of what is produced, or null. |
| `due_date` | string or null | yes | By when (YYYY-MM-DD), or null. |
| `note` | string or null | yes | Its note, or null. |
| `components` | array of object | yes | What it takes, from the recipe for quantity with its shrinkage: quantity what was planned, quantity_used what went out and value what it cost (pesos without IVA). tracks_stock false is a service: it only adds its cost. |
| `components[].product` | string | yes | A product from your catalog (prd_…): takes its key, unit, price and taxes. |
| `components[].quantity` | number | yes | Quantity (Cantidad). 1 by default. |
| `components[].quantity_used` | number or null | yes | What actually went out of that component, or null before the order starts. |
| `components[].tracks_stock` | boolean | yes | true if it tracks stock; false is a service, which only adds its cost. |
| `components[].value` | number or null | yes | What the component used is worth (quantity times cost), or null when it has no cost. |
| `other_costs` | array of object | yes | Labor, gas, packaging…: they are added to the cost of what is produced. |
| `other_costs[].description` | string | yes | Description. |
| `other_costs[].amount` | number | yes | Amount. |
| `materials_cost` | number or null | yes | What the components that went out cost, or null before starting. |
| `unit_cost` | number or null | yes | (materials_cost + other_costs) ÷ quantity_made: the cost each unit came in at, or null if it hasn't finished. |
| `created_at` | string (date-time) or null | yes | When it was made. |
| `started_at` | string (date-time) or null | yes | When the components went out, or null. |
| `completed_at` | string (date-time) or null | yes | When what was produced came in, or null. |
| `cancelled_at` | string (date-time) or null | yes | When it was canceled, or null. |

Example:

```json
{
  "id": "mfo_OufpKqnrvx9p1",
  "object": "production_order",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "number": "OP-1",
  "status": "completed",
  "product": "prd_OufpKqnrvx9p5",
  "quantity": 20,
  "quantity_made": 19,
  "warehouse": "whs_OufpKqnrvx9p1",
  "destination_warehouse": "whs_OufpKqnrvx9p1",
  "lot": null,
  "due_date": "2026-11-20",
  "note": null,
  "components": [
    {
      "product": "prd_OufpKqnrvx9p3",
      "quantity": 20,
      "quantity_used": 20,
      "tracks_stock": true,
      "value": 400
    },
    {
      "product": "prd_OufpKqnrvx9p4",
      "quantity": 2,
      "quantity_used": 2,
      "tracks_stock": true,
      "value": 120
    }
  ],
  "other_costs": [
    {
      "description": "Gas",
      "amount": 80
    }
  ],
  "materials_cost": 520,
  "unit_cost": 31.5789,
  "created_at": "2026-11-19T09:00:00-06:00",
  "started_at": "2026-11-19T09:05:00-06:00",
  "completed_at": "2026-11-19T12:30:00-06:00",
  "cancelled_at": null
}
```

## The StockLevel object

What there is of a product in a warehouse, and what it is worth.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Its id (stl_…): the product in that warehouse. It works as starting_after. |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"stock_level"` | yes | What kind of object it is («invoice», «customer»…). |
| `product` | string | yes | The product (prd_…). |
| `warehouse` | string | yes | The warehouse (whs_…). |
| `on_hand` | number | yes | What there is, in the product's unit (all its lots). |
| `reserved` | number | yes | What is reserved by accepted quotes that haven't been invoiced. |
| `available` | number | yes | on_hand minus reserved: what can be sold. |
| `value` | number | yes | What that stock is worth at its cost, in pesos without IVA. |
| `average_cost` | number or null | yes | value / on_hand: the unit cost, or null without stock. |

Example:

```json
{
  "id": "stl_OufpKqnrvx9p4gfFC6",
  "object": "stock_level",
  "livemode": false,
  "product": "prd_OufpKqnrvx9p2",
  "warehouse": "whs_OufpKqnrvx9p1",
  "on_hand": 48,
  "reserved": 6,
  "available": 42,
  "value": 4320,
  "average_cost": 90
}
```
