---
name: "saveDevProperty"
mode: "api"
versionRequirements:
  - { name: "@ray-js/ray", version: "1.5.2" }
title: "saveDevProperty - Write Custom Device Property Data"
---

## saveDevProperty

> [VERSION] @ray-js/ray >= 1.5.2

### Description

Write device property data set via custom settings; after saving, retrieve it with getDevProperty

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `params` | `ISaveDevProperty` | Yes | Request parameters |

### Return Value

Type: `Promise<boolean>`

Whether the save was successful

### Referenced Types

##### `interface` ISaveDevProperty

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `bizType` | `number` | Business type (custom) |
| `propertyList` | `string` | Device custom attribute list; for the string structure, see details. |
| `type` | `"remainAfterReset" \| string` | Rules for persisting device attributes; only applies to the attributes being written. By default, the data is removed on device reset and on reset with data cleared. You can set it to `remainAfterReset` to keep the data on device reset and remove it only on reset with data cleared |


### Examples

#### Basic usage

```ts
import { saveDevProperty } from '@ray-js/ray';

saveDevProperty({
  devId: 'your_device_id',
  bizType: 0,
  propertyList: JSON.stringify([
    { code: 'hello', value: 'world' },
    { code: 'foo', value: 'bar' },
  ]),
}).then((response) => {
  console.log('Save result:', response);
}).catch((err) => {
  console.error(err);
});
```
