# patchDeviceData

Audience: Developer

Apply RFC 6902 JSON Patch operations to the device's data field.

Apply RFC 6902 JSON Patch operations to the device's data field.

**Served by:** [management](https://docs.pyck.cloud/dev/api/services/management.md)

## Arguments

| Name | Type |
| --- | --- |
| `id` | ID! |
| `patches` | \[[JSONPatchInput](https://docs.pyck.cloud/dev/api/inputs/jsonpatchinput.md)!\]! |

## Returns

[DeviceOutput](https://docs.pyck.cloud/dev/api/types/deviceoutput.md)!

## Example

Applies RFC 6902 JSON Patch operations to the device's data field. Only changed fields are modified; untouched fields are preserved.

```graphql
mutation PatchDeviceData($id: ID!, $patches: [JSONPatchInput!]!) {
  patchDeviceData(id: $id, patches: $patches) {
    device {
      createdAt
      createdBy
      data
      dataTypeID
      dataTypeSlug
      deletedAt
      deletedBy
      id
      name
      tenantID
      updatedAt
      updatedBy
    }
    eventCount
    transactionID
  }
}
```

**Variables**

```json
{
  "id": "<device id to patch>",
  "patches": [
    {
      "op": "REPLACE",
      "path": "/firmware",
      "value": "\"2.0\""
    },
    {
      "op": "REPLACE",
      "path": "/battery",
      "value": "95"
    }
  ]
}
```
