---
title: "Ingest inventory snapshot or delta batch"
method: POST
path: "/api/v1/inventory"
tags: ["inventory"]
---

# Ingest inventory snapshot or delta batch

`POST /api/v1/inventory`

Validates a batch of inventory items and publishes them to Kafka for asynchronous processing. The discriminator field "updateType" (SNAPSHOT|DELTA) at the root selects the validation schema and the resulting event type. SNAPSHOT overwrites the position (onHand, blocked, safetyStock); DELTA increments or decrements onHand. Returns 202 with a correlation id shared by every published event of the batch.

## Request body

- union
  - InventorySnapshotIngest
    - `items` InventorySnapshotItemIngest[], required — Batch de posições absolutas (1..5000). Sobrescreve onHand, blocked e safetyStock da posição.
      - `blocked` number, required — Quantidade bloqueada na posição (inteiro >= 0).
      - `onHand` number, required — Quantidade física disponível na posição (inteiro >= 0).
      - `safetyStock` number, required — Estoque de segurança configurado (inteiro >= 0).
      - `sku` string, required — SKU do produto.
      - `strategyCode` string, required — Código da strategy (posição de estoque).
    - `updateType` 'SNAPSHOT' | 'DELTA', required — Discriminador do modo de ingestão. Para snapshot, deve ser exatamente "SNAPSHOT".
  - InventoryDeltaIngest
    - `items` InventoryDeltaItemIngest[], required — Batch de movimentações incrementais (1..1000). Incrementa/decrementa onHand da posição.
      - `eventId` string, required — Identificador único da movimentação no sistema origem. Usado como chave de dedup no consumer.
      - `quantity` number, required — Variação inteira a aplicar em onHand. Pode ser negativa (saída) ou positiva (entrada).
      - `reason` 'ADJUSTMENT' | 'ERP_SYNC' | 'ORDER_RELEASED' | 'ORDER_RESERVED' | 'POS_SALE' | 'RETURN_RECEIVED' | 'SAFETY_STOCK_CONFIG' | 'STOCK_SHORTAGE' | 'TRANSFER', required — Motivo da movimentação. Apenas reasons externos do ERP/WMS são aceitos aqui: POS_SALE, ADJUSTMENT, TRANSFER, ERP_SYNC.
      - `sku` string, required — SKU do produto.
      - `strategyCode` string, required — Código da strategy (posição de estoque).
    - `updateType` 'SNAPSHOT' | 'DELTA', required — Discriminador do modo de ingestão. Para delta, deve ser exatamente "DELTA".

## Response `202`

Batch accepted and published to Kafka.

- InventoryIngestResponse
  - `accepted` number, required — Number of items accepted and published to Kafka (always equals items.length on 202).
  - `correlation_id` string, required — Batch correlation id (UUID v4) shared by every published event.
  - `update_type` 'SNAPSHOT' | 'DELTA', required — Update mode of the accepted batch.

## Other responses

- `400` — Invalid payload: missing or unsupported updateType, schema violation on any item, or batch size out of bounds.
- `401` — Authentication is missing, malformed, expired, or refers to a session that is no longer active.
- `403` — The caller is authenticated but lacks the required permission for this action.
- `500` — Unexpected server error. The response body never leaks internal details.
- `503` — The message bus rejected or timed out the publish. The batch was not accepted; retry.

---

[API](https://skmtc.dev/kruzer-corp/apis/oms-api.md) · [All operations](https://skmtc.dev/kruzer-corp/apis/oms-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/kruzer-corp/oms-api/revisions/985f572bb039/schema)
