# Update tenant

> Source: https://truto.one/docs/api-reference/admin/tenants/update/

`PATCH /tenant/{id}`

Resource: **Tenants**

## Path parameters

- **`id`** _(string, required)_
  The tenant id, percent-encoded as a single path segment. Tenant ids are free-form and may contain `/`, spaces or non-ASCII, so reserved characters have to be escaped: `acme/prod` is requested as `/tenant/acme%2Fprod`. Sent raw, it is two path segments, matches no route, and comes back 404. Only *unreserved* escapes are normalised before the request reaches the API, so `%2F` arrives intact and is decoded back to the original id.

## Query parameters

- **`environment_id`** _(string)_
  Required for session auth. Ignored for API tokens.

## Request body

- **`name`** _(string)_
  New display name.
- **`metadata`** _(object)_
  Full replacement of the metadata object.

## Response body

- **`id`** _(string)_
  The tenant identifier — caller-chosen and immutable once created. Composite primary key with `environment_id`, so the same value can exist independently in `development`, `staging`, and `production`. Free-form up to 255 characters: whatever you already use to identify a customer, including `/`, spaces and non-ASCII. The only values rejected are the ones no URL path segment can carry — control characters, leading or trailing whitespace, and the dot segments `.` and `..`.
- **`environment_id`** _(string)_
  The environment this tenant belongs to.
- **`name`** _(string)_
  Display name shown in the dashboard. Defaults to the tenant `id` on create if not supplied; can be edited later via `PATCH /tenant/{id}`.
- **`metadata`** _(object)_
  Free-form JSON object stored verbatim. Truto does not interpret this field — use it for tier, region, billing plan, or any other customer attribute your app cares about.
- **`created_at`** _(string)_
  The date and time when the tenant was created.
- **`updated_at`** _(string)_
  The date and time when the tenant was last updated.

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/tenant/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Acme Corporation",
  "metadata": {
    "tier": "platinum"
  }
}'
```

### JavaScript

```javascript
const body = {
  "name": "Acme Corporation",
  "metadata": {
    "tier": "platinum"
  }
};

const response = await fetch('https://api.truto.one/tenant/{id}', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/tenant/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "name": "Acme Corporation",
    "metadata": {
        "tier": "platinum"
    }
}

response = requests.patch(url, headers=headers, params=params, json=payload)
print(response.json())
```
