## Replace the MSP billing configuration (tenant:settings:write)

`PUT /api/trade/v1/msp/config`

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

Replaces the `msp` section; the rest of the configuration stays. Masked or empty secrets keep their stored value.

### Request body

`application/json` (required)

- `autoBilling` (object): Window in the month after the billed one in which the drafts are approved without a person, once every active connector collected the month and no subscription lacks a customer or an article: at `from` when nothing blocks, else at every recheck and right after a collection ended, until `to`. When enabled, `from` must lie before `to` and every enabled connector's schedule before `to` (422 otherwise).
  - `enabled` (boolean): Bill the month automatically.
  - `from` (MspSchedule): A day of the month and a time of day (Europe/Berlin); unset values take the defaults (day 1, 06:00).
    - `day` (integer): Day of the month (1–28). (max 28)
    - `time` (string): `HH:MM`, 24 h.
  - `recheckHours` (integer): Hours until a blocked month (a connector missing, subscriptions without customer or article) is checked again; empty: 4. (max 168)
  - `to` (MspSchedule): A day of the month and a time of day (Europe/Berlin); unset values take the defaults (day 1, 06:00).
    - `day` (integer): Day of the month (1–28). (max 28)
    - `time` (string): `HH:MM`, 24 h.
- `enabled` (boolean): MSP billing is on.
- `ingram` (object): Ingram Micro cloud subscriptions (Microsoft CSP included), read through the Reseller API v7 with the Ingram connection of the distributor settings (`itsp.ingram`). The end customers (details, Custom_Account_ID = our address number) are read from the Cloud Marketplace API with the `marketplace*` access below; optional, without it customers are matched by name only.
  - `articleProductGroupId` (string (uuid)): Masterdata product group of the Microsoft articles MSP billing creates (see `articleUnitCode`).
  - `articleUnitCode` (string): Masterdata unit code of the Microsoft articles MSP billing creates for subscriptions without article; without unit and product group none is created.
  - `enabled` (boolean): Collect Ingram Micro marketplace usage.
  - `marketplaceCode` (string): Marketplace code.
  - `marketplaceLogin` (string): Ingram Micro marketplace login.
  - `marketplacePassword` (object): Write-only: stored encrypted, masked in answers; send the mask back to keep it.
  - `marketplaceSubscriptionKey` (object): Subscription key (`X-Subscription-Key`). Write-only: stored encrypted, masked in answers.
  - `marketplaceUrl` (string): Base URL of the Cloud Marketplace API gateway.
  - `schedule` (object): See `mailstore`.
  - `supplierAddressId` (string): See `mailstore` (distributor id `ingram`). Also the supplier of the Microsoft articles MSP billing creates.
- `itc` (object): ITC Riemer (provider `itc`): no API, its monthly reports are uploaded (`uploadMspItcReport`) and count for the completeness of the month without a schedule.
  - `articleProductGroupId` (string (uuid)): Masterdata product group of the ITC articles MSP billing creates (see `articleUnitCode`).
  - `articleUnitCode` (string): Masterdata unit code of the ITC articles MSP billing creates for SKUs without article; without unit and product group none is created.
  - `enabled` (boolean): Bill ITC Riemer reports.
  - `supplierAddressId` (string): Masterdata address of ITC Riemer: uploaded reports are filed under it in DMS, it is the supplier of the ITC articles MSP billing creates and the reconciliation compares its inbound invoices.
- `mailstore` (object): MailStore connection.
  - `enabled` (boolean): Collect MailStore usage.
  - `password` (Secret): Masked (`••••••••`) in answers; send the mask or an empty value to keep the stored secret.
  - `schedule` (object): When the previous month is collected each month.
  - `supplierAddressId` (string): Masterdata address of the supplier whose inbound invoices the reconciliation compares; empty: the address linked with the distributor id `mailstore`.
  - `url` (string): URL of the MailStore SPE.
  - `username` (string): MailStore user name.
- `notify` (object): Who is told about the connector runs and the automatic billing.
  - `recipients` (array of string (email)): E-mail addresses; trimmed, empty and repeated ones dropped.
- `sophos` (object): Sophos connection.
  - `articleProductGroupId` (string (uuid)): Masterdata product group of the Sophos articles MSP billing creates (see `articleUnitCode`).
  - `articleUnitCode` (string): Masterdata unit code of the Sophos articles MSP billing creates from the Infinigate catalog for SKUs without article; without unit and product group none is created.
  - `clientId` (string): Sophos API client id.
  - `clientSecret` (Secret): Masked (`••••••••`) in answers; send the mask or an empty value to keep the stored secret.
  - `enabled` (boolean): Collect Sophos usage.
  - `partnerId` (string): Sophos partner id.
  - `schedule` (object): See `mailstore`.
  - `supplierAddressId` (string): See `mailstore` (distributor id `sophos`). Also the supplier of the Sophos articles MSP billing creates (else the address of the distributor id `infinigate`).
- `taxRate` (number): VAT rate of the MSP invoices in percent; empty: 19. (max 100)

Example:

```json
{
  "autoBilling": {
    "enabled": true,
    "from": {
      "day": 5,
      "time": "06:00"
    },
    "recheckHours": 4,
    "to": {
      "day": 10,
      "time": "17:00"
    }
  },
  "enabled": true,
  "ingram": {
    "articleProductGroupId": "9a0b1c2d-3e4f-4a5b-8c6d-7e8f9a0b1c04",
    "articleUnitCode": "LIZ",
    "enabled": true,
    "marketplaceCode": "de",
    "marketplaceLogin": "EXAMPLE-marketplace-login",
    "marketplacePassword": "••••••••",
    "marketplaceSubscriptionKey": "••••••••",
    "marketplaceUrl": "https://marketplace.ingram.example",
    "schedule": {
      "day": 1,
      "time": "06:00"
    },
    "supplierAddressId": "6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d10"
  },
  "itc": {
    "articleProductGroupId": "9a0b1c2d-3e4f-4a5b-8c6d-7e8f9a0b1c05",
    "articleUnitCode": "MON",
    "enabled": true,
    "supplierAddressId": "6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d03"
  },
  "mailstore": {
    "enabled": true,
    "password": "••••••••",
    "schedule": {
      "day": 1,
      "time": "06:00"
    },
    "supplierAddressId": "",
    "url": "https://mailstore.muster-it.example:8474",
    "username": "EXAMPLE-api-user"
  },
  "notify": {
    "recipients": [
      "laura.kaestner@muster-it.example",
      "christina.adler@muster-it.example"
    ]
  },
  "sophos": {
    "articleProductGroupId": "9a0b1c2d-3e4f-4a5b-8c6d-7e8f9a0b1c04",
    "articleUnitCode": "LIZ",
    "clientId": "EXAMPLE-sophos-client-id",
    "clientSecret": "••••••••",
    "enabled": true,
    "partnerId": "EXAMPLE-sophos-partner-id",
    "schedule": {
      "day": 2,
      "time": "06:00"
    },
    "supplierAddressId": "6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d11"
  },
  "taxRate": 19
}
```

### Responses

- **200** Saved (`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 section is invalid: schedule day or time, automatic billing window (`from` must lie before `to`), tax rate, notification addresses. (`application/json`)
- **503** The configuration store is not available. (`application/json`)

Fields of the 200 answer:

- `status` (string, required): Outcome of the request.

Example 200 answer:

```json
{
  "status": "saved"
}
```

### Example request

```bash
curl -X PUT 'https://api.mbcom.cloud/api/trade/v1/msp/config' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"autoBilling":{"enabled":true,"from":{"day":5,"time":"06:00"},"recheckHours":4,"to":{"day":10,"time":"17:00"}},"enabled":true,"ingram":{"articleProductGroupId":"9a0b1c2d-3e4f-4a5b-8c6d-7e8f9a0b1c04","articleUnitCode":"LIZ","enabled":true,"marketplaceCode":"de","marketplaceLogin":"EXAMPLE-marketplace-login","marketplacePassword":"••••••••","marketplaceSubscriptionKey":"••••••••","marketplaceUrl":"https://marketplace.ingram.example","schedule":{"day":1,"time":"06:00"},"supplierAddressId":"6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d10"},"itc":{"articleProductGroupId":"9a0b1c2d-3e4f-4a5b-8c6d-7e8f9a0b1c05","articleUnitCode":"MON","enabled":true,"supplierAddressId":"6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d03"},"mailstore":{"enabled":true,"password":"••••••••","schedule":{"day":1,"time":"06:00"},"supplierAddressId":"","url":"https://mailstore.muster-it.example:8474","username":"EXAMPLE-api-user"},"notify":{"recipients":["laura.kaestner@muster-it.example","christina.adler@muster-it.example"]},"sophos":{"articleProductGroupId":"9a0b1c2d-3e4f-4a5b-8c6d-7e8f9a0b1c04","articleUnitCode":"LIZ","clientId":"EXAMPLE-sophos-client-id","clientSecret":"••••••••","enabled":true,"partnerId":"EXAMPLE-sophos-partner-id","schedule":{"day":2,"time":"06:00"},"supplierAddressId":"6d8f0a12-3c4e-4a5b-9d6f-7e8a9b0c1d11"},"taxRate":19}'
```
