# Update Devices

> Source: https://truto.one/docs/api-reference/unified-mdm-api/devices/update/

`PATCH /unified/mdm/devices/{id}`

Resource: **Devices** · API: **Unified MDM API**

## Supported integrations

Jamf, Kandji, Ninjaone

## Path parameters

- **`id`** _(string, required)_
  The ID of the resource.

## Query parameters

- **`integrated_account_id`** _(string, required)_
  The ID of the integrated account to use for the request.
- **`truto_response_format`** _(string)_
  The format of the response. - `unified` returns the response with unified mappings applied. - `raw` returns the unprocessed, raw response from the remote API. - `normalized` applies the unified mappings and returns the data in a normalized format. - `stream` returns the response as a stream, which is ideal for transmitting large datasets, files, or binary data. Using streaming mode helps to efficiently handle large payloads or real-time data flows without requiring the entire data to be buffered in memory. Defaults to `unified`.
  Allowed: `unified`, `raw`, `normalized`, `stream`
- **`truto_ignore_remote_data`** _(boolean)_
  Excludes the `remote_data` attribute from the response.
- **`truto_exclude_fields`** _(array<string>)_
  Array of fields to exclude from the response.
- **`remote_query`** _(object)_
  Query parameters to pass to the underlying API without any transformations. Refer [this guide](https://truto.one/docs/api-reference/overview/querying#remote-query-parameters) to see how to structure the query parameters.
- **`type`** _(string)_
  The type/category of the device
  Allowed: `desktop`, `laptop`, `mobile`, `other`, `server`, `tablet`, `virtual_machine`, `workstation`

## Request body

- **`name`** _(string)_
  The display name of the device
- **`serial_number`** _(string)_
  The serial number of the device
- **`asset_tag`** _(string)_
  The asset tag / inventory tag of the device
- **`mac_addresses`** _(array<string>)_
  Pass this value only when type is desktop.
- **`warranty_start_at`** _(string)_
  Pass this value only when type is desktop.
- **`owner`** _(object)_
  The assigned owner of the device
  - **`id`** _(string)_
    The unique identifier for a user
  - **`name`** _(string)_
    The name of the user
  - **`emails`** _(array<object>)_
    The emails of the user
    - **`email`** _(string)_
      The email address
    - **`type`** _(string)_
      The type of email address
    - **`is_primary`** _(boolean)_
      Whether the email address is primary
- **`policy`** _(object)_
  The applied policy / blueprint
  - **`id`** _(string)_
    The unique identifier for a policy
  - **`name`** _(string)_
    The name of the policy
- **`tags`** _(array<object>)_
  The device's tags
  - **`id`** _(string)_
    The tag's unique identifier
  - **`name`** _(string)_
    The tag's name
- **`organization`** _(object)_
  The organization/account the device belongs to
  - **`id`** _(string)_
    The unique identifier for an organization
  - **`name`** _(string)_
    The name of the organization
- **`warranty_end_at`** _(string)_
  The date and time warranty ends
- **`remote_data`** _(object)_
  Any additional data that should be passed as part of the request body. This data is not transformed by Truto and is passed as is to the remote API.

## Response body

- **`id`** _(string, required)_
  The unique identifier for the device
- **`name`** _(string)_
  The display name of the device
- **`hostname`** _(string)_
  The host/system name of the device
- **`dns_name`** _(string)_
  The DNS name of the device
- **`netbios_name`** _(string)_
  The NetBIOS name of the device (Windows)
- **`type`** _(string)_
  The type/category of the device
  Allowed: `workstation`, `server`, `mobile`, `tablet`, `laptop`, `desktop`, `virtual_machine`, `other`
- **`is_corporate_owned`** _(boolean)_
  Whether the device is corporate-owned (as opposed to personally-owned/BYOD)
- **`platform`** _(string)_
  The platform family of the device
  Allowed: `windows`, `macos`, `linux`, `ios`, `ipados`, `android`, `chromeos`, `unknown`
- **`model`** _(string)_
  The hardware model of the device
- **`manufacturer`** _(string)_
  The hardware manufacturer of the device
- **`serial_number`** _(string)_
  The serial number of the device
- **`asset_tag`** _(string)_
  The asset tag / inventory tag of the device
- **`os_name`** _(string)_
  The operating system name
- **`os_version`** _(string)_
  The operating system version
- **`os_build`** _(string)_
  The operating system build identifier
- **`os_version_extra`** _(string)_
  Additional operating system version information
- **`disk_encryption`** _(boolean)_
  Whether the disk encryption is enabled on the device
- **`firewall_enabled`** _(boolean)_
  Whether the host firewall is enabled on the device
- **`mdm_enabled`** _(boolean)_
  Whether MDM management is enabled on the device
- **`agent_installed`** _(boolean)_
  Whether a management agent is installed
- **`agent_version`** _(string)_
  The management agent version
- **`enrollment_status`** _(string)_
  Enrollment state of the device in the provider
  Allowed: `enrolled`, `pending`, `removed`, `missing`, `unknown`
- **`approval_status`** _(string)_
  Approval state if the provider requires approval
  Allowed: `approved`, `pending`, `rejected`, `unknown`
- **`is_offline`** _(boolean)_
  Whether the device is currently offline
- **`first_enrolled_at`** _(string)_
  The date and time the device was first enrolled
- **`last_enrolled_at`** _(string)_
  The date and time the device was most recently enrolled
- **`last_scan_at`** _(string)_
  The date and time the device was last scanned for vulnerabilities or security posture signals, when supported by the underlying product
- **`last_activity_at`** _(string)_
  The date and time of the last recorded activity for the device
- **`organization`** _(object)_
  The organization/account the device belongs to
  - **`id`** _(string)_
    The unique identifier for an organization
  - **`name`** _(string)_
    The name of the organization
- **`owner`** _(object)_
  The assigned owner of the device
  - **`id`** _(string)_
    The unique identifier for a user
  - **`name`** _(string)_
    The name of the user
  - **`emails`** _(array<object>)_
    The emails of the user
    - **`email`** _(string)_
      The email address
    - **`type`** _(string)_
      The type of email address
    - **`is_primary`** _(boolean)_
      Whether the email address is primary
- **`policy`** _(object)_
  The applied policy / blueprint
  - **`id`** _(string)_
    The unique identifier for a policy
  - **`name`** _(string)_
    The name of the policy
- **`edr_installed`** _(boolean)_
  Whether an endpoint detection and response (EDR) agent is installed or detected on the device
- **`edr_status`** _(string)_
  The health/status of the EDR agent on the device, when available from the underlying product
  Allowed: `healthy`, `unhealthy`, `degraded`, `unknown`
- **`critical_vuln_count`** _(integer)_
  The number of critical severity vulnerabilities detected on the device
- **`high_vuln_count`** _(integer)_
  The number of high severity vulnerabilities detected on the device
- **`patch_status`** _(string)_
  The patch compliance status of the device, based on signals available in the underlying product
  Allowed: `up_to_date`, `updates_available`, `unknown`
- **`maintenance_status`** _(string)_
  The maintenance status
  Allowed: `none`, `pending`, `active`, `completed`, `unknown`
- **`maintenance_start_at`** _(string)_
  The date and time maintenance starts
- **`maintenance_end_at`** _(string)_
  The date and time maintenance ends
- **`maintenance_reason`** _(string)_
  The maintenance reason message
- **`warranty_start_at`** _(string)_
  The date and time warranty starts
- **`warranty_end_at`** _(string)_
  The date and time warranty ends
- **`warranty_fulfillment_at`** _(string)_
  The manufacturer fulfillment date
- **`backup_last_success_at`** _(string)_
  The date and time the last backup succeeded
- **`backup_last_failure_at`** _(string)_
  The date and time the last backup failed
- **`backup_total_bytes`** _(number)_
  Total backup usage in bytes
- **`public_ip`** _(string)_
  The public IP address of the device
- **`ip_addresses`** _(array<string>)_
  The private IP addresses of the device
- **`mac_addresses`** _(array<string>)_
  The MAC addresses of the device
- **`tags`** _(array<object>)_
  The device's tags
  - **`id`** _(string)_
    The tag's unique identifier
  - **`name`** _(string)_
    The tag's name
- **`notes`** _(array<object>)_
  Notes attached to the device
  - **`id`** _(string, required)_
    The note's unique identifier
  - **`title`** _(string)_
    The note's title
  - **`owner`** _(object)_
    The note's owner
    - **`id`** _(string)_
      The note's owner's unique identifier
  - **`content`** _(string)_
    The note's content
- **`custom_fields`** _(object)_
  Provider or customer specific fields mapped into a flexible key-value object
- **`created_at`** _(string)_
  The date and time the device record was created
- **`updated_at`** _(string)_
  The date and time the device record was last updated
- **`remote_data`** _(object)_
  Raw data returned from the remote API call.

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/unified/mdm/devices/{id}?integrated_account_id=<integrated_account_id>' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "your_name",
  "serial_number": "your_serial_number",
  "asset_tag": "your_asset_tag",
  "mac_addresses": [],
  "warranty_start_at": "your_warranty_start_at",
  "owner": {},
  "policy": {},
  "tags": [],
  "organization": {},
  "warranty_end_at": "your_warranty_end_at",
  "remote_data": {}
}'
```

### JavaScript

```javascript
const integratedAccountId = '<integrated_account_id>';

const body = {
  "name": "your_name",
  "serial_number": "your_serial_number",
  "asset_tag": "your_asset_tag",
  "mac_addresses": [],
  "warranty_start_at": "your_warranty_start_at",
  "owner": {},
  "policy": {},
  "tags": [],
  "organization": {},
  "warranty_end_at": "your_warranty_end_at",
  "remote_data": {}
};

const response = await fetch(`https://api.truto.one/unified/mdm/devices/{id}?integrated_account_id=${integratedAccountId}`, {
  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/mdm/devices/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
    "integrated_account_id": "<integrated_account_id>"
}
payload = {
    "name": "your_name",
    "serial_number": "your_serial_number",
    "asset_tag": "your_asset_tag",
    "mac_addresses": [],
    "warranty_start_at": "your_warranty_start_at",
    "owner": {},
    "policy": {},
    "tags": [],
    "organization": {},
    "warranty_end_at": "your_warranty_end_at",
    "remote_data": {}
}

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 result = await truto.unifiedApi.update(
  'mdm',
  'devices',
  '<resource_id>',
  {
  "name": "your_name",
  "serial_number": "your_serial_number",
  "asset_tag": "your_asset_tag",
  "mac_addresses": [],
  "warranty_start_at": "your_warranty_start_at",
  "owner": {},
  "policy": {},
  "tags": [],
  "organization": {},
  "warranty_end_at": "your_warranty_end_at",
  "remote_data": {}
},
  { integrated_account_id: '<integrated_account_id>' }
);

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():
    result = await truto_api.unified_api.update(
        "mdm",
        "devices",
        "<resource_id>",
        {
        "name": "your_name",
        "serial_number": "your_serial_number",
        "asset_tag": "your_asset_tag",
        "mac_addresses": [],
        "warranty_start_at": "your_warranty_start_at",
        "owner": {},
        "policy": {},
        "tags": [],
        "organization": {},
        "warranty_end_at": "your_warranty_end_at",
        "remote_data": {}
},
        {"integrated_account_id": "<integrated_account_id>"}
    )
    print(result)

asyncio.run(main())
```
