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

# Adjust Inventory

> This endpoint adjusts inventory levels for stock reconciliation, damage, or other reasons.

### Body

<ParamField body="inventory_item_id" type="string">
  The unique identifier of the inventory item to adjust
</ParamField>

<ParamField body="adjustment_type" type="string">
  The type of adjustment (e.g., "reconciliation", "damage", "theft", "expiration", "return", "manual")
</ParamField>

<ParamField body="quantity_change" type="number">
  The quantity to adjust (positive for increase, negative for decrease)
</ParamField>

<ParamField body="reason" type="string">
  Detailed reason for the adjustment
</ParamField>

<ParamField body="warehouse_id" type="string">
  The warehouse where the adjustment is being made
</ParamField>

<ParamField body="location_id" type="string">
  The specific location within the warehouse
</ParamField>

<ParamField body="reference_number" type="string">
  Reference number for tracking (e.g., count sheet number, incident report)
</ParamField>

<ParamField body="cost_adjustment" type="number">
  The cost impact of this adjustment for accounting purposes
</ParamField>

### Response

<ResponseField name="id" type="string">
  The unique identifier of the adjustment record
</ResponseField>

<ResponseField name="inventory_item_id" type="string">
  The inventory item that was adjusted
</ResponseField>

<ResponseField name="adjustment_type" type="string">
  The type of adjustment performed
</ResponseField>

<ResponseField name="quantity_before" type="number">
  The quantity before adjustment
</ResponseField>

<ResponseField name="quantity_after" type="number">
  The quantity after adjustment
</ResponseField>

<ResponseField name="quantity_change" type="number">
  The actual quantity change applied
</ResponseField>

<ResponseField name="cost_impact" type="number">
  The financial impact of this adjustment
</ResponseField>

<ResponseField name="adjusted_by" type="string">
  The user who performed the adjustment
</ResponseField>

<ResponseField name="adjusted_at" type="string">
  Timestamp when the adjustment was made
</ResponseField>

<ResponseField name="success" type="boolean">
  Indicates whether the adjustment was successful
</ResponseField>

### Error Responses

<ResponseField name="error" type="object">
  Error object containing details about what went wrong

  <Expandable title="properties">
    <ResponseField name="code" type="string">
      Error code (e.g., "insufficient\_stock", "invalid\_quantity", "warehouse\_not\_found")
    </ResponseField>

    <ResponseField name="message" type="string">
      Human-readable error message
    </ResponseField>

    <ResponseField name="details" type="object">
      Additional error details
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request POST 'https://api.stateset.com/v1/inventory_items/:id/adjust' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Token <token>' \
  --data-raw '{
      "inventory_item_id": "inv_abc123",
      "adjustment_type": "reconciliation",
      "quantity_change": -5,
      "reason": "Physical count showed 5 less than system",
      "warehouse_id": "wh_east_01",
      "location_id": "loc_a1_shelf_3",
      "reference_number": "COUNT_2024_001",
      "cost_adjustment": -125.00
  }'
  ```

  ```graphQL GraphQL theme={null}
  mutation inventoryAdjustMutation {
    inventoryAdjust(
      inventoryItemId: "${inventoryItemId}",
      adjustmentType: "${adjustmentType}",
      quantityChange: ${quantityChange},
      reason: "${reason}",
      warehouseId: "${warehouseId}",
      locationId: "${locationId}",
      referenceNumber: "${referenceNumber}",
      costAdjustment: ${costAdjustment}
    ) {
      adjustment {
        id
        quantity_before
        quantity_after
        quantity_change
        cost_impact
      }
      userErrors {
        field
        message
      }
    }
  }
  ```

  ```js Node.js theme={null}
  const adjustment = await stateset.inventory.adjust({
    inventory_item_id: 'inv_abc123',
    adjustment_type: 'reconciliation',
    quantity_change: -5,
    reason: 'Physical count showed 5 less than system',
    warehouse_id: 'wh_east_01',
    location_id: 'loc_a1_shelf_3',
    reference_number: 'COUNT_2024_001',
    cost_adjustment: -125.00
  });
  ```

  ```python Python theme={null}
  adjustment = stateset.inventory.adjust({
    'inventory_item_id': 'inv_abc123',
    'adjustment_type': 'reconciliation',
    'quantity_change': -5,
    'reason': 'Physical count showed 5 less than system',
    'warehouse_id': 'wh_east_01',
    'location_id': 'loc_a1_shelf_3',
    'reference_number': 'COUNT_2024_001',
    'cost_adjustment': -125.00
  })
  ```

  ```ruby Ruby theme={null}
  adjustment = Stateset::Inventory.adjust({
    inventory_item_id: 'inv_abc123',
    adjustment_type: 'reconciliation',
    quantity_change: -5,
    reason: 'Physical count showed 5 less than system',
    warehouse_id: 'wh_east_01',
    location_id: 'loc_a1_shelf_3',
    reference_number: 'COUNT_2024_001',
    cost_adjustment: -125.00
  })
  ```

  ```go Go theme={null}
  adjustment, err := stateset.Inventory.adjust({
    InventoryItemID: 'inv_abc123',
    AdjustmentType: 'reconciliation',
    QuantityChange: -5,
    Reason: 'Physical count showed 5 less than system',
    WarehouseID: 'wh_east_01',
    LocationID: 'loc_a1_shelf_3',
    ReferenceNumber: 'COUNT_2024_001',
    CostAdjustment: -125.00
  })
  ```

  ```java Java theme={null}
  InventoryAdjustment adjustment = stateset.inventory.adjust({
    inventoryItemId: 'inv_abc123',
    adjustmentType: 'reconciliation',
    quantityChange: -5,
    reason: 'Physical count showed 5 less than system',
    warehouseId: 'wh_east_01',
    locationId: 'loc_a1_shelf_3',
    referenceNumber: 'COUNT_2024_001',
    costAdjustment: -125.00
  });
  ```

  ```php PHP theme={null}
  $adjustment = $stateset->inventory->adjust([
    'inventory_item_id' => 'inv_abc123',
    'adjustment_type' => 'reconciliation',
    'quantity_change' => -5,
    'reason' => 'Physical count showed 5 less than system',
    'warehouse_id' => 'wh_east_01',
    'location_id' => 'loc_a1_shelf_3',
    'reference_number' => 'COUNT_2024_001',
    'cost_adjustment' => -125.00
  ]);
  ```

  ```csharp C# theme={null}
  var adjustment = await stateset.Inventory.Adjust(new {
    InventoryItemId = 'inv_abc123',
    AdjustmentType = 'reconciliation',
    QuantityChange = -5,
    Reason = 'Physical count showed 5 less than system',
    WarehouseId = 'wh_east_01',
    LocationId = 'loc_a1_shelf_3',
    ReferenceNumber = 'COUNT_2024_001',
    CostAdjustment = -125.00
  });
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "adj_xyz789",
    "inventory_item_id": "inv_abc123",
    "adjustment_type": "reconciliation",
    "quantity_before": 100,
    "quantity_after": 95,
    "quantity_change": -5,
    "cost_impact": -125.00,
    "reason": "Physical count showed 5 less than system",
    "warehouse_id": "wh_east_01",
    "location_id": "loc_a1_shelf_3",
    "reference_number": "COUNT_2024_001",
    "adjusted_by": "user_123",
    "adjusted_at": "2024-01-15T14:30:00Z",
    "success": true
  }
  ```

  ```json Error Response theme={null}
  {
    "error": {
      "code": "insufficient_stock",
      "message": "Cannot adjust inventory below zero. Current quantity: 3, requested change: -5",
      "details": {
        "current_quantity": 3,
        "requested_change": -5,
        "minimum_allowed": 0
      }
    }
  }
  ```
</ResponseExample>
