> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zenflow.com.ar/llms.txt
> Use this file to discover all available pages before exploring further.

# Crear Ajuste de Stock

> Agregar o remover stock (ajuste relativo)

# Crear Ajuste de Stock

Crea un ajuste de stock agregando o removiendo una cantidad.

<Note>Requiere scope `write:stock`.</Note>

## Solicitud

```bash theme={null}
POST /api/v1/stock/adjustment
```

### Parámetros del Body

<ParamField body="product_id" type="integer">
  ID del producto (o usar sku)
</ParamField>

<ParamField body="sku" type="string">
  SKU del producto (alternativa a product\_id)
</ParamField>

<ParamField body="location_id" type="string" required>
  ID de la ubicación
</ParamField>

<ParamField body="adjustment_quantity" type="number" required>
  Cantidad a agregar (positivo) o remover (negativo)
</ParamField>

<ParamField body="reason" type="string">
  Razón del ajuste
</ParamField>

## Ejemplos

### Agregar Stock

```bash theme={null}
curl -X POST "https://api.zenflow.com.ar/api/v1/stock/adjustment" \
  -H "X-API-Key: zenflow_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": 100,
    "location_id": "LOC-A1",
    "adjustment_quantity": 25,
    "reason": "Recibido de proveedor"
  }'
```

#### Respuesta

```json theme={null}
{
  "success": true,
  "data": {
    "type": "addition",
    "quantity_adjusted": 25,
    "stock": {
      "product_id": 100,
      "location_id": "LOC-A1",
      "previous_quantity": 50,
      "new_quantity": 75
    }
  }
}
```

### Remover Stock

```bash theme={null}
curl -X POST "https://api.zenflow.com.ar/api/v1/stock/adjustment" \
  -H "X-API-Key: zenflow_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "sku": "SKU-001",
    "location_id": "LOC-A1",
    "adjustment_quantity": -10,
    "reason": "Items dañados removidos"
  }'
```

#### Respuesta

```json theme={null}
{
  "success": true,
  "data": {
    "type": "removal",
    "quantity_adjusted": -10,
    "stock": {
      "product_id": 100,
      "location_id": "LOC-A1",
      "previous_quantity": 75,
      "new_quantity": 65
    }
  }
}
```

## Respuestas de Error

### 400 Cantidad Cero

```json theme={null}
{
  "success": false,
  "error": {
    "code": "validation_error",
    "message": "adjustment_quantity no puede ser cero"
  }
}
```

### 400 Stock Insuficiente

```json theme={null}
{
  "success": false,
  "error": {
    "code": "adjustment_error",
    "message": "Stock insuficiente. Disponible: 5, Solicitado: 10"
  }
}
```

### 404 Producto No Encontrado

```json theme={null}
{
  "success": false,
  "error": {
    "code": "not_found",
    "message": "Producto no encontrado"
  }
}
```
