# Update environment unified model

> Source: https://truto.one/docs/api-reference/admin/installed-unified-models/update/

`PATCH /environment-unified-model/{id}`

Resource: **Installed unified models**

**Update** an existing environment-unified-model record (e.g., changing overrides). You have the flexibility to customize a Unified Model and its configuration to better suit your specific needs. Customizing the models allow you to override default mappings, add new resources, and tailor the unified apis to fit seamlessly within your environment.  Read more about [Installing Unified Models](https://truto.one/docs/guides/unified-apis/installing-unified-api)

## Path parameters

- **`id`** _(string, required)_
  The ID of the environment-unified-model record to update.

## Request body

- **`change_message`** _(string)_
  Why this change is being made. Optional, at most 2000 characters, recorded with the version this save creates (see `GET /environment-unified-model/{id}/versions`). Not saved on the object.
- **`override`** _(object)_
  The updated override object. Deep-merged on top of the base unified model.
  - **`resources`** _(object)_
    Resource-level overrides keyed by resource name. A `null` value is a tombstone: it removes an inherited resource from this environment's effective unified model. Omitting the key cannot say that — overrides are deep-merged, so an absent key means "inherit from the base model". The tombstone is stripped while merging, so the resource is simply absent from the returned `unified_model` rather than present with a null value.
  - **`scopes`** _(object)_
    Per-integration extra OAuth scopes appended to the base unified-model scopes.
  - **`webhooks`** _(object)_
    Per-integration JSONata expressions that route inbound webhooks to unified-model resources.
  - **`docs`** _(object)_
    Per-integration documentation overrides.

## Response body

- **`id`** _(string)_
  The ID of the environment-unified-model record.
- **`unified_model_id`** _(string)_
  The ID of the unified model being installed or overridden.
- **`environment_id`** _(string)_
  The ID of the environment where this unified model is installed.
- **`override`** _(object)_
  An optional object containing environment-level overrides for the unified model. Deep-merged on top of the base unified model. See `EnvironmentUnifiedModelOverride` for the typed shape.
  - **`resources`** _(object)_
    Resource-level overrides keyed by resource name. A `null` value is a tombstone: it removes an inherited resource from this environment's effective unified model. Omitting the key cannot say that — overrides are deep-merged, so an absent key means "inherit from the base model". The tombstone is stripped while merging, so the resource is simply absent from the returned `unified_model` rather than present with a null value.
  - **`scopes`** _(object)_
    Per-integration extra OAuth scopes appended to the base unified-model scopes.
  - **`webhooks`** _(object)_
    Per-integration JSONata expressions that route inbound webhooks to unified-model resources.
  - **`docs`** _(object)_
    Per-integration documentation overrides.
- **`created_at`** _(string)_
  Timestamp when this record was created.
- **`updated_at`** _(string)_
  Timestamp when this record was last updated.
- **`unified_model`** _(object)_
  - **`id`** _(string)_
    The ID of the unified model.
  - **`name`** _(string)_
    The name of the unified model.
  - **`category`** _(string)_
    The category of the unified model.
  - **`description`** _(string)_
    A brief description of what this unified model represents.
  - **`team_id`** _(string)_
    The ID of the team that owns this unified model.
  - **`sharing`** _(string)_
    The sharing policy of the unified model.
    Allowed: `allow`, `ask`, `deny`
  - **`resources`** _(object)_
    Map of resource name (e.g. `users`, `contacts`) → resource definition (`UnifiedModelResource`).
  - **`docs`** _(object)_
    Per-resource documentation (pricing plan / scopes / instructions).
  - **`scopes`** _(object)_
    Per-resource OAuth/permission scopes required to call its methods.
  - **`webhooks`** _(object)_
    Per-resource webhook routing expression (JSONata that decides whether an inbound webhook should be delivered to this resource).
  - **`created_at`** _(string)_
    The date and time when the unified model was created.
  - **`updated_at`** _(string)_
    The date and time when the unified model was last updated.
  - **`version`** _(number)_
    The current version of the unified model.
  - **`installed_environment`** _(array<string>)_
    A list of environment IDs where this unified model is installed.
  - **`team`** _(object)_
    - **`id`** _(string)_
      The ID of the team.
    - **`name`** _(string)_
      The name of the team.
    - **`domain`** _(string)_
      The domain of the team.
    - **`logo`** _(string)_
      The URL of the team's logo.
    - **`is_verified`** _(boolean)_
      Whether the team is verified or not.
    - **`is_white_label`** _(boolean)_
      Whether the team is white-labeled or not.
    - **`tos_link`** _(string)_
      A link to the team's Terms of Service, if available.
    - **`allow_impersonation`** _(boolean)_
      Whether the team allows impersonation.
    - **`created_at`** _(string)_
      The date and time when the team was created.
    - **`updated_at`** _(string)_
      The date and time when the team was last updated.

## Errors

| Status | Description |
| :----- | :---------- |
| `404` | Environment Unified Model not found |

## Code examples

### Truto CLI

```bash
truto env-unified-models update '<id>' \
  -b '{
  "change_message": "your_change_message",
  "override": {}
}' \
  -o json
```

### Truto Python SDK

```python
import asyncio
from truto_python_sdk import TrutoApi

truto_api = TrutoApi(token="<your_api_token>")

async def main():
    body = {
        "change_message": "your_change_message",
        "override": {}
    }

    result = await truto_api.environment_unified_models.update("<id>", body)
    print(result)

asyncio.run(main())
```

### curl

```bash
curl -X PATCH 'https://api.truto.one/environment-unified-model/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "change_message": "your_change_message",
  "override": {}
}'
```

### JavaScript

```javascript
const body = {
  "change_message": "your_change_message",
  "override": {}
};

const response = await fetch('https://api.truto.one/environment-unified-model/{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/environment-unified-model/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "change_message": "your_change_message",
    "override": {}
}

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