# Update unified model

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

`PATCH /unified-model/{id}`

Resource: **Unified Models**

## Path parameters

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

## Request body

- **`name`** _(string)_
  The new name of the unified model, if you want to rename it.
- **`category`** _(string)_
  The new category, if you want to change it.
- **`description`** _(string)_
  A brief description of what this unified model represents.
- **`resources`** _(object)_
  Updated map of resource name → `UnifiedModelResource`.
- **`team_id`** _(string)_
  The ID of the team that owns this unified model.
- **`version`** _(number)_
  The current version of the unified model. Required to prevent version conflicts.
- **`docs`** _(object)_
  Per-resource documentation.
- **`scopes`** _(object)_
  Per-resource OAuth/permission scopes required to call its methods.
- **`webhooks`** _(object)_
  Per-resource webhook routing expression (JSONata).

## Response body

- **`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.

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/unified-model/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "user-directory",
  "category": "communication",
  "description": "This model provides a user directory interface for various HRIS integrations.",
  "resources": {},
  "team_id": "05daecaf-4365-42e8-8370-8127de5dd717",
  "version": 3,
  "docs": {},
  "scopes": {},
  "webhooks": {}
}'
```

### JavaScript

```javascript
const body = {
  "name": "user-directory",
  "category": "communication",
  "description": "This model provides a user directory interface for various HRIS integrations.",
  "resources": {},
  "team_id": "05daecaf-4365-42e8-8370-8127de5dd717",
  "version": 3,
  "docs": {},
  "scopes": {},
  "webhooks": {}
};

const response = await fetch('https://api.truto.one/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/unified-model/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "name": "user-directory",
    "category": "communication",
    "description": "This model provides a user directory interface for various HRIS integrations.",
    "resources": {},
    "team_id": "05daecaf-4365-42e8-8370-8127de5dd717",
    "version": 3,
    "docs": {},
    "scopes": {},
    "webhooks": {}
}

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

### Truto TS SDK

```typescript
import Truto from '@truto/truto-ts-sdk';

const truto = new Truto({
  token: '<your_api_token>',
});

const body = {
  "name": "user-directory",
  "category": "communication",
  "description": "This model provides a user directory interface for various HRIS integrations.",
  "resources": {},
  "team_id": "05daecaf-4365-42e8-8370-8127de5dd717",
  "version": 3,
  "docs": {},
  "scopes": {},
  "webhooks": {}
};

const result = await truto.unifiedModel.update('<id>', body);

console.log(result);
```

### Truto Python SDK

```python
import asyncio
from truto_python_sdk import TrutoApi

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

async def main():
    body = {
        "name": "user-directory",
        "category": "communication",
        "description": "This model provides a user directory interface for various HRIS integrations.",
        "resources": {},
        "team_id": "05daecaf-4365-42e8-8370-8127de5dd717",
        "version": 3,
        "docs": {},
        "scopes": {},
        "webhooks": {}
    }

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

asyncio.run(main())
```
