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.


Notes

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

  • Logging secrets.

    If you need to log sensitive values like passwords from device storage, prefer zw.logTemp() over zw.log(). zw.logTemp() shows the value in the live run logs without persisting it to the TaskBot run reports.

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

Last updated

Was this helpful?