# snap_manageState

> Reference documentation for the `snap_manageState` method of the Snaps API.

<SnapsAPIReference method={{"name":"snap_manageState","description":"Allow the Snap to persist up to 64 MB of data to disk and retrieve it at\nwill. By default, the data is automatically encrypted using a Snap-specific\nkey and automatically decrypted when retrieved. You can set `encrypted` to\n`false` to use unencrypted storage (available when the client is locked).","parameters":{"kind":"union","type":"{ operation: \"clear\"; encrypted?: boolean | null } | { operation: \"get\"; encrypted?: boolean | null } | { operation: \"update\"; encrypted?: boolean | null; newState: Record<string, JSON> }","description":"An object containing the parameters for the `snap_manageState` method.","commonProperties":[{"kind":"primitive","type":"boolean","description":"Whether to use the encrypted or unencrypted state. Defaults to `true`\n(encrypted). Encrypted state is only accessible when the wallet is\nunlocked, while unencrypted state is accessible whether the wallet is\nlocked or unlocked. State can be cleared regardless of the wallet's lock\nstate, but this parameter determines which state is cleared.","name":"encrypted","required":false}],"options":[{"kind":"object","type":"{ operation: \"clear\"; encrypted?: boolean | null }","description":"The `clear` operation, which deletes all stored state.","required":true,"properties":[{"kind":"primitive","type":"\"clear\"","description":"The literal string \"clear\" to indicate that this is a clear operation.","name":"operation","required":true}]},{"kind":"object","type":"{ operation: \"get\"; encrypted?: boolean | null }","description":"The `get` operation, which retrieves the stored state.","required":true,"properties":[{"kind":"primitive","type":"\"get\"","description":"The literal string \"get\" to indicate that this is a get operation.","name":"operation","required":true}]},{"kind":"object","type":"{ operation: \"update\"; encrypted?: boolean | null; newState: Record<string, JSON> }","description":"The `update` operation, which replaces the stored state with a new value.","required":true,"properties":[{"kind":"primitive","type":"\"update\"","description":"The literal string \"update\" to indicate that this is an update operation.","name":"operation","required":true},{"kind":"primitive","type":"Record<string, JSON>","description":"The new state to store. Must be a JSON-serializable object.","name":"newState","required":true}]}]},"result":{"kind":"primitive","type":"Record<string, JSON> | null","description":"If the operation is `get`, the result is the state. Otherwise, the result is\n`null`."},"examples":[{"examples":[{"name":"Manifest","language":"json","content":"{\n  \"initialPermissions\": {\n    \"snap_manageState\": {}\n  }\n}\n"},{"name":"Usage","language":"ts","content":"// Persist some data.\nawait snap.request({\n  method: 'snap_manageState',\n  params: {\n    operation: 'update',\n    newState: { hello: 'world' },\n  },\n})\n\n// At a later time, get the stored data.\nconst persistedData = await snap.request({\n  method: 'snap_manageState',\n  params: { operation: 'get' },\n})\n\nconsole.log(persistedData)\n// { hello: 'world' }\n\n// If there's no need to store data anymore, clear it out.\nawait snap.request({\n  method: 'snap_manageState',\n  params: {\n    operation: 'clear',\n  },\n})\n"}]}],"subjectTypes":["snap"],"restricted":true}}  />
