# API to change Data Retention period of Immutable device

**URL:** https://community.tago.io/t/api-to-change-data-retention-period-of-immutable-device/1637
**Category:** Analysis and Actions
**Created:** [July 16, 2024, 12:19pm UTC](https://community.tago.io/t/api-to-change-data-retention-period-of-immutable-device/1637 "2024-07-16T12:19:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hegde.ramyanarayan](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hegde.ramyanarayan](https://community.tago.io/u/hegde.ramyanarayan)
#### Post date: [July 16, 2024, 12:19pm UTC](https://community.tago.io/t/api-to-change-data-retention-period-of-immutable-device/1637/1 "2024-07-16T12:19:07Z")

</div>

Hi,

I could not able to find the methods which allow to edit the data retention period of device in Resources.devices.As we cannot use account.buckets, it would be great if you indicate me the API which allow us to perform this functionality.

Thank you

---

<div class="post-metadata">

### Author: ![mateus.silva](https://avatars.discourse-cdn.com/v4/letter/m/77aa72/32.png) [@mateus.silva](https://community.tago.io/u/mateus.silva)
#### Post date: [July 16, 2024, 2:07pm UTC](https://community.tago.io/t/api-to-change-data-retention-period-of-immutable-device/1637/2 "2024-07-16T14:07:38Z")

</div>

Hello hegde.ramyanarayan,

Regarding your question, it is indeed possible to edit the retention chunk, but the period chunk cannot be edited.

To update the retention, you can use the **Resources.devices.edit()** method. Below is an example of how to use it. Please ensure that you have the appropriate permissions set in [Access Management](https://help.tago.io/portal/en/kb/articles/183-access-management).

const { Analysis, Resources } = require(“@tago-io/sdk”);

async function startAnalysis() {

const [fetchDevice] = await Resources.devices.list({

amount: 1,

fields: [“id”, “name”],

filter: { tags: [{ key: “device\_type”, value: “device” }] }

});

if (!fetchDevice) {

throw new Error(“Device not found”);

}

await Resources.devices.edit(fetchDevice.id, { chunk\_retention: 6 });

console.info(“Finished”);

}

---

<div class="post-metadata">

### Author: ![hegde.ramyanarayan](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hegde.ramyanarayan](https://community.tago.io/u/hegde.ramyanarayan)
#### Post date: [July 16, 2024, 5:27pm UTC](https://community.tago.io/t/api-to-change-data-retention-period-of-immutable-device/1637/3 "2024-07-16T17:27:33Z")

</div>

Thank you Mateus. It worked
