Skip to main content
POST
Ajustar el stock de un producto
Records a stock entry or exit. A positive delta adds stock, a negative one removes it. Without branch_id the change happens in the warehouse; with it, in that branch. The change is synced to the stores you have connected, and it leaves an adjustment entry in the stock movements.

Endpoint

Required scope

ecommerce:stock:write
The scope comes from your role. Minting a token with ecommerce:stock:write requires the permission to adjust and transfer stock in your Keebai role, unless you are the company owner or a superuser. See scopes.

Headers

Path parameters

Body

Example request

Response

200 OK

The product’s stock after the adjustment, in the same shape as GET /v1/ecommerce/products/{id}/stock.

400 Bad Request

The body does not match the schema — for example delta is 0 or not an integer — or one of these:

401 Unauthorized

Missing, invalid, revoked, or expired token.

403 Forbidden

The token does not have the ecommerce:stock:write scope.

404 Not Found

No product with that id, or it belongs to a different company.

502 Bad Gateway

ECOMMERCE_UPSTREAM_ERROR — the ecommerce service could not answer.

Operational notes

  • The change reaches your stores. Connected stores receive the new stock, so an adjustment here is what customers see online.
  • This call is not idempotent. Retrying after a timeout applies the delta twice. Check the stock movements before retrying.
  • To move stock between branches, transfer it. POST .../stock/transfer keeps the total; two adjustments would record an exit and an entry instead.

Authorizations

Authorization
string
header
required

Personal Access Token con prefijo kbai_pk_. Generar desde el portal con permiso developer.manage_tokens.

Path Parameters

id
string
required

Body

application/json
delta
number
required

Unidades a sumar (positivo) o restar (negativo). Entero distinto de 0

Example:

-2

variant_id
string

ObjectId de la variante. Obligatorio si el producto tiene más de una

branch_id
string

Sucursal donde se mueve el stock. Sin ella, el ajuste es sobre la bodega

note
string

Motivo del ajuste

Maximum string length: 500

Response

200 - application/json
product_id
string
required
variants
object[]
required