## Set the minimum-stock rule of an article (tenant:stock:write)

`PUT /api/trade/v1/stock/{articleId}/rule`

Module: Trade · operationId: `putStockRule` · Tag: Stock · Auth: access token (`Authorization: Bearer <accessToken>`)

Creates or replaces the rule. At most one of `reorderQty` (fixed batch) and `maxStock` (order up to) may be
set, and `maxStock` must not be below `minStock`. Only the default warehouse exists; another `warehouseId` is
answered `422`. An article that is already below its new minimum raises `trade.stock.below_minimum` at once.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `articleId` | path | string | yes | Masterdata product id of the article. |

### Request body

`application/json` (required)

- `minStock` (number, required): Minimum stock.
- `articleId` (string, read-only): From the path.
- `maxStock` (number, nullable): Order up to this quantity. Excludes `reorderQty`; not below `minStock`.
- `reorderQty` (number, nullable): Fixed batch to reorder. Excludes `maxStock`.
- `warehouseId` (string): Warehouse code; empty or the default warehouse (`HAUPT`).

Example:

```json
{
  "minStock": 5,
  "reorderQty": 20
}
```

### Responses

- **200** The stored rule (`application/json`)
- **400** Error (`application/json`)
- **401** No valid session or bearer token (no body).
- **403** Missing permission, no active tenant in the token, or a missing CSRF token on a cookie write. (`application/json`)
- **422** The input is not valid for the stored data. (`application/json`)

Fields of the 200 answer:

- `minStock` (number, required): Minimum stock.
- `articleId` (string, read-only): From the path.
- `maxStock` (number, nullable): Order up to this quantity. Excludes `reorderQty`; not below `minStock`.
- `reorderQty` (number, nullable): Fixed batch to reorder. Excludes `maxStock`.
- `warehouseId` (string): Warehouse code; empty or the default warehouse (`HAUPT`).

Example 200 answer:

```json
{
  "articleId": "4b7d9f13-5e6a-4c8b-a1d2-3e4f5a6b7c03",
  "maxStock": 200,
  "minStock": 50,
  "reorderQty": null,
  "warehouseId": "HAUPT"
}
```

### Example request

```bash
curl -X PUT 'https://api.mbcom.cloud/api/trade/v1/stock/string/rule' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"minStock":5,"reorderQty":20}'
```
