# Update a machine's tenants

Source: https://www.jawsdeploy.net/rest-api/machines-tenants-update | Section: Machines

Set which tenants a machine serves.

`PUT /api/machine/tenants`

Sets which tenants the machine serves. A deployment for a tenant can use the machine when its mode is `Tenanted` or `Both` and the tenant is listed in `tenantIds`, or carries one of the tags in `tenantTagIds`. A deployment that is not for a tenant can use it when its mode is `Untenanted` or `Both`.

Only the fields you send are changed. When the mode is `Untenanted` the tenant lists are cleared, because they are not used. A machine that serves tenants but lists none is used by no tenant deployment.

Every tenant and tag must belong to the **same workspace as the machine** and must not be deleted. An archived tenant may be listed; it just never matches. If any ID is invalid, the whole call is refused and nothing is changed.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `machineId` | body | string | yes | ID of the machine, from [List machines](https://www.jawsdeploy.net/rest-api/machines-list). |
| `tenantMode` | body | string | no | `Untenanted` (only deployments that are not for a tenant), `Tenanted` (only deployments for a tenant) or `Both`. Leave out to keep the current mode. |
| `tenantIds` | body | array<string> | no | The complete set of tenant IDs the machine serves. Leave out to keep the current list, send `[]` to clear it. |
| `tenantTagIds` | body | array<string> | no | The complete set of tag IDs - the machine serves any tenant with at least one of these tags. Leave out to keep the current list, send `[]` to clear it. |

## Errors

| Status | Meaning |
|---|---|
| 400 | Invalid `machineId`. A machine that belongs to another organization is reported the same way as one that does not exist. |
| 400 | Invalid `tenantMode`. |
| 400 | One or more tenants or tenant tags do not exist in the machine's workspace. Nothing is changed. |
| 401 | Missing or invalid Basic auth credentials, or the service account lacks permission to manage machines in this workspace. |

Example request:

```
PUT /api/machine/tenants HTTP/1.1
Authorization: Basic <base64(...)>
Content-Type: application/json

{
  "machineId": "mch_web01",
  "tenantMode": "Tenanted",
  "tenantIds": ["ten_acme"],
  "tenantTagIds": ["tag_region_eu"]
}
```

Example response:

```
{}
```

