Device Storage (upcoming)

Available in version 1.1.72 (not yet live).

Persist key–value data on this device. Survives Desktop Agent restarts, uninstalls, and reinstalls. Stays on this device; data is never sent to ZeroWork servers.

API zw.deviceStorage.*

const credentials = {
  username: await zw.deviceStorage.get("username_salesforce"),
  password: await zw.deviceStorage.get("password_salesforce"),
};
await zw.deviceStorage.set("last_login_salesforce", String(Date.now()));

At a Glance

  • async await zw.deviceStorage.get(key: string) β†’ returns the string value for the key, or undefined if not set.

  • async await zw.deviceStorage.set(key: string, value: string) β†’ saves a string value under the key.

  • async await zw.deviceStorage.remove(key: string) β†’ removes the key and its value from device storage.

  • async await zw.deviceStorage.has(key: string) β†’ returns true if the key exists, otherwise false.

  • async await zw.deviceStorage.getAll() β†’ returns an object of key–value pairs { [key: string]: string }.


Adding Secrets

For passwords, API tokens, and other sensitive values, add them in the Desktop Agent UI instead of saving them as plain text in the Write JS building block using zw.deviceStorage.set(). (Reading a value with zw.deviceStorage.get() is safe.)

To add a secret:

  1. Open the Desktop Agent.

  2. Select Device storage from the tray menu.

  3. Click Add key, then save your value.


Examples

Check if value is present and set if not

Securely log in with credentials stored only locally

Clear device storage


Saving Non-String Values

Device storage only accepts strings. You can stringify on write and parse on read if you want to work with other types.


Logging Secrets

If you need to log sensitive values (like passwords or API tokens), use zw.logTemp() instead of zw.log(). zw.logTemp() shows the value in the live run logs, but it is not saved to TaskBot run reports.

⚠️ Avoid using zw.deviceStorage.get() to read secrets via Code in Inputs in no-code building blocks. Many building blocks auto-log values, and those logs are saved to TaskBot run reports.


Notes

  • Size limits. Total device storage is limited to ~3,000,000 characters. Writes that would exceed the total limit will throw an error.

  • Always use await. All methods in zw.deviceStorage.* are async, whether the code runs locally or in the browser.

Last updated