# Stock changes

Path: `/guide/stock-changes`

Beyond the order flows, you often need the current stock picture. Pulpo exposes both
webhooks that include stock updates and endpoints to query stock per product and per
location.

## Query endpoints

**Endpoint: Get stock summary** — `GET /inventory/stocks/summary` (operationId: getStockSummary)Aggregated stock summary per product.
**Endpoint: Get stock by product and location** — `POST /inventory/stocks/products/locations` (operationId: getStockByLocation)Stock per product and per location.
**Endpoint: List stock records** — `GET /inventory/stocks` (operationId: listStocks)List stock records with filtering.

## Correcting stock

**Endpoint: Correct stock at a location** — `POST /inventory/stocks/correct` (operationId: correctStock)

Add or remove stock for a product at a location. `quantity` is signed — positive adds,
negative removes. Not a `/bulk/` path, but you can still send multiple `items` in one
request.

For a plain product (not lot or serial managed), send `location_id`, `product_id`, and
`quantity`:

```json
{
  "warehouse_id": 140,
  "items": [
    { "location_id": 229364, "product_id": 1957711, "quantity": 5 }
  ]
}
```

For a lot or serial managed product, also include `item_batches` — one entry per
batch affected. For a `serial` product each batch's `quantity` must be `1` (a serial
is a single unique unit); for `lot` it can be any amount:

```json
{
  "warehouse_id": 140,
  "items": [
    {
      "location_id": 229364,
      "product_id": 1957712,
      "quantity": 5,
      "item_batches": [
        { "batch_id": 45231, "quantity": 5 }
      ]
    }
  ]
}
```

> **WARNING: Removing more than is available**
>
> A negative `quantity` larger than what's actually at that location is rejected with a
> 422 (`not_enough_stock_to_remove_for_given_location_product_batch`), not silently
> floored at zero.

> **TIP: Recommended batch size**
>
> Up to 50 corrections (`items` entries) per request.

## Events

Several webhooks carry stock update information — for example the incoming
`replenishment_order_finished` (stock available), kitting stock movements, and counting/audit
adjustments. Subscribe to the ones relevant to your reconciliation logic.

**Webhook event:&#x20;**`stock_correction_finished`

Fired after a `correctStock` call completes. `items[].quantity` is the same signed
delta you sent — negative here means stock was removed. `reason_codes` is only present
if you sent one.

Sample payload:

```json
{
  "data": {
    "id": 55441,
    "sequence_number": "SC-0000022",
    "warehouse_id": 2236,
    "owner_id": 4625,
    "owner": {
      "id": 4625,
      "username": "simon_user1",
      "first_name": "Lilyan",
      "last_name": "Rogahn"
    },
    "comment": null,
    "reason_codes": [
      {
        "id": 198,
        "code": "pulpo_0000001",
        "name": "return"
      }
    ],
    "inserted_at": "2026-09-23T13:46:40",
    "items": [
      {
        "id": 219246,
        "product_id": 9169276,
        "location_id": 986900,
        "quantity": -12,
        "batches": [],
        "loading_unit_location_id": null,
        "location": {
          "id": 986900,
          "code": "M-1-1-1-1-1",
          "warehouse_id": 2236
        },
        "product": {
          "id": 9169276,
          "sku": "NP0001",
          "name": "T-Shirt 1",
          "management_type": "none"
        }
      }
    ]
  },
  "id": "587e93c6-8e90-416b-ab07-04aa88e48926",
  "status": "triggered",
  "type": "stock_correction_finished",
  "retry": false,
  "inserted_at": "2026-09-23T13:46:40",
  "updated_at": "2026-09-23T13:46:40",
  "warehouse_id": 2236,
  "merchant_id": 1053,
  "merchant_channel_id": 1068,
  "webhook_id": null,
  "merchant_channel_name": "default",
  "merchant_name": "default",
  "warehouse_name": "simon_warehouse_1",
  "pre_event_data": null
}
```

**Webhook event:&#x20;**`counting_task_closed`

Fired when a counting/audit task for a location is closed. Per item, compare `quantity`
(what the counter found) against `current_stock_quantity` (what the system had on
record) to spot discrepancies — surplus, shortage, or a match. Batch-controlled products
get one item per batch; `reason_codes` explains a counted discrepancy when the counter
logged one.

Sample payload:

```json
{
  "data": {
    "id": 37194,
    "type": "location",
    "state": "closed",
    "sequence_number": "CT-0000012",
    "warehouse_id": 2236,
    "location_id": 986900,
    "location": {
      "id": 986900,
      "code": "M-1-1-1-1-1",
      "warehouse_id": 2236
    },
    "owner_id": 4625,
    "counter_id": 4625,
    "auditor_id": 4625,
    "auditor": {
      "id": 4625,
      "username": "simon_user1",
      "first_name": "Lilyan",
      "last_name": "Rogahn"
    },
    "count_iteration": 1,
    "inserted_at": "2026-09-23T13:49:20",
    "iteration_started_at": "2026-09-23T13:49:39",
    "audited_at": "2026-09-23T13:51:28",
    "items": [
      {
        "id": 69347,
        "product_id": 9169276,
        "location_id": 986900,
        "quantity": 400,
        "current_stock_quantity": 507,
        "batch_id": null,
        "is_valid": true,
        "reason_codes": [],
        "product": {
          "id": 9169276,
          "sku": "NP0001",
          "name": "T-Shirt 1",
          "management_type": "none"
        }
      },
      {
        "id": 69349,
        "product_id": 10277019,
        "location_id": 986900,
        "quantity": 12,
        "current_stock_quantity": 0,
        "batch_id": null,
        "is_valid": true,
        "reason_codes": [
          {
            "reason_type": "counter",
            "reason_code": {
              "id": 198,
              "code": "pulpo_0000001",
              "name": "return"
            }
          }
        ],
        "product": {
          "id": 10277019,
          "sku": "TEST-WNNUOK",
          "name": "Classic Wireless Mouse A5 WNNUOK",
          "management_type": "none"
        }
      },
      {
        "id": 69351,
        "product_id": 9169279,
        "location_id": 986900,
        "quantity": 0,
        "current_stock_quantity": 100,
        "batch_id": 204317,
        "batch": {
          "id": 204317,
          "number": "432432",
          "expiration_date": "2029-07-09"
        },
        "is_valid": true,
        "reason_codes": [],
        "product": {
          "id": 9169279,
          "sku": "LP0001",
          "name": "Drink 1",
          "management_type": "lot"
        }
      }
    ]
  },
  "id": "14b9b1d9-4017-41c0-96d8-baeb291faad3",
  "status": "triggered",
  "type": "counting_task_closed",
  "retry": false,
  "inserted_at": "2026-09-23T13:51:28",
  "updated_at": "2026-09-23T13:51:28",
  "warehouse_id": 2236,
  "merchant_id": 1053,
  "merchant_channel_id": 1068,
  "webhook_id": null,
  "merchant_channel_name": "default",
  "merchant_name": "default",
  "warehouse_name": "simon_warehouse_1",
  "pre_event_data": null
}
```

> **TIP: Reconcile efficiently**
>
> Prefer the aggregated summary endpoint for periodic reconciliation, and rely on webhooks for
> near-real-time deltas. See [best practices](/guide/best-practices) for pagination and rate
> limits.

---

Website version: https://connect.pulpo.co/guide/stock-changes
Whole guide in one file: https://connect.pulpo.co/llms-full.txt
Index of all pages: https://connect.pulpo.co/llms.txt
