## Create a product group (tenant:masterdata:write)

`POST /api/masterdata/product-groups`

Module: Master data · operationId: `createProductGroup` · Tag: Product groups · Auth: access token (`Authorization: Bearer <accessToken>`)

Emits `masterdata.product_group.created`.

### Request body

`application/json` (required)

- `code` (string, required): Unique per tenant
- `defaultTaxKeyCode` (string, required): Code of `tax-keys`; new articles of the group without tax key get it
- `name` (string, required): Name (max length 255)
- `accounts` (array of ProductGroupAccount): Revenue accounts per tax key, saved as a whole set (overrides the tax key's default account for the group and its sub-groups)
  - `revenueAccount` (string, required): Revenue account
  - `taxKeyCode` (string, required): Code of `tax-keys` (once per group)
- `costCenter` (string): Cost center; sub-groups without one inherit it (max length 32)
- `createdAt` (string (date-time), read-only): Creation time
- `defaultUnitCode` (string): Code of `units`; new articles of the group without unit get it
- `id` (string (uuid), read-only): Id of the product group
- `info` (string): Info text
- `parentId` (string (uuid), nullable): Parent group (no cycles)
- `priceTiers` (array of PriceTier): The group's own price calculation scale (same rules as `PUT /price-tiers`); it replaces the inherited scale completely. `null` or absent: the group uses its parent's scale, then the tenant's (saving without it removes the group's own scale).
  - `fromCost` (number, required): Purchase price from which the row applies (inclusive, net, base currency); the first row is 0
  - `markupRate` (number, required): Markup in percent of the purchase price (max 1000)
  - `rounding` (string, required): `NONE` rounds half up to cents; `UP_x` rounds up to the next multiple of x (0.05, 0.10, 0.50, 1, 5, 10); `END_90`/`END_99` take the smallest price ending in .90/.99 that is not below the value. (one of `NONE`, `UP_0_05`, `UP_0_10`, `UP_0_50`, `UP_1`, `UP_5`, `UP_10`, `END_90`, `END_99`)
- `productCount` (integer, read-only): Number of articles in the group
- `updatedAt` (string (date-time), read-only): Time of the last change
- `version` (integer): Optimistic locking version (updates)

Example:

```json
{
  "code": "MON",
  "defaultTaxKeyCode": "STANDARD",
  "name": "Monitore"
}
```

### Responses

- **201** Created (`application/json`)
- **400** Malformed body or query parameter (`application/json`)
- **401** Missing, invalid or expired token (empty body)
- **403** The token lacks the permission or carries no tenant (`application/json`)
- **409** Stale version or conflict with existing data (`application/json`)

Fields of the 201 answer:

- `code` (string, required): Unique per tenant
- `defaultTaxKeyCode` (string, required): Code of `tax-keys`; new articles of the group without tax key get it
- `name` (string, required): Name (max length 255)
- `accounts` (array of ProductGroupAccount): Revenue accounts per tax key, saved as a whole set (overrides the tax key's default account for the group and its sub-groups)
  - `revenueAccount` (string, required): Revenue account
  - `taxKeyCode` (string, required): Code of `tax-keys` (once per group)
- `costCenter` (string): Cost center; sub-groups without one inherit it (max length 32)
- `createdAt` (string (date-time), read-only): Creation time
- `defaultUnitCode` (string): Code of `units`; new articles of the group without unit get it
- `id` (string (uuid), read-only): Id of the product group
- `info` (string): Info text
- `parentId` (string (uuid), nullable): Parent group (no cycles)
- `priceTiers` (array of PriceTier): The group's own price calculation scale (same rules as `PUT /price-tiers`); it replaces the inherited scale completely. `null` or absent: the group uses its parent's scale, then the tenant's (saving without it removes the group's own scale).
  - `fromCost` (number, required): Purchase price from which the row applies (inclusive, net, base currency); the first row is 0
  - `markupRate` (number, required): Markup in percent of the purchase price (max 1000)
  - `rounding` (string, required): `NONE` rounds half up to cents; `UP_x` rounds up to the next multiple of x (0.05, 0.10, 0.50, 1, 5, 10); `END_90`/`END_99` take the smallest price ending in .90/.99 that is not below the value. (one of `NONE`, `UP_0_05`, `UP_0_10`, `UP_0_50`, `UP_1`, `UP_5`, `UP_10`, `END_90`, `END_99`)
- `productCount` (integer, read-only): Number of articles in the group
- `updatedAt` (string (date-time), read-only): Time of the last change
- `version` (integer): Optimistic locking version (updates)

Example 201 answer:

```json
{
  "accounts": [
    {
      "revenueAccount": "4400",
      "taxKeyCode": "STANDARD"
    }
  ],
  "code": "HARDWARE",
  "costCenter": "4200",
  "createdAt": "2026-01-02T08:00:00Z",
  "defaultTaxKeyCode": "STANDARD",
  "defaultUnitCode": "STK",
  "id": "8d0b6f3e-2c4a-4e7b-9a1d-5f3c2e1b0a97",
  "name": "Hardware",
  "parentId": null,
  "priceTiers": [
    {
      "fromCost": 0,
      "markupRate": 35,
      "rounding": "END_99"
    },
    {
      "fromCost": 500,
      "markupRate": 25,
      "rounding": "END_99"
    }
  ],
  "productCount": 14,
  "updatedAt": "2026-04-11T15:20:00Z",
  "version": 2
}
```

### Example request

```bash
curl -X POST 'https://api.mbcom.cloud/api/masterdata/product-groups' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"code":"MON","defaultTaxKeyCode":"STANDARD","name":"Monitore"}'
```
