## Assign a distributor ID to an address (tenant:masterdata:write)

`PUT /api/masterdata/distributor-ids/{source}/{distributorId}`

Module: Master data · operationId: `assignDistributorId` · Tag: Distributor IDs · Auth: access token (`Authorization: Bearer <accessToken>`)

Links the distributor ID with the address; an ID already linked with another address moves to the new one. An omitted `distributorName` keeps the stored name. Emits `masterdata.distributor_id.assigned`.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `source` | path | string | yes | Distributor source, lower-case (`egis`, `ingram`, `infinigate`, `amazon`, …) |
| `distributorId` | path | string | yes | The distributor's own supplier ID (matched case-insensitively) (max length 64) |

### Request body

`application/json` (required)

- `addressId` (string (uuid), required): Supplier address the distributor stands for
- `distributorName` (string): Name of the distributor (kept when empty) (max length 255)

Example:

```json
{
  "addressId": "3f6c1a52-7b1e-4d2a-9c8e-2b5f0d6a91e4",
  "distributorName": "EGIS Computer Service-Center GmbH"
}
```

### Responses

- **200** Assigned (`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`)

Fields of the 200 answer:

- `addressId` (string (uuid), required): Supplier address the distributor ID maps to
- `addressName` (string, required): Display name of that address
- `adrNr` (string, required): Address number of that address
- `distributorId` (string, required): The distributor's own ID
- `source` (string, required): Distributor (lower case, e.g. egis, ingram)
- `updatedAt` (string (date-time), required): Time of the last change
- `distributorName` (string): Name of the distributor

Example 200 answer:

```json
{
  "addressId": "3c5e7a9c-1d3f-4b5a-9c7e-1a3c5e7a9c1e",
  "addressName": "Alpenhotel Seeblick GmbH \u0026 Co. KG",
  "adrNr": "10001",
  "distributorId": "700123",
  "distributorName": "EGIS Computer Service-Center GmbH",
  "source": "egis",
  "updatedAt": "2026-05-20T11:40:00Z"
}
```

### Example request

```bash
curl -X PUT 'https://api.mbcom.cloud/api/masterdata/distributor-ids/egis/700123' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  --data '{"addressId":"3f6c1a52-7b1e-4d2a-9c8e-2b5f0d6a91e4","distributorName":"EGIS Computer Service-Center GmbH"}'
```
