HomeGuidesAPI ReferenceGraphQL
Submit Documentation FeedbackJoin Developer CommunityLog In

Settings Store

This topic describes how to store customer data using the settings store in Optimizely Connect Platform (OCP).

See SDK Reference for additional details.

The settings store is where settings form data is stored. Like the secret store, it is encrypted in-flight and at rest using AES 256-bit encryption and is a safe place to store passwords and API keys/tokens. When a user configures your app through the settings form, you can read and update the data backing the form by writing it to the settings store.



Do not write sensitive data such as user names, passwords, API keys, or API tokens to any store other than the secrets or settings store.

Writing to the settings store

When your app handles a settings form submission, you should write the user data to the settings store after you make any necessary modifications.

import {storage} from '@zaius/app-sdk';
// ...
public async onSetupForm(section: string, action: string, formData: App.ValueHash): Promise<App.Response> {
  // validate formData and make any changes necessary
  // then save the data for this section to the settings store:
  await storage.settings.put(section, formData);
  return new AppResponse(200);

Any data you write to the settings store is available to the form UI to be displayed or used to determine what to show or hide for the user.

Update data in the settings store

Most of the time you will be writing to the settings store when your app handles a settings form submission but you can also write to it any time you want to update the data for that form. For example, to make it clear to the user a historical import was previously run:

const update = {complete: true, completed_at: new Date().toISOString()};
await storage.settings.patch('importSection', update);

Your settings form can then display this information to the user instead of showing a button to start the import or a notification the import is running.

Getting Settings Form Data

When you need to access user-provided configuration such as in a job to decide which list to import or to use the user's credentials, you can read the desired form from the settings store.

import {storage} from '@zaius/app-sdk';
const credentials = await storage.settings.get('authentication');
reauthenticate(credentials.user_name, credentials.password);

While rare, there may be cases where you want to delete configuration such as if the user changes the mode of your app and you want to clear the configuration relevant to the previous mode. To do this, you should delete each section you want to clear.

await storage.settings.delete('authentication')
await storage.settings.delete('list_options')

When an app is uninstalled, all settings data is deleted. If the app is reinstalled, the settings store is empty.

Did this page help you?