The Key-Value Store also lets you store key-value pairs in a secure, encrypted manner. Use the methods listed here to store sensitive data. Data stored through these methods can't be queried through the query method.
To start, import the Forge API package in your app, as follows:
1 2import { storage } from '@forge/api';
Each installation of your app is subject to the Storage API's quotas and limits. See Storage quotas and Storage limits for more details.
The app storage API requires your app to have the storage:app
scope. See
Add scopes to call an Atlassian REST API
guide to add new scopes to your app.
Similar to storage.set
, storage.setSecret
provides a way to store sensitive credentials.
Values set with storage.setSecret
can only be accessed with storage.getSecret
.
The same limitation is applied: persisted JSON values may be up to 128 KiB in size and have a key of up to 500 bytes.
You do not need to identify your app or the active site/installation in your key, as Forge will do this automatically.
Write conflicts are resolved using a last-write-wins strategy.
1 2storage.setSecret(key: string, value: array | boolean | number | object | string ): Promise<void>;
Sets the key example-key
to one of the supported value types.
1 2// array storage.setSecret('example-key', [ 'Hello', 'World' ]); // boolean storage.setSecret('example-key', true); // number storage.setSecret('example-key', 123); // object storage.setSecret('example-key', { hello: 'world' }); // string storage.setSecret('example-key', 'Hello world');
Gets a value by key, which was stored using storage.setSecret
. If the key doesn't exist, the API returns undefined
.
1 2storage.getSecret(key: string): Promise<array | boolean | number | object | string>;
Gets the secret value associated with the key example-key
.
1 2// Read the value for key `example-key` await storage.getSecret('example-key');
Deletes a secret value by key, this succeeds whether the key exists or not.
Write conflicts are resolved using a last-write-wins strategy.
1 2storage.deleteSecret(key: string): Promise<void>;
Deletes the value associated with the key example-key
, if it hasn't already been deleted.
1 2// Delete the value with the key `key` await storage.deleteSecret('example-key');
Rate this page: